Repository navigation
fix(compile): prevent distributed delete dispatch hang - #26533
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
LeftHandCold
left a comment
There was a problem hiding this comment.
Requesting changes on issue targeting; I did not find a code-side blocker in the topology or lifecycle changes.
The published evidence for #26526 does not currently establish that this code path was reached:
- The issue investigation says the target account never authenticated and all three CNs had zero Exec.Run during 03:10–14:54: #26526 (comment)
- The exact nightly restore script starts a mysql client after CREATE ACCOUNT, and its generated restore contains CREATE DATABASE, CREATE TABLE, and LOAD DATA statements, not a DELETE workload: https://github.com/matrixorigin/mo-nightly-regression/blob/6f85cb6d3cc7b35377522f4ba7f05d839c4e39d0/script/checkpoint_dump/verify_s3_checkpoint_dump_restore.sh#L827-L840
- This patch changes the large plan.Node_DELETE path in newDeleteMergeScope. If the published authentication and zero-execution evidence is correct, that path was unreachable in the reported incident.
The structural regression does demonstrate a real latent distributed-delete topology defect, but it does not yet connect that defect to #26526. Merging this as Fixes #26526 would close the reported Proxy/authentication incident without showing it is fixed. Please either link/create the correct issue for this distributed-delete defect and stop auto-closing #26526, or add concrete evidence from that run (affected SQL/statement or trace ID, query plan, and/or goroutine stack) proving the two distributed-delete steps ran, and reconcile it with the existing zero-Exec/authentication diagnosis.
For the code itself, I checked bucket/UUID/FromAddr preservation, per-CN ownership, full encoded-tree validation, pre-registration, cancellation/cleanup, bounded waits, and compile-time cost. Seventeen focused topology, encoding, registration, and unhappy-path tests pass at head 93bd29c.
|
Thanks — this was a valid evidence gap in the original issue discussion. I re-queried the real CI Loki data and correlated it with the archived raw goroutine snapshots. I kept
This also reconciles the two conflicting observations:
I also posted the sanitized correction on #26526. No code change was needed for this review because your code-side review found no blocker; the requested change was addressed by completing the incident evidence chain. Please re-review when convenient. |
LeftHandCold
left a comment
There was a problem hiding this comment.
Re-reviewed the code at head 93bd29c. I found no production-reachable blocker in the per-CN distributed-delete grouping, bucket and UUID routing preservation, encoded-tree standalone validation, dispatch pre-registration, cancellation/cleanup paths, or compile-time performance. Seventeen focused topology, encoding, registration, and unhappy-path tests passed with bounded local concurrency. My earlier issue-attribution concern is non-blocking for this code review and should not gate this patch.
Superseded by the code-focused re-review and approval at head 93bd29c; issue attribution is non-blocking for this patch.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26526
What this PR does / why we need it:
Root cause
newDeleteMergeScopecreated one receiver scope per delete bucket and attached only sourceibeneath receiveri. However, every sourceDispatch.LocalRegstargeted all same-CN delete receivers. Each receiver tree therefore owned only one of the local channels used by its source dispatch and was not independently executable on its planned CN.RemoteRunsilently converted such a remote tree to localMergeRunon the coordinator. The dispatch UUID was then registered and executed on the coordinator whileRemoteReceivRegInfo.FromAddrstill named the planned worker CN. Receivers notified a CN that would never publish that UUID and waited indefinitely inGetProcByUuid.The generated topology reproduces the incident exactly: two distributed-delete steps, three CNs with DOP 16, 64 misplaced remote source dispatches, 32 remote UUID routes per source, 2048 coordinator-side waits, and 1024 lookups on each remote CN.
Incident correlation (sanitized)
The request-changes review correctly noted that the original issue discussion did not publish enough evidence to connect the nightly hang to this path. Rechecking the real CI Loki data and archived raw goroutine snapshots closes that gap:
03:10:10.363181 UTC, the target restore connection completed authentication and received the OK packet. At03:10:10.567937, the planner logged the sanitized query shapeLOAD DATA URL (...) ... PARALLEL=true.03:10:10.590517–03:10:10.601298, statement019fb626-984b-7eda-bb4f-aac9e7d65773, tracec8489d33-8079-91e3-8f0b-56321c81ac0demitted 128remoterunClient.go:155fallback messages: 64 unique pipeline pointers, each checked twice, explicitly converted to local execution because its dispatch referenced another local pipeline tree.03:13:18coordinator snapshot, the authenticated frontend goroutine is insideexecuteStatusStmt -> Compile.Run -> runOnce. The same compile execution contains 2MergeDelete.Callstacks and 96Deletion.remoteDeletestacks; every remote-delete stack passes throughScope.RemoteRun -> Scope.MergeRun. All 64 fallback pipeline pointers from Loki match those raw remote-delete stacks. The remaining 32 are the coordinator-local sources:2 steps * 3 CNs * DOP 16 = 96, of which2 steps * 2 remote CNs * DOP 16 = 64were misplaced.03:13snapshots to the14:50snapshots: 2048 coordinatorsendNotifyMessageWithFactoryAndWaitwaits and 1024GetProcByUuidwaits on each of the two remote CNs. The same stacks remained blocked for about 700 minutes.status_stmt.gocallsrunner.Run(0)first and emitstime of Exec.Runonly after it returns; the archived frontend stack shows that call still blocked. The cited salt timeout belongs to a different connection, was already occurring before restore started, and does not appear on the target restore session.This directly ties the reported restore hang to the distributed
compileDelete -> newDeleteMergeScope -> RemoteRun -> MergeRunfallback. A literalDELETEstatement is not required: the physicalDeletionandMergeDeleteoperators are present in theLOAD DATAexecution stacks.Fix
RemoteRunenvelope per execution CN. Every envelope now owns all same-CNLocalRegsreferenced by its source dispatches while preserving all delete buckets, UUIDs, and remote routes.RemoteRunguide to document the fail-fast contract.The success path fixes the compiler topology. The runtime checks are a liveness backstop so a future invalid topology returns an error instead of changing placement and hanging.
Validation
Based on latest
origin/4.2-devat890270f4e6.count=50count=3pkg/sql/compiletest packagepkg/sql/compiletest package with race detectorgo build -mod=readonly ./pkg/sql/compilego vet -mod=readonly ./pkg/sql/compilegit diff --checkRegression coverage verifies per-CN standalone execution for multi-CN and single-remote-CN DOP, all
IBucket/Nbucketvalues, UUID-to-receiver route bijection, the observed 2048/1024/1024 topology, pre-registration ownership, nested operators, direct fail-fast cancellation, and boundedMergeRunsibling shutdown.