-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
storage: don't clobber HardState on splits #17051
Conversation
pkg/storage/client_split_test.go
Outdated
@@ -2212,3 +2212,131 @@ func TestPushTxnQueueDependencyCycleWithRangeSplit(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestMinimal(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.
ha, TestMinimal
was something I used for the quick hacky test. Can/Should be renamed (also breaks my hacky workflows).
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.
Oops, didn't actually mean to commit. Removed.
Hmm, the assertion I put in is obviously garbage. Let me rework that. |
Cleaned up, PTAL. |
Are there really no migration concerns? When this goes in, leaders will stop emitting HardStates in their write batches for splits, but followers may not yet know that they need to do it themselves. I don't think that will work because we won't fill in the missing HardState values at read time. Reviewed 5 of 14 files at r1, 1 of 2 files at r3, 8 of 8 files at r4. pkg/storage/replica_state.go, line 489 at r4 (raw file):
The remaining mentions of pkg/storage/replica_state.go, line 498 at r4 (raw file):
Instead of passing in truncState and raftAppliedIndex, maybe this should take pkg/storage/client_split_test.go, line 2216 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
It's now added in one commit and removed in the next one. You can remove this file completely from both commits. Comments from Reviewable |
You're right, my statement is wrong. We'll have to migrate as per the usual. I think I'll send a quick PR to get some stubs into place so that we can start landing changes before the migration RFC is implemented. Modified the commit message to point out the migration concern. Review status: 3 of 11 files reviewed at latest revision, 3 unresolved discussions, some commit checks pending. pkg/storage/replica_state.go, line 489 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/replica_state.go, line 498 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I like to avoid hard-coding pkg/storage/client_split_test.go, line 2216 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. Comments from Reviewable |
Added the "migration" as well. |
fb0fc47
to
9550420
Compare
Review status: 2 of 12 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. Comments from Reviewable |
Reviewed 4 of 14 files at r1, 9 of 9 files at r5, 1 of 1 files at r6, 7 of 7 files at r7, 2 of 2 files at r8. pkg/storage/below_raft_protos_test.go, line 80 at r8 (raw file):
why not generate a new function like these other protos have? pkg/storage/replica.go, line 4413 at r6 (raw file):
is this intentionally mixing log.Fatal and panic? pkg/storage/replica_command.go, line 3079 at r8 (raw file):
s/write initial/synthesize/? Comments from Reviewable |
This was previously in storage/engine, which is not a canonical place for it.
Motivated by cockroachdb#16749. Added an assertion that catches HardState clobbering. Now ``` make stressrace PKG=./pkg/storage/ TESTS=TestStoreRangeSplitRaceUninitializedRHS ``` fails immediately with ``` clobbered hard state: [Term: 8 != 9 Commit: 10 != 0] previously: raftpb.HardState{ Term: 0x9, Vote: 0x2, Commit: 0x0, XXX_unrecognized: nil, } overwritten with: raftpb.HardState{ Term: 0x8, Vote: 0x2, Commit: 0xa, XXX_unrecognized: nil, } ``` which is fixed in the next commit in this PR.
Since the move to proposer-evaluated KV, we were potentially clobbering the HardState on splits as we accidentally moved HardState synthesis upstream of Raft as well. This change moves it downstream again. Though not strictly necessary, writing lastIndex was moved as well. This is cosmetic, though it aids @irfansharif's PR cockroachdb#16809, which moves lastIndex to the Raft engine. After this PR, neither HardState nor last index keys are added to the WriteBatch, so that pre-cockroachdb#16993 `TruncateLog` is the only remaining command that does so (and it, too, won't keep doing that for long). Migration concerns: a lease holder running the new version will propose splits that don't propose the HardState to Raft. A follower running the old version will not write the HardState downstream of Raft. In combination, the HardState would never get written, and would thus be incompatible with the TruncatedState. Thus, while 1.0 might be around, we're still sending the potentially dangerous HardState. Fixes cockroachdb#16749.
Review status: all files reviewed at latest revision, 6 unresolved discussions, all commit checks successful. pkg/storage/below_raft_protos_test.go, line 80 at r8 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Wouldn't that entail mucking with the vendored proto? I guess we could upstream the pkg/storage/replica.go, line 4413 at r6 (raw file): Previously, tamird (Tamir Duberstein) wrote…
absolutely not, made them both pkg/storage/replica_command.go, line 3079 at r8 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. (synthesize initial). Comments from Reviewable |
Review status: 3 of 12 files reviewed at latest revision, 6 unresolved discussions, all commit checks successful. pkg/storage/below_raft_protos_test.go, line 80 at r8 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Instead of upstreaming a new gogoproto option, It would be simpler to use reflection on the HardState struct to make sure that it only has the expected fields. Comments from Reviewable |
Reviewed 1 of 8 files at r4, 9 of 9 files at r11. pkg/storage/below_raft_protos_test.go, line 80 at r8 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Ah, it's upstream. @bdarnell's suggestion SGTM. Comments from Reviewable |
Since the move to proposer-evaluated KV, we were potentially clobbering the
HardState on splits as we accidentally moved HardState synthesis upstream
of Raft as well. This change moves it downstream again.
Though not strictly necessary, writing lastIndex was moved as well. This is
cosmetic, though it aids @irfansharif's PR #16809, which moves lastIndex to
the Raft engine. After this PR, neither HardState nor last index keys are
added to the WriteBatch, so that pre-#16993
TruncateLog
is the onlyremaining command that does so (and it, too, won't keep doing that for
long).
Note that there is no migration concern.
Fixes #16749.