[Bug]: Wide INSERT … SELECT requests a near-2 GiB JOIN output allocation despite a working batched path
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Customer impact
A single wide INSERT … SELECT over two broadcast LEFT JOINs can fail with MySQL error 3015. The same logical result can be committed in one transaction when the input is partitioned into smaller disjoint ranges. This is a non-blocking follow-up to #33242. The stable base d2bc81d9f0, the backport head 8353ba7fac, and upstream main 336486e108 all rejected the single statement. #33246 tracks the separate key-only HashBuild and probe-reset cases.
Reproduction on an isolated single CN
The observed configuration used DOP 1, a 7 GiB process cgroup, an 8 GiB frontend query configuration, the default single-allocation limit (2,147,483,631 bytes), and an effective allocation account of 3 GiB. The effective account matters when comparing results across hosts.
Run in a fresh database. The four long source values each have 262,150 bytes.
SET @@max_dop = 1;
SET SESSION optimizer_hints='forceOneCN=1,joinOrdering=1';
CREATE TABLE p (id INT, k INT, v MEDIUMTEXT);
CREATE TABLE b (id INT, k INT);
CREATE TABLE e (id INT);
CREATE TABLE sink (pid INT, bid INT, eid INT, v MEDIUMTEXT);
INSERT INTO p
SELECT result, CASE WHEN result <= 4 THEN result ELSE result + 10000 END,
CASE WHEN result <= 4 THEN CONCAT(
REPEAT(CHAR(64 + result), 52430), REPEAT(CHAR(64 + result), 52430),
REPEAT(CHAR(64 + result), 52430), REPEAT(CHAR(64 + result), 52430),
REPEAT(CHAR(64 + result), 52430))
ELSE NULL END
FROM generate_series(1,10000) g;
INSERT INTO b SELECT result, result % 4 + 1 FROM generate_series(1,8192) g;
INSERT INTO e VALUES (1),(8192),(NULL);
INSERT INTO sink
SELECT q.pid, q.bid, e.id, q.v
FROM (SELECT p.id AS pid, b.id AS bid, p.v AS v
FROM p LEFT JOIN b ON p.k = b.k LIMIT 30000) q
LEFT JOIN e ON q.bid = e.id;
SELECT COUNT(*) FROM sink;
The expected result has 18,188 rows. In the failing runs the client received 3015 and the target remained empty. On main and the backport head, a diagnostic replay recorded 1,745,941,624 bytes already charged and a 2,147,483,631-byte request for JOIN output against an account limit of 3,221,225,472 bytes. The allocator correctly rejected the request. The improvement to evaluate is whether the JOIN can emit a smaller batch before requesting that much additional capacity.
Controls and related storage observation
- With 6,200-byte source values, the single statement succeeded on both branches. The client checked all 8,192 matches, 9,996 outer rows, NULLs and text values.
- At full width, five statements in one explicit transaction succeeded on both branches. Each kept the same query and applied a disjoint
p.idpredicate inside the derived table before its LIMIT. The ranges were 1, 2, 3, 4 and 5–10000. A second connection observed zero rows before commit, then all 18,188 afterwards. The full result matched byte for byte. The LIMIT exceeds the total result in this fixture. - In a separate test with the single-allocation limit reduced to about 35 MiB, copying the 6,200-byte result from an ordinary source table using
INSERT INTO sink_copy SELECT * FROM sinkalso failed. Both branches reachedSinker.Writeduring commit. Main returned 1105 and the stable candidate returned 20101. Both targets remained empty. This lower-limit storage observation has a distinct failure site. Its incidence at the default production limit is unverified.
Acceptance
Keep the memory limits and transaction atomicity intact. Evaluate smaller output batches for the single-statement case and validate with the same effective account, full row and payload checks, and a narrow-row performance control. Track the storage observation separately within this investigation.
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 312
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 736
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matrixorigin/matrixone
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
matrixorigin/matrixone#33363 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
matrixorigin/matrixone#33362 ·
Maintainers usually reply within 1 day
-
SLEEP rejects NULL and negative durations that MySQL acceptsPossibly taken @XuPeng-SH claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
matrixorigin/matrixone#32653 ·
Maintainers usually reply within 1 day
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in matrixorigin/matrixone
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zalando/postgres-operator#3257 ·
Maintainers usually reply within 2 days
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentPossibly taken @cvas22 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
influxdata/telegraf#20264 ·
Maintainers usually reply within 1 day
-
[Bug] Standalone migration breaks existing Ingress routes using the envoy-http Service port nameOpenaccepted bug wg/enterprise-environment
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#7483 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
stacklok/toolhive-catalog#2076 ·
Maintainers usually reply within 1 day