Skip to content

Fix infinite loop from non-positive TABLE_METADATA_CLEANUP_BATCH_SIZE#4970

Merged
dimas-b merged 3 commits into
apache:mainfrom
vigneshio:fix/table-metadata-cleanup-batch-size-bounds
Jul 8, 2026
Merged

Fix infinite loop from non-positive TABLE_METADATA_CLEANUP_BATCH_SIZE#4970
dimas-b merged 3 commits into
apache:mainfrom
vigneshio:fix/table-metadata-cleanup-batch-size-bounds

Conversation

@vigneshio

Copy link
Copy Markdown
Contributor

Fix infinite loop from non-positive TABLE_METADATA_CLEANUP_BATCH_SIZE

TABLE_METADATA_CLEANUP_BATCH_SIZE is realm-overridable without bounds. When a realm/catalog override sets the value to 0 or negative, TableCleanupTaskHandler.getMetadataFileBatches(...) behaves badly: 0 causes an infinite loop in the batch-splitting logic, and negative values cause IllegalArgumentException from List.subList(...).

This change clamps the configured batch size to at least 1 at the use site with Math.max(1, batchSize), preventing the availability issue without changing the existing configuration machinery. A regression test with a short @Timeout verifies that a 0 override still results in queued cleanup subtasks instead of hanging.

Checklist

  • Don't disclose security issues! (contact security@apache.org)
  • Clearly explained why the changes are needed, or linked related issues
  • Added/updated tests with good coverage, or manually tested (and explained how)
  • Added comments for complex logic
  • Updated `CHANGELOG.md` (if needed)
  • Updated documentation in `site/content/in-dev/unreleased` (if needed)

vigneshio added 2 commits July 5, 2026 02:54
Clamp TABLE_METADATA_CLEANUP_BATCH_SIZE to at least 1 in TableCleanupTaskHandler

to prevent an infinite loop (batchSize = 0) or IllegalArgumentException

(batchSize < 0) when the realm config overrides the default. Add a

regression test that verifies cleanup still queues subtasks with batchSize = 0.
dimas-b
dimas-b previously approved these changes Jul 6, 2026

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch! Thanks, @vigneshio !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jul 6, 2026
nandorKollar
nandorKollar previously approved these changes Jul 7, 2026
@vigneshio
vigneshio dismissed stale reviews from nandorKollar and dimas-b via 9fefc94 July 8, 2026 11:51
@dimas-b
dimas-b merged commit 8254e8a into apache:main Jul 8, 2026
27 of 42 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jul 8, 2026
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.

4 participants