-
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
HashKV should compute the hash of all MVCC keys up to a given revision #18337
Comments
Value return by HashKV api call till IMO, this is not correct as HashKV api call calculates the hash of all MVCC key-values, whereas snapshot is snapshot of etcd db which also contains cluster information, hence the hash will not be same. |
Hi @ishan16696
I don't follow this. Do you mean etcd/api/etcdserverpb/rpc.proto Lines 226 to 238 in e7f5729
|
Hi @fuweid ,
Than to validate the integrity of this snapshot, If I calculate the hash this snapshot taken via snapshot api call upto |
Anyway, my doubt is different from this issue, I have now open a separate issue now: #18340 |
The
However, both
Unfortunately, it's not. |
Compaction is tightly coupled with HashKV, we have to consider/discuss them together. We need to get consensus on #18274 (comment) firstly. As mentioned in that comment, compatibility ( Probably it would be better to turn that into a KEP " |
Bug report criteria
What happened?
Based on https://etcd.io/docs/v3.5/dev-guide/api_reference_v3/, HashKV api should compute the hash of all MVCC keys up to a given revision, even if the key/value is tombstone. However, HashKV could skip compacted revision.
etcd/server/storage/mvcc/hash.go
Lines 60 to 76 in e7f5729
For the compacted revision, the
lower.GreaterThan(kr)
always return true.Assume that the compacted revision is for key
A
. If the keyA
has revisions higher than compacted revision, the HashKV won't compute the hash on compacted revision.Case 1: ETCD contains more than two keys
For example, there are two keys in store.
After compaction on
Revision{Main: 5}
, the store will be likeWhen we perform HashKV on
Revision{Main: 7}
, the hash should compute the following revisions:However, HashKV skips
Revision{Main: 5}
because the compacted revision is{Main: 5}
andkvindex.Keep
returns two revisions{Main: 2, Sub: 1}
and{Main: 7}
, TheRevision{Main: 5}
isn't in result ofkvindex.Keep
.Case 2: ETCD contains only one key
There is key
foo
.After compaction on
Revision{Main: 5}
, the store will be likeWhen we perform HashKV on
Revision{Main: 7}
, the hash should compute the following revisions:HashKV skips
Revision{Main: 5}
because the compacted revision is{Main: 5}
andkvindex.Keep
returns one revision{Main: 7}
.However, when we perform HashKV on
Revision{Main: 8}
, thekvindex.Keep
will return emptykeep
because theRevision{Main: 8}
is tombstone. So, the hash result will compute the following revisions, which is expectation.What did you expect to happen?
HashKV should compute the hash of all MVCC keys up to a given revision
How can we reproduce it (as minimally and precisely as possible)?
fuweid@a6454f2
Anything else we need to know?
The HashKV was introduced by #8263. IMO, the
keep
, available revision map, was used to skip the revisions which were marked deleted in on-going compaction. If there is no compaction, thekeep
is always empty and then HashKV will compute all the MVCC keys up to the revision.#8263 has bug and then #8333 introduced
keyIndex.Keep
interface to fixbug
.However, after #8333, the non-empty
keep
map forces HashKV to skip compacted revision.Etcd version (please run commands below)
Etcd configuration (command line flags or environment variables)
paste your configuration here
Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)
Relevant log output
No response
The text was updated successfully, but these errors were encountered: