fix return value of loadAppendOnlyFiles#10295
Conversation
When one of the AOF files succeeded to load, but the last AOF file was empty, the loadAppendOnlyFiles will return AOF_EMPTY. This commit changes this behavior, and return AOF_OK in that case. This can happen for example, when loading old AOF file, and no more commands processed, the manifest file will include base AOF file with data, and empty incr AOF file.
There was a problem hiding this comment.
Thanks, I found out that the return value of AOF was introduced in #9012 (which you submitted). In this PR, AOF_EMPTY is considered a correct return value (such as in debug loadaof).
But in multi part aof, both base and incr AOF may be empty. The current implementation is to directly ignore the empty return value during the AOF loading process, and finally return it to the upper-level caller for processing.
But I found that at the end of the loadAppendOnlyFiles function, there is a problem when we use stopLoading(ret == AOF_OK) At this time, if ret is AOF_EMPTY, we will send a wrong load event to the module, which is not as expected. So I think this modification of yours makes sense. Or change to stopLoading(ret == AOF_OK || ret == AOF_EMPTY) to use less code to get the same effect.
In addition, according to your modification, the upper-level caller will no longer perceive AOF_EMPTY, so can we remove judgment on AOF_EMPTY in debug.c?
|
I think it's a good idea to keep supporting the EMPTY return value, some callers may want to treat that as a failure (e.g debug.c, or if we some day have an explicit AOFLOAD command). as for stopLoading. ideally, we could have left that for the caller to decide what's a failure, or maybe pass in some flag telling loadAppendOnlyFiles which values are a failure, but that's too complicated. |
src/aof.c
Outdated
| if (aof_loaded && ret == AOF_EMPTY) ret = AOF_OK; | ||
|
|
||
| cleanup: | ||
| stopLoading(ret == AOF_OK); |
There was a problem hiding this comment.
i think we need to treat TRUNCATED and maybe EMPTY as success..
There was a problem hiding this comment.
Agree.
- if no base and no incr AOF,we just return
AOF_NOT_EXIST - or if
total_size == 0, we just returnAOF_EMPTY - if any of the middle AOF is empty ,we convert the ret to
AOF_OK - if the AOF was truncated (only the last file) , we also treat it as
AOF_OK
@oranagra right ?
There was a problem hiding this comment.
yes, that's the logic i aim for.
please check the code to make sure we didn't miss anything.
There was a problem hiding this comment.
@YaacovHazan Maybe you need to update your PR to satisfy the above logic. thanks.
There was a problem hiding this comment.
@chenyang8094 already added a new commit... pls review
|
@chenyang8094 thanks for the review. |
treat TRUNCATED and EMPTY as success
no need for extra aof_loaded vairable
|
@chenyang8094 I pushed a new commit, please review. |
fix compliation
You are right. Maybe I should have made |
make getBaseAndIncrAppendOnlyFilesSize return extra information if we succeeded or not to get the AOF files size
|
@chenyang8094 makes sense... I changed the |
fix the usage of status pointer
some more fixes
@YaacovHazan Please solve the test error, thanks. |
Make sure the status return from loading multiple AOF files reflects the overall
result, not just the one of the last file.
When one of the AOF files succeeded to load, but the last AOF file
was empty, the loadAppendOnlyFiles will return AOF_EMPTY.
This commit changes this behavior, and return AOF_OK in that case.
This can happen for example, when loading old AOF file, and no more commands processed,
the manifest file will include base AOF file with data, and empty incr AOF file.