db: add regression test for RemoteTablesTotal underflow#5878
Merged
annrpom merged 1 commit intocockroachdb:masterfrom Apr 6, 2026
Merged
Conversation
Add a regression test verifying that RemoteTablesTotal() returns zero on a local-only DB with virtual sstables. Previously, RemoteTablesTotal() computed remote tables as (total - local) using inconsistent size accounting: totals used virtual table sizes while locals used physical backing sizes. When virtual sstables existed (e.g., from excise during Raft snapshot application), backing sizes could exceed virtual sizes, causing a uint64 underflow. CockroachDB then cast this to int64 for its gauge metric, producing large negative values for storage.sstable.remote.bytes. The underlying bug was fixed in 951fae6 (metrics: redesign disk usage metrics), which rewrote RemoteTablesTotal() to directly sum shared and external placement stats instead of subtracting local from total. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Member
Contributor
Author
RaduBerinde
approved these changes
Apr 6, 2026
Member
RaduBerinde
left a comment
There was a problem hiding this comment.
@RaduBerinde made 1 comment.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on xxmplus).
Contributor
Author
|
TFTR! ('-')7 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a regression test verifying that RemoteTablesTotal() returns zero on a local-only DB with virtual sstables.
Previously, RemoteTablesTotal() computed remote tables as (total - local) using inconsistent size accounting: totals used virtual table sizes while locals used physical backing sizes. When virtual sstables existed (e.g., from excise during Raft snapshot application), backing sizes could exceed virtual sizes, causing a uint64 underflow. CockroachDB then cast this to int64 for its gauge metric, producing large negative values for storage.sstable.remote.bytes.
The underlying bug was fixed in 951fae6 (metrics: redesign disk usage metrics), which rewrote RemoteTablesTotal() to directly sum shared and external placement stats instead of subtracting local from total.