Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
The closed #21469 involved the same test but a different failure mode: its fix #21476 increased replay wait deadlines and added a timeout around ReplayWaitC. It did not address cancellation-cause propagation. The open #32912 concerns cancellation during skip-command Append retry backoff, which is also a different path.
Branch Name
main (observed in PR #32938 CI)
Commit ID
Tested PR head: 5def69e1136a472650f12d18150acd2d94e6d4cc
PR base: d2e71035dbae7471052ca5c0034d05827b926249
Other Environment Information
- Hardware parameters: GitHub Actions Ubuntu/x86 runner
- OS type: Ubuntu/x86
- Others: UT job https://github.com/matrixorigin/matrixone/actions/runs/44505921401/job/135497484102
- UT command: make ut UT_CONFIGURED=1 UT_PARALLEL=8 UT_TIMEOUT=40 UT_SHARD=allActual Behavior
Test_Replayer9 failed after 0.78 seconds. The failing assertion is at pkg/vm/engine/tae/logstore/driver/logservicedriver/replay_test.go:1790:
replay_test.go:1789: Read error: context canceled
replay_test.go:1790:
Error Trace: .../logservicedriver/replay_test.go:1790
Error: Target error should be in err chain:
expected: "internal error: cancel"
in chain: "context canceled"
Test: Test_Replayer9
--- FAIL: Test_Replayer9 (0.78s)
The corresponding replay log shows that the error came back through the read-and-schedule path:
Wal-Replay-Info {
"err-msg": "read and schedule error in loop: context canceled",
"error": "context canceled"
}
The later line below is only a t.Logf message from the second replay, not the failing assertion:
replay_test.go:1837: Read error: internal error: cancel
That second value demonstrates the other cancellation path preserving the cause as expected.
Expected Behavior
After readCancel(cancelErr) cancels either replay, consumer.GetReplayState().Err() should retain the supplied cancellation cause. In particular:
assert.ErrorIs(t, readErr, cancelErr)should hold whether cancellation is observed by the outer replay loop or while reading the next batch from the backend. The returned error should not depend on goroutine/read timing.
Steps to Reproduce
Observed in the CI job linked above. The test creates a context with context.WithCancelCause, runs ReplayForever, and then cancels it with:
cancelErr := moerr.NewInternalErrorNoCtx("cancel")
readCancel(cancelErr)
<-consumer.ReplayWaitC()
readErr := consumer.GetReplayState().Err()
assert.ErrorIs(t, readErr, cancelErr)A focused stress command for reproducing the timing-dependent failure is:
go test ./pkg/vm/engine/tae/logstore/driver/logservicedriver \
-run '^Test_Replayer9$' -count=100This report is based on the executed CI failure and source tracing; the focused local stress run has not been performed as part of this report.
Additional information
Source trace and likely mechanism
There are two cancellation-error paths with different semantics:
- The outer replay loop in
replayer.Replayusescontext.Cause(ctx)when it observesctx.Done()(replayer.go:462-471). This preserves the test'sinternal error: cancelcause. readNextBatchcallsLogServiceDriver.readFromBackend(replayer.go:849-858). When the parent context is canceled,readFromBackendreturnsctx.Err()in its cancellation checks (driver.go:380-383anddriver.go:399-401). This discards the specific cause and returns onlycontext.Canceled.readNextBatchpropagates that error to the replay loop, which returns through theread and schedule error in looppath before the outerctx.Done()branch can replace it withcontext.Cause(ctx).
Therefore, cancellation during backend reading can produce context canceled, while cancellation observed by the outer replay loop produces internal error: cancel. This explains both values appearing in the same test log and why the failure is timing-dependent.
Scope
- The observed failure is a UT failure and an inconsistency in cancellation-error propagation.
- No data corruption or incorrect replayed entries are demonstrated by this failure.
- PR perf(cdc): avoid formatting disabled watermark debug logs #32938 only changes
pkg/cdc/watermark_updater.go; there is no evidence that its CDC logging optimization is involved in this logservice replay path.
Suggested fix and regression coverage
Preserve context.Cause(ctx) when the parent replay context is canceled, either in readFromBackend's parent-cancellation branches or at a single replay error-normalization boundary. Real backend errors and timeout causes should remain unchanged rather than being blindly replaced.
Regression coverage should exercise cancellation both before/around the outer replay ctx.Done() check and while the backend read is active, asserting errors.Is(err, cancelErr) in both cases. The existing second replay log shows that the outer-loop path already satisfies this contract.
Activity
fix: preserve TAE snapshot row IDs and stabilize main CI (#32957)