Skip to content

Conversation

@zhyass
Copy link
Member

@zhyass zhyass commented Oct 18, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

When checking the compaction block limit, we now verify the number of imperfect blocks among the selected blocks.
Once reached for imperfect blocks, triggers one final segment acquisition before stopping. This “+1” segment behaviour ensures boundary blocks are not missed and avoids off-by-one omissions.

Refactors the is_limit_reached method to return an explicit state enum (CompactLimitState) with values: Continue, ReachedBlockLimit, ReachedSegmentLimit. This clarifies the intent of each stop condition and aligns the control flow with the outer loop logic.

Improves readability of the compaction loop by handling the “take one more” state outside the immediate stop condition, thus making the workflow more predictable and maintainable.

This change ensures that auto-compaction covers all eligible segments/blocks without accidentally skipping near-limit items, and also tightly bounds resource usage by segments.

Fixes: #18859

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Oct 18, 2025
@zhyass zhyass requested a review from dantengsky October 18, 2025 04:19
@zhyass zhyass changed the title fix: auto compaction as expect chore: auto compaction as expect Oct 19, 2025
@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Oct 19, 2025
@zhyass zhyass added ci-cloud Build docker image for cloud test and removed pr-bugfix this PR patches a bug in codebase labels Oct 19, 2025
@github-actions
Copy link
Contributor

Docker Image for PR

  • tag: pr-18860-5d62881-1760879530

note: this image tag is only available for internal use.

@zhyass zhyass added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Oct 20, 2025
@github-actions
Copy link
Contributor

Docker Image for PR

  • tag: pr-18860-fdab881-1760964116

note: this image tag is only available for internal use.

@zhyass zhyass changed the title chore: auto compaction as expect chore: ensuring all imperfect blocks are compacted Oct 22, 2025
@zhyass zhyass added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Oct 23, 2025
@github-actions
Copy link
Contributor

Docker Image for PR

  • tag: pr-18860-70ab357-1761217919

note: this image tag is only available for internal use.

@BohuTANG BohuTANG merged commit 38a927a into databendlabs:main Oct 24, 2025
186 of 188 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cloud Build docker image for cloud test pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: auto compaction did not compact all blocks that were expected

3 participants