-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
59423: kvserver: use combined store/repl critical section in applySnapshot r=nvanbenschoten,irfansharif a=tbg This PR addresses #58378, which highlighted insufficient locking in `(*Replica).applySnapshot`. Prior to this PR, `applySnapshot` carried out operations in roughly this order: 1. ingest SSTs into the LSM 2. update the replica's descriptor and the store's map of span to replica 3. update the replica state There was no critical section wrapping both of 2) and 3). As a result, it was possible (in theory, not observed) to obtain a replica from the store under descriptor `X` whose state had not entirely been updated to reflect `X`. It's hard to say where exactly you would see issues with this, but there was one instance that caused a crash: when a replica was created in response to an incoming snapshot, its state was completely empty; such a replica is not initialized; they are never handed out by the store; they don't have anything in their state. Due to the race described above, the store would sometimes hand out these replicas when their descriptor had just been initialized, but its state not populated yet, which caused at least two crashes related to calls to `(*Replica).Version`: 1. from `PurgeOutdatedReplicas`, and 2. during evaluation of a lease request, triggering [this assertion] [this assertion]: ef64519 Both previously had workarounds in place to avoid the crash, which are now removed. Release note: None Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: Tobias Schottdorf <[email protected]>
- Loading branch information
Showing
15 changed files
with
174 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.