Repository navigation
Description
Description
An eligible shuffle HashBuild remains resident, or at least reports no physical
spill, after join_spill_mem is set to 8,000,000 bytes. EXPLAIN ANALYZE
selects shuffle: range(...), the Join reports 105-139 MiB of memory, and the
queries return correct results, but none of the three targeted plans contains
SpillRows or SpillSize.
This is different from #26556: the planner does select the eligible range
shuffle for both equality-predicate orders. It is also different from #26586:
the query does not fail during spill recovery and returns no budget error.
Environment
- Branch:
main - MatrixOne commit:
b992c9ef36514e3d1c14760a5311eace122cce94 - Test harness commit:
3933e729e415ec1e679301b3d8566abdd3146248 - Date: 2026-08-10
- Deployment: isolated TKE cluster, 1 DN, 3 LogService, 3 CN and 2 Proxy
- CN: 14 CPU / 55 GiB per replica
- Session settings:
max_dop=8,join_spill_mem=8000000
Steps to reproduce
Using a source table containing at least 2,000,000 sequential integer rows:
CREATE TABLE spill_probe_2m AS
SELECT id AS k1, MOD(id, 97) AS k2, id AS payload
FROM source_100m WHERE id <= 2000000;
CREATE TABLE spill_build_2m AS
SELECT id AS k1, MOD(id, 97) AS k2, id AS payload
FROM source_100m WHERE id <= 2000000;
SET @@max_dop = 8;
SET @@join_spill_mem = 8000000;
EXPLAIN ANALYZE
SELECT COUNT(*), SUM(p.payload), SUM(b.payload)
FROM spill_probe_2m p
JOIN spill_build_2m b
ON p.k1 = b.k1 AND p.k2 = b.k2;
EXPLAIN ANALYZE
SELECT COUNT(*), SUM(p.payload), SUM(b.payload)
FROM spill_probe_2m p
JOIN spill_build_2m b
ON p.k2 = b.k2 AND p.k1 = b.k1;A third variant used a 2,000,000-row build side with a 128-byte padding column:
CREATE TABLE spill_wide_build_2m AS
SELECT id AS k, CONCAT(CAST(id AS CHAR), REPEAT('x', 128)) AS pad
FROM source_100m WHERE id <= 2000000;
EXPLAIN ANALYZE
SELECT COUNT(*), SUM(p.payload), SUM(LENGTH(b.pad))
FROM spill_probe_wide_2m p
JOIN spill_wide_build_2m b ON p.k = b.k;Actual behavior
Both multi-key predicate orders choose the expected range shuffle, but neither
plan reports spill:
Join MemorySize=138.45 MiB (min=16.00 MiB, max=16.00 MiB)
Join Cond: (b.k1 = p.k1), (b.k2 = p.k2) shuffle: range(b.k1)
no SpillRows / SpillSize
Join MemorySize=138.71 MiB (min=16.00 MiB, max=16.00 MiB)
Join Cond: (b.k2 = p.k2), (b.k1 = p.k1) shuffle: range(b.k1)
no SpillRows / SpillSize
The wide-build variant behaves the same way:
Join MemorySize=105.13 MiB (min=8.00 MiB, max=38.24 MiB)
Join Cond: (b.k = p.k) shuffle: range(b.k)
no SpillRows / SpillSize
All queries still return the exact expected results. For the multi-key cases:
joined_rows=2000000
probe_sum=2000001000000
build_sum=2000001000000
The post-query health control SELECT 1 succeeds. No panic, OOM or CN restart
was observed.
Expected behavior
For a shuffle HashBuild whose retained/build memory crosses the configured
8,000,000-byte threshold, MatrixOne should enter the supported spill path and
EXPLAIN ANALYZE should expose positive SpillRows/SpillSize measurements.
If the displayed Join memory is not the memory governed by
join_spill_mem, the plan or diagnostics should expose the resolved threshold,
unit and spill-eligibility decision so that the setting has an observable and
testable contract.
Stability and controls
- Independent workflow reproduction: 1/1.
- Within that run: 3/3 targeted shuffle plans had no positive spill metric
(two predicate orders and one wide-build shape). - Resident control with
join_spill_mem=0: passed with the same exact result. - Low-memory query results: passed and matched the resident result.
- Health/cleanup:
SELECT 1passed; cluster remained healthy and the isolated
namespace was removed successfully.
Evidence
- Workflow run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31365986312
- Failing job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31365986312/job/93387289595
- Regression source: https://github.com/matrixorigin/mo-nightly-regression/pull/1329
The three failures are explicit plan assertions for
regex:SpillRows=[1-9][0-9]*; the accompanying shuffle: range assertions pass.
Code analysis
The failing evidence establishes that planner shuffle selection is present and
that SQL correctness is preserved. It does not yet distinguish between:
- the resolved
join_spill_memthreshold not reaching the executing
HashBuild workers; - the threshold being interpreted per worker or in a different unit than the
session-visible value; - physical spill occurring but its
SpillRows/SpillSizecounters not being
propagated toEXPLAIN ANALYZE.
These are hypotheses requiring engine-side tracing; this report does not infer
one of them as the confirmed root cause.
Regression coverage
PR matrixorigin/mo-nightly-regression#1329 contains the big-data regression.
After the product/observability contract is confirmed, retain both predicate
orders, the wide build side, resident-vs-spill result equality, positive spill
evidence and the post-recovery health check.
Related
- matrixorigin/mo-nightly-regression#1329
- [Bug]: multi-key join predicate order can bypass shuffle spill #26556: predicate-order-dependent shuffle eligibility; shuffle is present in
this reproduction. - [Bug]: shuffle HashBuild can strand TPCH Q9 spill recovery under a shared budget #26586: shared-budget spill recovery failure; no recovery error occurs here.
- [Design]: make join spill thresholds explicitly versioned and unit-safe #26434: spill-threshold unit and observability design.
Activity
aptend commentedon Aug 10, 2026
I reproduced this locally at the reported MatrixOne commit (
b992c9ef36514e3d1c14760a5311eace122cce94) with an embedded 3-CN cluster, 2,000,000 sequential rows,max_dop=8, and temporary per-operator instrumentation.Confirmed behavior
For the balanced multi-key shuffle join, all 8 HashBuild workers received the configured value unchanged:
Therefore, no physical spill occurred and the missing
SpillRows/SpillSizevalues are not a propagation problem.join_spill_mem=8000000is interpreted as bytes (>100000selects byte mode) and is applied independently by each eligible shuffle HashBuild worker. The early decision checks retained build batches plus the current input batch. With DOP 8, each worker retains only about 6 MB, so it does not cross the 8 MB threshold.The roughly 16 MiB HashMap is allocated afterward. In this two-
BIGINT-key case MatrixOne usesStringHashMap: 250k distinct keys require 524,288 slots at the 50% load limit, and each slot is 32 bytes, giving 16,777,216 bytes plus small descriptors. A successful HashMap build is not followed by anotherjoin_spill_memcheck. The separate HashBuild hard allocation budget does account for both retained batches and the HashMap (roughly 22.78 MiB per worker here); it was large enough, so its admission-failure spill fallback was not activated.Why EXPLAIN reports 128-138 MiB
Join MemorySizeis not the memory value tested byjoin_spill_mem. It sumsMemorySizefrom all physical operators mapped to the logical Join node, and those operators do not all use the field with identical semantics.The local
Join MemorySize=128.74 MiBdecomposed exactly as:This aggregation mechanism also explains the reported 138.45 MiB: approximately 128 MiB is the eight JoinMap/HashMap observations, while the remainder comes from other physical operator statistics mapped to the Join node. The current EXPLAIN line does not retain enough per-operator detail to reconstruct that remainder exactly. Its
min/max=16 MiBalso describes physical operator statistics, not the per-worker pre-map spill-decision value.The wide-table variant is not evidence that 128-byte
padwas retained by HashBuild. In the local reproduction the optimizer built the narrowp(k,payload)side: each worker retained about 4 MB, then allocated an approximately 8 MiBIntHashMap, and again did not cross the pre-map 8 MB threshold.Controls
Skewing the range distribution so that only 3 workers received large partitions also produced 3 spill starts, confirming that the decision is per active worker/partition.
Conclusion
The setting reaches the executing workers and works according to the current implementation. The reported plans genuinely do not spill because their per-worker retained batch memory is below 8 MB before HashMap construction. Comparing the aggregated EXPLAIN
Join MemorySizewithjoin_spill_memis therefore not a valid spill oracle.There is still a real contract/observability gap: the setting looks like a final HashBuild resident-memory limit, but currently acts as a pre-HashMap retained-batch threshold; HashMap construction can raise resident memory above it without a post-build recheck. EXPLAIN also does not expose the resolved threshold, unit/mode, actual build side, per-worker decision value, or spill decision. If
join_spill_memis intended to cap final resident HashBuild memory, the implementation needs a post-map admission/recheck policy; otherwise the regression assertions and user-facing diagnostics should be adjusted to the narrower current contract.XuPeng-SH commentedon Oct 22, 2026
This report is now tracked together with #30125. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.