Repository navigation
[4.2-dev] fix(tae): cancel snapshot writes when a table-tail flush fails - #33493
mergify[bot] merged 3 commits into
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: Fixes #33490. The corresponding 4.2-dev change is #33493. ## What this PR does / why we need it: When a table-tail flush times out waiting for an appendable-object snapshot, a child that already owns its batch can continue writing on the I/O worker. That write occupies the worker even though its parent can no longer commit the flush. Register the child's cancel function while transferring ownership of the batch. On failure, retire pending batches and cancel running writes across both the data and tombstone groups, including partially scheduled groups. Wait for the local writers to release their resources before returning the parent's object scopes to the scheduler. Log the failing phase before draining so it is visible even if storage is slow to respond. The six-minute snapshot wait budget is unchanged. ### Validation on main Compared the baseline at `d4a41b466c` and this patch on the same Linux host. Two three-row flushes shared one I/O worker. The loopback HTTP endpoint delayed the first PUT response by 400 ms, and the parent had a 40 ms wait budget after the write reached storage. | Scenario | Runs per version | Baseline P50 / P95 | Patched P50 / P95 | |---|---:|---:|---:| | S3FS + MinIO SDK, time from timeout to next successful flush | 20 | 361.196 / 361.526 ms | 0.679 / 0.872 ms | | Backend ignores cancellation, same recovery metric | 20 | 360.722 / 360.904 ms | 360.642 / 360.778 ms | | Two successful writes, warmed up, total elapsed | 1,800 | 53 / 205 µs | 57 / 205 µs | The HTTP endpoint observed cancellation in all 20 patched runs, and the next object write succeeded each time. A backend that ignores cancellation can still delay parent cleanup. These tests measure local worker recovery; production checkpoint latency and OOM frequency were outside the experiment. The jobs package passed build, vet, normal tests and the race detector. Both new regression tests passed 100 race repetitions each. The engine regressions passed for table-tail flush, error handling, tombstone rollback, stopping checkpoints on flush failure, and preserving snapshot row IDs across an aborted append. ### Branch update validation Rebased onto official `main` at `98b20975b7` after GitHub rejected Mergify's automated branch update for a workflow permission. The patch at `54b5814dcb` matches the patch at `8286e8d586` in `git range-diff`. `git diff --check` and the Loom artifact check passed. On Darwin/arm64 at `54b5814dcb`, `mo-cgo-test -race -short` passed both snapshot cancellation tests and four engine tests covering normal table-tail flush, flush errors, and tombstone rollback. These checks cover the rebase across the upstream appendable-object merge changes. The benchmark numbers above are from `8286e8d586`. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 10c9a8b52e2784da2a73cf211dfe4e205902040e
Assessment: request_changes
The cancellation design handles ordinary error returns, but the new cleanup condition skips a recoverable panic path. This allows snapshot writes that were previously retired while queued to start after the parent releases its object scopes.
Model: gpt-6.1-terra / max
Session: 01a22af4-cf2a-7f70-88e4-931bbf57d739 · slot 2 · generation 14
- P2
pkg/vm/engine/tae/tables/jobs/flushTableTail.go:322: The synchronous merge panics after snapshot tasks have been scheduled, for example when S3FS.Write encounters an io.EOF error.
Impact: The named error remains nil during unwinding, so abortSnapshotWrites is skipped. The scheduler recovers the panic and releases the object scopes, after which queued snapshot tasks can start writes that may leave orphan files or overlap a retry. The baseline already allowed an active writer to continue on this path; allowing queued writers to start is the regression.
Evidence: A real-scheduler probe with one I/O worker and an injected merge-write panic observed a queued snapshot write after scope release on the candidate; the same probe with the two implementation files overlaid from the merge-base observed none. Those baseline files match the pinned target base and the linked issue's v4.2.9 incident commit. Ensure outstanding children are canceled and drained on panic as well as on an error return, while preserving panic propagation.
Validation:
-
Private /tmp and loopback preflight passed; retained native inputs and library hashes matched the frozen checkout.
-
Both focused cancellation tests passed. The jobs package passed 30 repetitions under the race detector.
-
TestFlushTableErrorHandle, TestFlushTableErrorHandle2, TestFlushTabletail, and TestFlushTransferTombstonesRollback passed.
-
The controlled scheduler panic probe and merge-base control completed with the observations described in the finding; receipts and logs are retained in the diagnostic directory.
Limitations:
-
The panic probe injected a FileService panic; it did not exercise a real S3 endpoint or a real network failure.
-
The first race build did not load the assigned shell environment and failed to find native headers. The corrected run used the assigned environment and passed.
-
The full test suite was not run. A remote PUT already accepted by an object store may still complete after local cancellation.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 415e77f443bbfa3705f45a174c38b675cb2f7d5a
Assessment: approve
The earlier panic finding is resolved: the parent records children before scheduling and cancels and drains outstanding snapshot writes on both errors and panics. The change reuses the existing scheduler and adds per-child synchronization to preserve batch ownership and object scopes. No actionable findings remain.
Model: gpt-6.1-terra / max
Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45
Validation:
-
Private /tmp and loopback preflight and native-input provenance checks passed.
-
The focused cancellation tests and the complete jobs package passed. Each focused child test passed 100 race-enabled repetitions, and the complete jobs package passed once under race.
-
The engine panic regression and selected flush, error-handling, and tombstone-rollback tests passed. The panic regression also passed 100 race-enabled repetitions.
-
The same panic regression failed against the earlier reviewed parent implementation, observing one queued snapshot write after the panic, and passed on the assigned head.
-
Vet and git diff --check passed. The corrected evidence audit passed with receipt checks/1796097353872575714-4.json; its initial receipt selector had matched multiple valid test runs.
Limitations:
-
The author-reported MinIO latency experiment and full integration suite were not independently rerun.
-
A backend that ignores cancellation can delay scope release until its local write returns; cancellation cannot guarantee rollback of a PUT already accepted remotely.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #33490.
What this PR does / why we need it:
A table-tail flush can time out waiting for a snapshot while an already-running child keeps writing on the I/O worker's context. In one QA incident a child logged a successful object write more than 18 minutes after its parent reported failure.
The child now registers a cancel function and claims its batch under the same lock. On parent failure, the parent first retires pending batches and cancels running writes across both data and tombstone groups, including any partially scheduled group. It then waits for the local writers and their resource cleanup before returning control to the scheduler. The existing snapshot wait budget is unchanged. A phase log records the failure before waiting for cleanup.
If the parent panics while snapshot writes are outstanding, the same cancellation and drain run before the panic propagates. The parent retains each child as it is scheduled, including children in a partially scheduled group. Review finding
If the storage backend ignores cancellation, the parent must still wait for the local writer to finish. Canceling a client request cannot guarantee rollback of a PUT already received by a remote server.
Validation
Both new ownership and cancellation regression tests passed 100 repetitions each under the race detector. The owning package also passed build, vet, normal tests and a full-package race run.
Engine integration tests passed for table-tail flush, both flush error-handling paths and tombstone rollback.
In the QA-version A/B experiment with the real MinIO SDK and a delayed loopback HTTP endpoint, median time from timeout to the next successful flush fell from 361.119 ms to 0.645 ms (20 runs per version). Normal two-write medians were 0.168 and 0.172 ms. Experiment and controls
Panic follow-up at
415e77f443bb(Darwin/arm64, Go 1.27.1).mo-cgo-testreproduced one late queued write on the reviewed code and zero after the fix, with the injected panic reaching the caller. The panic regression and both snapshot ownership tests each passed 100 race repetitions. The jobs package passed normal and race tests, and the targeted TAE flush and tombstone rollback tests passed. The jobs package built successfully. Vet and incremental lint passed for both touched packages. The loopback figures above are from the original QA-version experiment.