Skip to content

kvserver: extract kvstorage.DestroyReplica#96650

Merged
craig[bot] merged 11 commits intocockroachdb:masterfrom
tbg:replica-destroy-untangle
Feb 8, 2023
Merged

kvserver: extract kvstorage.DestroyReplica#96650
craig[bot] merged 11 commits intocockroachdb:masterfrom
tbg:replica-destroy-untangle

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented Feb 6, 2023

This series of commits extracts (*Replica).preDestroyRaftMuLocked into a
free-standing method kvstorage.DestroyReplica.

In doing so, it separates the in-memory and on-disk steps that are a part
of replica removal, and makes the on-disk steps unit testable.

Touches #93241.

Epic: CRDB-220
Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@tbg tbg marked this pull request as ready for review February 6, 2023 16:37
@tbg tbg requested a review from a team February 6, 2023 16:37
@tbg tbg requested a review from a team as a code owner February 6, 2023 16:37
@tbg tbg requested a review from pav-kv February 6, 2023 16:37
Copy link
Copy Markdown
Collaborator

@pav-kv pav-kv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM + nits

@tbg tbg force-pushed the replica-destroy-untangle branch from 90cceb9 to fa7bd75 Compare February 8, 2023 15:02
tbg added 11 commits February 8, 2023 16:06
There are four callers to this method, and in all of them it is obvious
that the replica is marked as destroyed.

The invariant this code was checking is important, but also this code
primarily stages updates into a batch. It is not actually necessary to
have the replica marked as destroyed at this point yet, though in
practice we do do it. What you really need is to prevent further
modification of the data, but that still allows reads to be served until
we actually commit the batch.

Removing the dependency on `*Replica` will allow a series of simplifying
refactors, at the end of which the end of the life of a Replica should
be a little less nested, and a little more clear.  There'll be a better
place to assert this invariant as the work unfolds.

Epic: CRDB-220
Release note: None
Prep for more refactoring.

Epic: CRDB-220
Release note: None
It now checks in two ways that we're not regressing:

1. tombstone actually has to cover the replica's replicaID
2. tombstone itself must not regress.

I had verified that all call sites at least claim to not regress
and also conceptually I'm not aware of any that would want/need
to rely on being forwarded by the old code. But there are lots
of callers, so better to fail loudly in that case.

If you see this commit, the `kvserver` tests have passed.

Epic: CRDB-220
Release note: None
It now has to be there, so turn this into an assertion failure.
See cockroachdb#95513.

Epic: CRDB-220
Release note: None
Make this all about engine interactions. This removes the first
assertion added in the last commit (tests had passed with it)
and replaces it with a corresponding assertion on the persisted
ReplicaID.

Epic: CRDB-220
Release note: None
Epic: CRDB-220
Release note: None
Epic: CRDB-220
Release note: None
This is in preparation for moving the storage interactions of replica
removal, too.

Epic: CRDB-220
Release note: None
Epic: CRDB-220
Release note: None
It's now a first-class citizen of `kvstorage`, and we can
now write better unit tests for it.

Epic: CRDB-220
Release note: None
Epic: CRDB-220
Release note: None
@tbg tbg force-pushed the replica-destroy-untangle branch from fa7bd75 to 6b7de86 Compare February 8, 2023 15:15
Copy link
Copy Markdown
Member Author

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

@tbg
Copy link
Copy Markdown
Member Author

tbg commented Feb 8, 2023

bors r=pavelkalinnikov
TFTR!

@craig craig bot merged commit 844a370 into cockroachdb:master Feb 8, 2023
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 8, 2023

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants