-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: double check file reference counts when loading file
Double check the file reference counts before attempting to find/create a table cache node for a file. Once a file's reference count falls to zero, the file becomes obsolete and may be deleted at any moment. Today if we have a race, break this invariant and attempt to load a file with a nonpositive reference count, it's relatively unlikely that it manifests as an error. Typically tables remain open in the table cache, allowing the table cache to serve the request even if the file is no longer linked into the data directory. Additionally, even if it's not in the table cache presently, deletion of obsolete files may be delayed due to deletion pacing, hiding the race. This commit preemptively asserts on the file reference counts. I opted for not restricting this invariant check to invariants builds because it's cheap relative to a table cache lookup, and it's a particularly tricky form of corruption to debug otherwise. Informs cockroachdb/cockroach#110645.
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
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