Skip to content

Adds row-based compaction eligibility filtering and a dry run API for overlord compaction#19179

Open
cecemei wants to merge 17 commits intoapache:masterfrom
cecemei:metric
Open

Adds row-based compaction eligibility filtering and a dry run API for overlord compaction#19179
cecemei wants to merge 17 commits intoapache:masterfrom
cecemei:metric

Conversation

@cecemei
Copy link
Contributor

@cecemei cecemei commented Mar 19, 2026

Description

This PR makes two main enhancements to Druid's compaction system:

  1. Adds row-based compaction eligibility filtering - Extends MostFragmentedIntervalFirstPolicy with row count analysis to complement the existing byte-based filtering
  2. Adds dry run API for overlord compaction - Provides detailed visibility into what compaction jobs would be submitted without actually running them

Added row count tracking to CompactionStatistics

  • Added totalRows field (nullable Long) to CompactionStatistics to track row counts alongside bytes
  • Row count can be null for old segments where this information was not stored
  • Updated arithmetic operations (increment/decrement) to handle null propagation correctly
  • This enables row-based analysis for compaction decisions

Added row-based eligibility check to MostFragmentedIntervalFirstPolicy

  • Added minUncompactedRowsPercentForFullCompaction parameter similar to the existing minUncompactedBytesPercentForFullCompaction
  • Allows compaction policies to filter candidates based on uncompacted row ratio in addition to byte ratio
  • Provides more flexibility in determining which intervals need full compaction
  • Useful for cases where row count is a better indicator of compaction need than byte size

Created CompactionStatusDetailedStats for dry run mode

  • New class to collect detailed compaction statistics during dry run mode in Overlord
  • Organizes candidates by compaction status (COMPLETE, RUNNING, PENDING, SKIPPED) into table format
  • Includes comprehensive metrics: segment counts, bytes, rows, and uncompacted statistics
  • JSON serializable for API responses

Added dryRun API endpoint

  • Added dryRunWithConfig() method to CompactionScheduler interface
  • Added /dryRun POST endpoint to OverlordCompactionResource that accepts a ClusterCompactionConfig
  • Returns CompactionStatusDetailedStats showing what would be compacted without actually submitting jobs
  • Deprecated simulateRunWithConfigUpdate() in favor of the new dry run API
  • Helps operators preview compaction behavior and validate configuration changes before applying them

Updated CompactionStatusTracker for dry run support

  • Added optional CompactionStatusDetailedStats field to track detailed statistics during dry run
  • Added recordPendingTask() method to record tasks that could be allocated without submission
  • Updated javadocs to clarify dry run behavior

Release note

Added row-based compaction eligibility filtering to MostFragmentedIntervalFirstPolicy via the minUncompactedRowsPercentForFullCompaction configuration parameter. This complements the existing byte-based filtering and provides more flexibility in determining which intervals need full compaction.

Added a dry run API (/druid/indexer/v1/compaction/dryRun) to the Overlord that shows what compaction jobs would be submitted for a given cluster compaction configuration without actually submitting them. This helps operators preview compaction behavior and validate configuration changes. The API returns detailed statistics including segment counts, bytes, and rows for candidates in different compaction states (pending, skipped, complete, running).


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@cecemei cecemei changed the title collect compaction status for overlord compaction in dry run mode Adds row-based compaction eligibility filtering and a dry run API for overlord compaction Mar 19, 2026
@cecemei cecemei marked this pull request as ready for review March 20, 2026 07:30
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.

1 participant