Skip to content

Fix duplicate TsFile metric updates#18219

Open
jt2594838 wants to merge 3 commits into
apache:masterfrom
jt2594838:refactor_file_metric
Open

Fix duplicate TsFile metric updates#18219
jt2594838 wants to merge 3 commits into
apache:masterfrom
jt2594838:refactor_file_metric

Conversation

@jt2594838

Copy link
Copy Markdown
Contributor

Description

Make TsFile metric updates idempotent

  • Refactor file metric APIs to accept TsFileResource directly and derive database, region, sequence, size, and file name from the resource.
  • Track whether each TsFileResource has been recorded by metrics with an atomic flag, preventing duplicate additions or deletions during compaction and file lifecycle transitions.
  • Simplify compaction and DataRegion call sites by removing redundant metric arguments.

Tests

  • Extend CompactionUpdateFileCountTest to cover repeated metric updates and mixed sequence/unsequence resource deletion.
  • Update existing compaction metric tests for the resource-based API.

This PR has:

  • been self-reviewed.
  • added comments explaining the why and the intent of the code wherever it would not be obvious for an unfamiliar reader.
  • added or updated unit tests to cover new code paths.

Tested with:

mvn test -pl iotdb-core/datanode -Dtest=CompactionUpdateFileCountTest -DfailIfNoTests=false


Key changed/added classes
  • TsFileMetrics
  • TsFileResource
  • DataRegion compaction tasks and utilities
  • CompactionUpdateFileCountTest

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.

2 participants