-
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
storage: write a tombstone with math.MaxInt32 when processing a merge #40814
storage: write a tombstone with math.MaxInt32 when processing a merge #40814
Conversation
@benesch any interest in chiming in on this one? Am I missing anything? It seems like if we're at this critical phase of a merge we know the RHS has its terminal replica ID. |
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.
but let's wait for @benesch to chime in.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)
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.
It's been a while (holy cow, 9 months!) since I've really thought about range merges, so I'm not 1000% sure that this is correct. But it certainly seems legit, and it's not like there was a particular reason that the code looked like this. Rather the GC queue using MaxInt was quick fix when I realized I didn't have NextReplicaID available there, and I didn't think to propagate that change back to the normal subsumption code path.
Reviewed 2 of 2 files at r1.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @ajwerner)
pkg/storage/replica_application_state_machine.go, line 571 at r1 (raw file):
const mustClearRange = false if err := rhsRepl.preDestroyRaftMuLocked( ctx, b.batch, b.batch, math.MaxInt32, rangeIDLocalOnly, mustClearRange,
Not that it really matters much to me, but it seems like it might be worth leaving a comment here along these lines:
// Use math.MaxInt32 as the nextReplicaID as an extra safeguard against creating
// new replicas of the RHS. This isn't required for correctness, since the merge
// protocol should guarantee that no new replicas of the RHS can ever be
// created, but it doesn't hurt to be careful.
The comment in the GC queue (
cockroach/pkg/storage/replica_gc_queue.go
Lines 331 to 337 in ad4d6f5
// We don't have the last NextReplicaID for the subsumed range, nor can we | |
// obtain it, but that's OK: we can just be conservative and use the maximum | |
// possible replica ID. store.RemoveReplica will write a tombstone using | |
// this maximum possible replica ID, which would normally be problematic, as | |
// it would prevent this store from ever having a new replica of the removed | |
// range. In this case, however, it's copacetic, as subsumed ranges _can't_ | |
// have new replicas. |
Before this PR we would write such a tombstone when detecting that a range had been merged via a snapshot or via the replica gc queue but curiously not when merging the range by applying a merge. Release Justification: Came across this oddity while working on updating tests for cockroachdb#40751. Release note: None
bee452a
to
264c71d
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.
TFTR!
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @benesch)
pkg/storage/replica_application_state_machine.go, line 571 at r1 (raw file):
Previously, benesch (Nikhil Benesch) wrote…
Not that it really matters much to me, but it seems like it might be worth leaving a comment here along these lines:
// Use math.MaxInt32 as the nextReplicaID as an extra safeguard against creating // new replicas of the RHS. This isn't required for correctness, since the merge // protocol should guarantee that no new replicas of the RHS can ever be // created, but it doesn't hurt to be careful.
The comment in the GC queue (
) should also probably be updated to read "a replica ID of max int is what we do on merges; see runPreApplyTriggers for details" rather than "oh shoot we don't have the NextReplicaID, lol, guess we can just stick maxint here."cockroach/pkg/storage/replica_gc_queue.go
Lines 331 to 337 in ad4d6f5
// We don't have the last NextReplicaID for the subsumed range, nor can we // obtain it, but that's OK: we can just be conservative and use the maximum // possible replica ID. store.RemoveReplica will write a tombstone using // this maximum possible replica ID, which would normally be problematic, as // it would prevent this store from ever having a new replica of the removed // range. In this case, however, it's copacetic, as subsumed ranges _can't_ // have new replicas.
Done.
Build failed |
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.
zerosum-splits flake.
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @benesch)
40814: storage: write a tombstone with math.MaxInt32 when processing a merge r=ajwerner a=ajwerner Before this PR we would write such a tombstone when detecting that a range had been merged via a snapshot or via the replica gc queue but curiously not when merging the range by applying a merge. Release Justification: Came across this oddity while working on updating tests for #40751. Maybe is not justified. Release note: None Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
Build succeeded |
Before this PR we would write such a tombstone when detecting that a range had
been merged via a snapshot or via the replica gc queue but curiously not when
merging the range by applying a merge.
Release Justification: Came across this oddity while working on updating tests
for #40751. Maybe is not justified.
Release note: None