Skip to content

[Design]: add a terminal spill fallback for extreme join-key skew #26436

Closed as not planned

Description

@XuPeng-SH

Context

Follow-up from #26408 and #26412. Re-spill now has bounded depth, queue, memory, disk, and FD admission, so it cannot recurse forever. Extreme key skew can still repeatedly rewrite nearly the full partition before ending in a controlled failure.

Problem

Hash repartitioning does not make progress when most or all rows share the same partition key. Retrying with more hash spill rounds amplifies I/O and latency without reducing the working set. A bounded error is safer than unbounded work, but it is not a complete execution strategy for valid skewed joins.

Proposed direction

  • Detect insufficient partition-size/cardinality progress between spill rounds.
  • Switch to a terminal bounded-memory algorithm, such as external sort/merge or another explicitly designed skew path.
  • Preserve SQL join semantics, duplicate multiplicity, NULL behavior, and right/full unmatched-row finalization.
  • Define stop versus round-complete signaling so all participants terminate consistently.

Acceptance criteria

  • Adversarial all-equal and heavy-hitter distributions complete correctly within declared memory, disk, FD, and work bounds, or fail before repeated full rewrites when no terminal strategy is admissible.
  • Results match a nested-loop oracle for inner, left, right/full, semi/anti, single, DedupJoin, and RightDedupJoin cases in scope.
  • Tests cover merger/non-merger ownership, cancellation, disk exhaustion, I/O failure, and multi-round transition into the terminal path.
  • Progress detection has deterministic thresholds and cannot oscillate between algorithms.
  • Metrics expose skew detection, fallback selection, rewritten bytes, and termination reason.
  • Benchmarks include ordinary and worst-case skew and guard against regression in uniform workloads.

Related: #26408, #26412, #25782.

Activity

  1. self-assigned this
    on Jul 30, 2026
  2. XuPeng-SH commented on Aug 1, 2026

    @XuPeng-SH
    ContributorAuthor

    Roadmap decision: #26563. Current hard depth/queue/memory/disk/FD bounds make extreme skew a controlled failure. First measure exact or consecutive no-progress rewrites with fixed-cardinality observability. Evaluate a terminal fallback only if this occurs in production and completion is a product requirement; do not implement sort-merge fallback for every join type in advance.

  3. XuPeng-SH commented on Aug 12, 2026

    @XuPeng-SH
    ContributorAuthor

    Closing as evidence-gated work that is not currently planned.

    The current engine already bounds spill depth, queued work, memory, disk, and FD admission, so extreme skew terminates with a controlled error rather than unbounded recursion. No current workload attached to this roadmap proves consecutive near-full partition rewrites or shows that a terminal sort/merge fallback is required.

    Create a new, narrower issue only when a current-main workload records partition bytes/cardinality across rounds and deterministically demonstrates insufficient progress. That issue must cover only the observed join types and preserve a controlled bounded failure when no terminal strategy is admissible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions