-
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
Fix member response header missing revision #14026
Conversation
Codecov Report
@@ Coverage Diff @@
## main #14026 +/- ##
==========================================
- Coverage 74.96% 74.73% -0.24%
==========================================
Files 450 450
Lines 37173 37173
==========================================
- Hits 27868 27781 -87
- Misses 7532 7602 +70
- Partials 1773 1790 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
The change looks good to me. Two additional verification:
|
@@ -106,7 +106,7 @@ func (cs *ClusterServer) MemberPromote(ctx context.Context, r *pb.MemberPromoteR | |||
} | |||
|
|||
func (cs *ClusterServer) header() *pb.ResponseHeader { | |||
return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.ID()), RaftTerm: cs.server.Term()} | |||
return &pb.ResponseHeader{ClusterId: uint64(cs.cluster.ID()), MemberId: uint64(cs.server.ID()), RaftTerm: cs.server.Term(), Revision: cs.server.KV().Rev()} |
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.
This goes into recent discussion about meaning of revision in lease response requests that was raised during community meeting #13989. Please remember that revision only relates to key value store, even though revision field is present in all etcd rpc responses. Current situation is not satisfactory as usage of revision is inconsistent and not properly documented.
Before we merge this PR we should make a decision of meaning of revision in all rpc responses and document it. We should look into how revision is used currently in APIs, propose changes and analyse impact if we would make changes.
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.
Please remember that revision only relates to key value store,
This might not be correct. I think revision
is related to any data which needs raft consensus. Membership info definitely needs raft consensus.
Lease is a special case, which we can discuss separately.
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 think you mistook revision
for raft index
. It's raft index that relates to all data which needs raft concensus. Revision is global version number used for key value store. Etcd implements MVCC by using btree with revision as key.
You see this if you look how bbolt is used, we have multiple buckets
used to stored different values:
- key values are stored under
key
bucket with keys being revisions - leases are stored under `lease bucket with keys being revision id
- membership info is stored under two buckets
members
andmembers_removed
both use member id as key
So if you look at this at low level, only KV store uses revision to version changes, however leases and membership is not versioned and totally unaware of revision.
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.
Yes, you are right. The key for the lease is lease ID.
This could be the reason why member related commands do not have revision in the header.
But all responses share the same header struct, so we might need to hide the revision field if it's 0. For example printer_fields.go#L39
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.
+1 to hiding in etcdctl and not exposing revision for these methods.
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.
Okay. The missing revision behavior sounds like intended not to reflect unrelated mvcc global revision.
Fix issue raised in #14020 (comment)
Before
After