-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
etcdserver: fix corruption check when server has just been compacted #14457
Conversation
@@ -542,23 +542,19 @@ type hashKVResult struct { | |||
func TestHashKVWhenCompacting(t *testing.T) { |
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 reason for the refactoring of this test case, is that the test used to run compactions/HashByRev for 1000 rounds, using hash 9899 to 9999, with no guarantee that all compactions have finished before the end of the test.
Now, the test runs for as long as it takes to complete all compactions (within a limit of 10 seconds), using revisions from 9900 to 10000. This is beneficial because the problem from the initial issue, only appears after compacting revision 10000.
My issues with the proposed change:
|
Thank you for reviewing the PR @serathius
The intention here was actually to make the HashByRev API consistent with Range, which I believe is what the author of #14325 meant in #14325 (comment) when he/she said:
I believe the following test illustrates this point. Start with a fresh etcd cluster:
Then compact it at revision 5:
Then check what revisions are accessible with Range:
As the version at which the compaction is done (5) is still available, it made sense to me that HashByRev raising an "required revision has been compacted" error when called on the revision, was indeed an issue. This inconsistency is what we can see when we compare this for the HashByRev API: etcd/server/storage/mvcc/kvstore.go Lines 180 to 182 in e61d431
and this for the Range API: etcd/server/storage/mvcc/kvstore_txn.go Lines 74 to 76 in fff5d00
with the comparison being "<=" on one side, and "<" on the other side.
Fully agree that this is a rare case.
Fair enough. |
@serathius : would you suggest we simply close the PR and associated issue, please ? |
Sorry for mistaking it there. I think there is some value in making API consistent, however from top of my head I don't know if this change doesn't negatively impact any of existing mechanisms using HashKV. @ahrtr what's your opinion? |
I will have a closer look at this PR and related issue late today or tomorrow morning my time. |
I think this is a valid PR. When the leader performs the periodic check , it calculates the hash up to the etcd/server/storage/mvcc/kvstore.go Line 180 in 54f9483
But when leader uses the same |
Please note that when I review this PR, I found a related issue, please see #14510 |
When a key-value store corruption check happens immediately after a compaction, the revision at which the key-value store hash is computed, is the compacted revision itself. In that case, the hash computation logic was incorrect because it returned an ErrCompacted error; this error should instead be returned when the revision at which the key-value store is hashed, is strictly lower than the compacted revision. Fixes etcd-io#14325 Signed-off-by: Jeremy Leach <44558776+jbml@users.noreply.github.com>
682fd4a
to
cc1e245
Compare
Overall looks good to me, and I don't see any negative impact.
|
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.
Hello @serathius , |
@jbml Could you backport this PR to 3.5 and 3.4 if needed? |
I found this still do not backport to v3.4 and v3.5. I would help to do this. |
When a key-value store corruption check happens immediately after a compaction, the revision at which the key-value store hash is computed, is the compacted revision itself.
In that case, the hash computation logic was incorrect because it returned an ErrCompacted error; this error should instead be returned when the revision at which the key-value store is hashed, is strictly lower than the compacted revision.
Fixes #14325
Signed-off-by: Jeremy Leach 44558776+jbml@users.noreply.github.com