-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add parameter for limiting maximum AOF files size on disk #1425
Open
kronwerk
wants to merge
2
commits into
valkey-io:unstable
Choose a base branch
from
kronwerk:aof_size_limit
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
proc setup {{size 1}} { | ||
r set k v | ||
r config set aof-max-size $size | ||
r set k2 v2 | ||
} | ||
|
||
proc cleanup {} { | ||
r config set aof-max-size 0 | ||
r flushall | ||
} | ||
|
||
start_server {tags {"external:skip"}} { | ||
r config set auto-aof-rewrite-percentage 0 ; # disable auto-rewrite | ||
r config set appendonly yes ; # enable AOF | ||
|
||
set master_host [srv 0 host] | ||
set master_port [srv 0 port] | ||
|
||
test "Low aof-max-size stops writing AOF with ENOSPC" { | ||
setup | ||
wait_for_log_messages 0 {"*Error writing to the AOF file: No space left on device*"} 0 100 10 | ||
cleanup | ||
} | ||
|
||
test "New write attempts when limited with aof-max-size fail and doesn't insrease AOF buffer anymore" { | ||
setup | ||
set info1 [r info] | ||
set buf1 [getInfoProperty $info1 mem_aof_buffer] | ||
set len1 [getInfoProperty $info1 aof_buffer_length] | ||
|
||
catch {r set somelongerkey somelongrvalue} err | ||
assert {$err eq "MISCONF Errors writing to the AOF file: No space left on device"} | ||
assert_equal [r get somelongerkey] "" | ||
|
||
set info2 [r info] | ||
set buf2 [getInfoProperty $info2 mem_aof_buffer] | ||
set len2 [getInfoProperty $info2 aof_buffer_length] | ||
assert_equal $buf1 $buf2 | ||
assert_equal $len1 $len2 | ||
cleanup | ||
} | ||
|
||
test "Increasing aof-max-size fixes AOF write error" { | ||
setup | ||
set loglines [count_log_lines 0] ; # want to check new line, not from previous test | ||
r config set aof-max-size 1000 | ||
wait_for_log_messages 0 {"*AOF write error looks solved. The server can write again.*"} $loglines 100 10 | ||
|
||
assert_equal [r set k3 v3] "OK" | ||
assert_equal [r get k3] "v3" | ||
cleanup | ||
} | ||
|
||
test "Meeting aof-max-size does not prevent AOF rewrite" { | ||
setup 200 | ||
set loglines [count_log_lines 0] ; # want to check new line, not from previous test | ||
|
||
waitForBgrewriteaof r | ||
r bgrewriteaof | ||
wait_for_log_messages 0 {"*Background AOF rewrite finished successfully*"} $loglines 100 10 | ||
wait_for_log_messages 0 {"*AOF write error looks solved. The server can write again.*"} $loglines 100 10 | ||
cleanup | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message:
Error writing to the AOF file: <ENOSPC>
is misleading if the issue is not actual disk space but hitting the configured max file size. Consider logging a more explicit message, and using
EFBIG
instead ofENOSPC
for clarity.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about smth like that, but haven't found a better error code than ENOSPC. the one you offered is (https://man7.org/linux/man-pages/man2/open.2.html):
EOVERFLOW pathname refers to a regular file that is too large to be opened. The usual scenario here is that an application compiled on a 32-bit platform without -D_FILE_OFFSET_BITS=64 tried to open a file whose size exceeds (1<<31)-1 bytes; see also O_LARGEFILE above. This is the error specified by POSIX.1; before Linux 2.6.24, Linux gave the error EFBIG for this case.
seems that it's more misleading (imho) - we're not opening a file, we're writing to it, and we're exactly out of space (though the limit is not a real disk limit).
we can try to define our own errno type, a new one, to differ it from the real disk limit and form a more descriptive message based on that upper in code stack - but shouldn't that be an overkill for such an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POSIX error codes aren't tied to specific system/library calls and can be applied broadly. In the example above, it was in the context of
open
. Applications can use their own interpretations, this is an example:https://github.com/valkey-io/valkey/blob/unstable/src/module.c#L5427
I'm fine with using either error codes, but there should be a custom error message to avoid misleading users into thinking it's a real disk space issue if ENOSPC is used.