Skip to content

fix(compile): LOAD DATA with compressed file hangs due to empty dispatch source address - #25556

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-25554-main
Jul 9, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
ck89119:issue-25554-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

issue #25554

What this PR does / why we need it:

PR #25537 replaced isSameCN with sameExecutionNode in constructDispatchLocalAndRemote. The new function correctly treats empty-vs-non-empty addresses as different execution nodes, but compileExternScanParallelWrite still hardcoded an empty address for the source scope, causing:

  1. dispatch Prepare sees RemoteRegs + FuncId=SendToAnyLocalFunc → raises "SendToAnyLocalFunc should not send to remote"
  2. Runtime tries to connect to empty address via morpc → "dial tcp4: missing address" infinite retry
  3. Query hangs forever until workflow timeout

Fix: Pass the current CN address (c.addr) to constructScopeForExternal in compileExternScanParallelWrite, so sameExecutionNode correctly identifies source and target as the same local node.

Affected: All LOAD DATA with compressed files (flate/bz2/gzip/lz4) where mcpu > 1. Not specific to any compression type.

Verification

  • go vet ./pkg/sql/compile/ ✅
  • go test ./pkg/sql/compile/ ✅
  • Added TestSameExecutionNodeMatchesByAddressForLocalScope regression test ✅

🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.8 [email protected]

…tch source address (matrixorigin#25554)

compileExternScanParallelWrite hardcoded an empty address for the source
scope, but matrixorigin#25537 replaced isSameCN with sameExecutionNode which correctly
treats empty-vs-non-empty addresses as different execution nodes. This
caused constructDispatchLocalAndRemote to generate RemoteRegs with empty
NodeAddr, leading to infinite morpc retry to an empty address.

Fix: pass the current CN address (c.addr) to constructScopeForExternal
so sameExecutionNode correctly identifies the source and target as the
same local node.

Regression test added: TestSameExecutionNodeMatchesByAddressForLocalScope.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@ck89119
ck89119 requested review from aunjgr and ouyuanning as code owners July 9, 2026 09:10
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes. The one-line fix is in the right direction, but the PR does not yet have an effective regression guard for this production hang.

  1. High: the new regression test does not exercise the changed behavior and would pass before this fix.

pkg/sql/compile/max_dop_test.go:248 only checks sameExecutionNode with equal/non-equal addresses. That helper already behaves that way on main, so this test would not catch the actual regression from pkg/sql/compile/compile.go:1892 where compileExternScanParallelWrite constructed the source scope with an empty address.

The contract that failed is in constructDispatchLocalAndRemote: for compressed LOAD DATA with mcpu > 1, the source external scope and local merge scopes must be classified as the same execution node, producing SendToAnyLocalFunc with RemoteRegs == 0 and no empty NodeAddr. Please make the regression test assert that actual compile shape, for example by extending TestCompileExternScanParallelWrite to inspect rs[0].PreScopes[0].RootOp.(*dispatch.Dispatch) and require:

  • source scope NodeInfo.Addr == testCompile.addr
  • dispatchOp.FuncId == dispatch.SendToAnyLocalFunc
  • len(dispatchOp.RemoteRegs) == 0
  • len(dispatchOp.LocalRegs) == expected mcpu
  • no generated remote receive info with empty addr

That test should fail on the pre-fix line constructScopeForExternal("", false) and pass with constructScopeForExternal(c.addr, false). This is important because the unhappy path is a hang / infinite retry to an empty morpc address, so a helper-only test is too weak.

  1. Low: the PR currently fails whitespace hygiene.

git diff --check origin/main...pr/25556 reports:

pkg/sql/compile/max_dop_test.go:241: trailing whitespace.

Please run gofmt or remove the stray tab/blank whitespace around the new test.

… test (matrixorigin#25554)

The previous TestSameExecutionNodeMatchesByAddressForLocalScope only
tested the sameExecutionNode pure function which was unchanged by the
fix, so reverting the compile.go change would leave it green.

Replace it with TestCompileExternScanParallelWriteSourceScopeHasCorrectAddr
which directly asserts:
- source scope NodeInfo.Addr == current CN address (not empty)
- dispatch operator has SendToAnyLocalFunc with zero RemoteRegs

Verified: reverting the compile.go fix makes this test fail with
expected="cn1:6001" actual="".

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@XuPeng-SH
XuPeng-SH merged commit 23ce67c into matrixorigin:main Jul 9, 2026
20 checks passed
@ck89119
ck89119 deleted the issue-25554-main branch July 9, 2026 13:31

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants