Skip to content

[server] Fix tableCount metric after dropping partitioned tables#3482

Open
swuferhong wants to merge 2 commits into
apache:mainfrom
swuferhong:fix-table-count-metrics
Open

[server] Fix tableCount metric after dropping partitioned tables#3482
swuferhong wants to merge 2 commits into
apache:mainfrom
swuferhong:fix-table-count-metrics

Conversation

@swuferhong

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3481

processDropTable's onDeleteTable() is a no-op for partitioned tables
(their buckets live under partitionAssignments, not tableAssignments)
and they have no table-level replicas, so areAllReplicasInState is
vacuously true the moment the table enters tablesToBeDeleted. Without
an explicit trigger, resumeDeletions() runs only when some unrelated
stop-replica response piggy-backs it -- which can be never if no other
drop is in flight. The dropped table then lingers in tablesToBeDeleted
and tablePathById, inflating the tableCount gauge until something
else gets dropped.

Brief change log

Tests

API and Format

Documentation

@swuferhong swuferhong force-pushed the fix-table-count-metrics branch from aa09e46 to 9214516 Compare June 12, 2026 11:39
Comment on lines +131 to +134
for (Long tableId : context.allTables().keySet()) {
if (!tablesToBeDeleted.contains(tableId)) {
tableCount++;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should reverse the lookup by iterating over tablesToBeDeleted and checking for existence in context.allTables(). If a match is found, decrement tableSize. This approach significantly improves performance.

Set<Long> allTables = context.allTables().keySet();
int tableCount = allTables.size();
for (Long toDelete : context.getTablesToBeDeleted()) {
    if (allTables.contains(toDelete)) {
        tableCount--;
    }
}

@wuchong wuchong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I pushed a commit to fix this comment. Please take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[server] tableCount metric stays inflated after dropping partitioned tables

2 participants