feat: warn when hash/range ingest publishes oversized segments - #20173
Open
davidalexander3986 wants to merge 1 commit into
Open
feat: warn when hash/range ingest publishes oversized segments#20173davidalexander3986 wants to merge 1 commit into
davidalexander3986 wants to merge 1 commit into
Conversation
davidalexander3986
marked this pull request as ready for review
August 27, 2026 03:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19573.
Description
Hash and range native batch ingest can publish segments much larger than
maxRowsPerSegment/targetRowsPerSegmentwhen a partition key is hot. Operators had no signal for that besides noticing huge segments later.This PR counts published segments whose row count exceeds
maxRowsPerSegment × 2, then warns, emits a metric, and records the count on the completion report.Detect oversized segments at supervisor publish
After a successful publish,
ParallelIndexSupervisorTaskruns the check only for HASH or RANGE whengetMaxRowsPerSegment()is non-null (so hashed +numShardswith no max is skipped). Ratio is2.0. For range, resolved max is alreadytarget + target/2, so the warn is effectively 3× the user’stargetRowsPerSegment.If the count is > 0:
ingest/segments/oversizedLive reports omit the field. Completion reports include
oversizedSegments(Long, omitted when null). SequentialIndexTask(maxNumConcurrentSubTasks: 1) does not run this check.Tests
IndexTaskUtils.getOversizedSegmentsunit cases (threshold, nulltotalRows, mixed)oversizedSegments = 1; even range expects0; hashed +numShardsomits the fieldoversizedSegmentsmetrics.md, logging emitter allow-list, Prometheus, and StatsD catalogsImplementation decision
In the cited issue it was recomended to set this logic in the PartialHashSegmentGenerateTask hooks and to use Appenderator.getRowCount(SegmentIdWithShardSpec) to get the row count. I ended up not doing this because I realized in the partial tasks we don't yet have the final segments. The final segments are only available after the final merge, right after publishing to S3. So, I instead went with wiring this through in the PartialSegmentMergetask instead.
Side effect
Those jobs merge and push DataSegments without going through an appenderator, so totalRows was never set. The supervisor still emits ingest/rows/published via IndexTaskUtils.getTotalRowCount(), which skips nulls, so the metric was always 0. After this change the metric should emit correctly for range and hash index_parallel jobs.
Release note
You can now have visibility into when your range and hash partitioning settings are resulting in creating overly large segment files (hot partitions) in a time chunk. Native batch hash and range ingest now warns and emits a count of segments
ingest/segments/oversizedfor all published segments with more than 2×maxRowsPerSegmentrows (for range, that is 3×targetRowsPerSegment). The count is also on the task completion report asoversizedSegments.Key changed/added classes in this PR
IndexTaskUtilsParallelIndexSupervisorTaskPartialSegmentMergeTaskIngestionStatsAndErrorsAbstractBatchIndexTaskThis PR has:
Verification
Ran the cluster locally, and submitted an ingestion spec with hashed partitioning for wikipedia, using channel as a partition key:
since channel is often wikipedia#en for many rows, this will cause a hot partition for the same time chunk. Confirmed in report that oversizedSegments is set:


and the warn log: