Skip to content

pebble-release-2.0: db: fix obsolete file metric underflows#4857

Merged
jbowens merged 1 commit intocockroachdb:pebble-release-2.0from
jbowens:2.0-underflow
Jun 9, 2025
Merged

pebble-release-2.0: db: fix obsolete file metric underflows#4857
jbowens merged 1 commit intocockroachdb:pebble-release-2.0from
jbowens:2.0-underflow

Conversation

@jbowens
Copy link
Copy Markdown
Contributor

@jbowens jbowens commented Jun 9, 2025

Previously a race existed in the calculation of obsolete file metrics resulting in underflow. The values within versionSet.metrics were reset and recalculated to reflect the set of files in versionSet.obsoleteTables whenever new files were added to obsoleteFiles. Additionally, the cleanup manager invoked a callback to decrease versionSet.metrics whenever a table was deleted.

The recalculation of versionSet.metrics could reset the metrics to less than the sum of outstanding pending deletes. When the cleanup manager eventually deleted the pending tables, these metrics would underflow.

This commit fixes the bug by maintaining separate stats for all files that have been enqueued for the cleanup manager and all files that have been successfully deleted. The volume of outstanding, pending deletions is the difference between the two.

For now, there's an additional wart that the set of files that are sitting in versionSet.obsoleteTables are still separately tracked.

Informs #4811.

Previously a race existed in the calculation of obsolete file metrics resulting
in underflow. The values within versionSet.metrics were reset and recalculated
to reflect the set of files in versionSet.obsoleteTables whenever new files
were added to obsoleteFiles. Additionally, the cleanup manager invoked a
callback to decrease versionSet.metrics whenever a table was deleted.

The recalculation of versionSet.metrics could reset the metrics to less than
the sum of outstanding pending deletes. When the cleanup manager eventually
deleted the pending tables, these metrics would underflow.

This commit fixes the bug by maintaining separate stats for all files that have
been enqueued for the cleanup manager and all files that have been successfully
deleted. The volume of outstanding, pending deletions is the difference between
the two.

For now, there's an additional wart that the set of files that are sitting in
versionSet.obsoleteTables are still separately tracked.

Informs cockroachdb#4811.
@jbowens jbowens requested a review from a team as a code owner June 9, 2025 15:41
@jbowens jbowens requested a review from RaduBerinde June 9, 2025 15:41
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@jbowens
Copy link
Copy Markdown
Contributor Author

jbowens commented Jun 9, 2025

TFTR!

@jbowens jbowens merged commit fe88d06 into cockroachdb:pebble-release-2.0 Jun 9, 2025
22 checks passed
@jbowens jbowens deleted the 2.0-underflow branch June 9, 2025 16:41
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