Repository navigation
Description
Description
The dedupjoin finalize merger silently converts context cancellation into a successful end-of-stream when one parallel worker result is missing.
When receiveWorkerMsg returns nil because proc.Ctx is canceled, container.finalize returns nil. DedupJoin.Call then advances to End and returns ExecStop with no error.
This can make a canceled/failed parallel pipeline look successful. Because finalize is responsible for emitting unmatched build rows, the same path can also silently omit output.
Environment
- MatrixOne
main:f6dab28046d70412cec132f0068840896852101c - macOS arm64
- Go 1.26.x
Reproduction
Add the following diagnostic test to pkg/sql/colexec/dedupjoin/join_test.go:
func TestDedupFinalizeMissingWorkerHonorsCancellation(t *testing.T) {
proc := testutil.NewProcessWithMPool(t, "", mpool.MustNewZero())
arg := &DedupJoin{
NumCPU: 2,
IsMerger: true,
Channel: make(chan *WorkerJoinMsg),
OnDuplicateAction: plan.Node_FAIL,
}
arg.ctr.state = Finalize
arg.ctr.matched = &bitmap.Bitmap{}
arg.ctr.matched.InitWithSize(1)
ctx, cancel := context.WithCancel(proc.Ctx)
proc.Ctx = ctx
cancel()
defer func() {
arg.Free(proc, true, context.Canceled)
proc.Free()
}()
res, err := arg.Call(proc)
if !errors.Is(err, context.Canceled) {
t.Fatalf("cancellation was swallowed: status=%v err=%v", res.Status, err)
}
}Run:
go test ./pkg/sql/colexec/dedupjoin \
-run '^TestDedupFinalizeMissingWorkerHonorsCancellation$' \
-count=1 -v
The failure reproduced twice with -count=1.
Actual Result
missing worker cancellation was swallowed: status=0 err=<nil>
Call returns ExecStop and no error.
Expected Result
Call should return context.Canceled (or the original terminal worker/pipeline error). It must not report successful end-of-stream when finalize could not collect all worker results.
White-box Analysis
pkg/sql/colexec/dedupjoin/join.go:
for cnt := 1; cnt < int(ap.NumCPU); cnt++ {
msg := receiveWorkerMsg(proc.Ctx, ap.Channel)
if msg == nil {
return nil
}
// merge worker state
}receiveWorkerMsg returns nil for both a closed channel and context cancellation. The caller does not inspect context.Cause(proc.Ctx) and therefore treats cancellation as successful finalize completion.
After finalize returns nil, Call sees no buffered output, transitions to End, and returns ExecStop with no error.
Impact
- A canceled or failed parallel dedup pipeline can be reported as successful.
- Unmatched build rows that should be emitted during finalize can be silently omitted.
- The original terminal cause is lost, preventing correct retry and incident classification.
- A missing worker and a genuinely empty/closed worker channel are indistinguishable at the caller.
Additional Information
This issue was found during colexec unhappy-path testing. It does not involve security-sensitive behavior.
Activity
fix(dedupjoin): preserve parallel finalize failures (#26393)
Ariznawlll commentedon Aug 5, 2026
测试版本
mainace13bf4b43773dd962f03325b22f58ed31fee91原问题验证
执行
go test -count=3 ./pkg/sql/colexec/dedupjoin与go test -race ./pkg/sql/colexec/dedupjoin。TestDedupFinalizeMissingWorkerHonorsCancellation构造缺失 worker result,验证 finalize 返回请求取消而不吞掉 context cancellation。Happy Path 覆盖
TestDedupJoin、TestDedupJoinCapture、TestDedupJoinCapturePartialMatch:普通与 capture join 结果正确。TestDedupShuffleWorkersFinalizeTheirOwnPartitions、TestDedupFinalizeParallelMergePreservesDataAcrossReset:正常多 worker/bucket finalize 保持数据。Unhappy Path 覆盖
TestDedupFinalizeConcurrentCancellationReturns。TestDedupFinalizeWorkerFailureCleansTransferredMessages、TestDedupFinalizeWorkerFailureDoesNotWaitForMissingWorker、TestDedupFinalizeNormalAbortDoesNotHideCancellation。TestReceiveWorkerMsg_ContextCancel、TestReceiveWorkerMsg_ChannelClose、TestReceiveWorkerMsg_RejectsMissingMailboxAndNilStatus。白盒验证
针对 join_test.go 完成 3 轮 UT 与
-race,覆盖 mailbox ownership、取消和 transferred-message cleanup。回归测试
缺 worker result 的注入只能稳定在 operator/mailbox 级完成,保留为 Go UT;不新增 motr。
测试证据
执行命令:
go test -count=3 ./pkg/sql/colexec/dedupjoin、go test -race ./pkg/sql/colexec/dedupjoin,均以 exit code 0 完成。测试结论
测试通过。
fix(dedupjoin): preserve parallel finalize failures (matrixorigin#26393)
fix(dedupjoin): preserve parallel finalize failures (matrixorigin#26393)
fix(dedupjoin): preserve parallel finalize failures (matrixorigin#26393)