Skip to content

[core] Reject a merge fan-in below two up front - #10293

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-097-merge-fanin
Open

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:m/core-097-merge-fanin

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Purpose

local-sort.max-num-file-handles (the external-merge fan-in, default 128) has no lower-bound validation, so it can be set to 1. With fan-in = 1, AbstractBinaryExternalMerger.mergeChannelList divides by maxFanIn - 1 = 0 once a second spill file forms, producing Integer.MAX_VALUE merges and a negative subList argument, so the sort crashes with IllegalArgumentException. Because it only triggers on the second spill, a fan-in of 1 passes small-data testing and then crash-loops in production as data grows (the job restarts on the same config and fails again).

This adds a checkArgument(maxFanIn >= 2, ...) in the AbstractBinaryExternalMerger constructor naming local-sort.max-num-file-handles, converting the latent, data-volume-dependent crash into a deterministic, actionable configuration error at construction time. The merger constructor is the single chokepoint through which every fan-in call path passes. A fan-in of 1 is degenerate for a merge sort (it can never converge N runs), so this rejects no legitimate configuration.

This closes #10292.

Tests

  • BinaryExternalSortBufferTest#testFanInBelowTwoFailsFast pins that constructing with a fan-in below two fails fast. Without the guard, construction succeeds and the crash only surfaces later on the second spill.

API and Format

No.

Documentation

No.

A local-sort.max-num-file-handles of 1 has no validator; with at least
two spilled runs the merge arithmetic overflowed (numMerges =
ceil(n/0)) and the flush crashed with a confusing subList argument
error, restart-looping the job on the same configuration. Reject a
fan-in below 2 in the external merger constructor.

Assisted-by: GLM-5.3
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.

local-sort.max-num-file-handles below 2 causes a data-volume-dependent crash on spill

1 participant