-
Notifications
You must be signed in to change notification settings - Fork 3.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
raftlog: correctly decode empty commands #100401
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
An alternative here is for either |
51efa85
to
c4d50c9
Compare
Note to self: check for any backwards compatibility concerns with 22.2 here. |
c4d50c9
to
d6bbe6b
Compare
v22.2 uses an empty payload rather than an empty entry: cockroach/pkg/kv/kvserver/replica_raft_quiesce.go Lines 91 to 92 in 43a37d5
This empty payload was handled here: cockroach/pkg/kv/kvserver/replica_application_cmd.go Lines 224 to 231 in 5819d7a
I've therefore updated this PR to retain the previous encoding (with command ID), and instead decode empty payloads into empty entries, for backwards compatibility with 22.2 entries. |
d6bbe6b
to
d50a5c0
Compare
d50a5c0
to
ef559b6
Compare
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.
Ended up nits-only, so feel free to skip them.
Maybe all of these would be better indicated with some explicit enum, but it would be a bigger change. |
When unquiescing a Raft group, an empty command is proposed to wake the Raft leader. During application, empty entries are considered noops, but only if they don't have a command ID. However, Raft entry decoding would preserve the command ID of an empty payload. `CheckForcedErr()` thus no longer considered this a noop, instead returning an error because the `ProposerLeaseSequence` of 0 was older than the current lease. Construction and processing of this error had a non-negligible cost when unquiescing a large number of ranges. This patch makes sure such empty commands are decoded as empty entries, without a command ID, and thus considered noops. Epic: none Release note: None
ef559b6
to
904afdd
Compare
Yeah, I'm going for a targeted change here, since this needs a 23.1 backport. |
TFTR! bors r+ |
Build succeeded: |
When unquiescing a Raft group, an empty command is proposed to wake the Raft leader. During application, empty entries are considered noops, but only if they don't have a command ID. However, Raft entry decoding would preserve the command ID of an empty payload.
CheckForcedErr()
thus no longer considered this a noop, instead returning an error because theProposerLeaseSequence
of 0 was older than the current lease. Construction and processing of this error had a non-negligible cost when unquiescing a large number of ranges.This patch makes sure such empty commands are decoded as empty entries, without a command ID, and thus considered noops.
Resolves #100400.
Epic: none
Release note: None