Skip to content

db: add regression test for RemoteTablesTotal underflow#5878

Merged
annrpom merged 1 commit intocockroachdb:masterfrom
annrpom:annrpom/remote-tables-regression-test
Apr 6, 2026
Merged

db: add regression test for RemoteTablesTotal underflow#5878
annrpom merged 1 commit intocockroachdb:masterfrom
annrpom:annrpom/remote-tables-regression-test

Conversation

@annrpom
Copy link
Copy Markdown
Contributor

@annrpom annrpom commented Apr 2, 2026

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.

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>
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@annrpom
Copy link
Copy Markdown
Contributor Author

annrpom commented Apr 2, 2026

@annrpom annrpom marked this pull request as ready for review April 2, 2026 15:14
@annrpom annrpom requested a review from a team as a code owner April 2, 2026 15:14
@annrpom annrpom requested a review from xxmplus April 2, 2026 15:14
Copy link
Copy Markdown
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

@RaduBerinde made 1 comment.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on xxmplus).

@annrpom
Copy link
Copy Markdown
Contributor Author

annrpom commented Apr 6, 2026

TFTR! ('-')7

@annrpom annrpom merged commit 942775a into cockroachdb:master Apr 6, 2026
9 checks passed
@annrpom annrpom deleted the annrpom/remote-tables-regression-test branch April 6, 2026 21:27
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