Skip to content

fix(tae): cancel snapshot writes when a table-tail flush fails - #33494

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/33490-main-cancel-snapshot-writes
Nov 30, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/33490-main-cancel-snapshot-writes

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • 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.

@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 →

@mergify

mergify Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@iamlinjunhong
iamlinjunhong force-pushed the fix/33490-main-cancel-snapshot-writes branch from 8286e8d to 54b5814 Compare November 30, 2026 07:46
@XuPeng-SH

XuPeng-SH commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 54b5814dcbce3f7b7de5bcdb1c18eece5f4b77d3

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 54b5814dcbce3f7b7de5bcdb1c18eece5f4b77d3

Assessment: approve

No actionable defects found. The change extends the existing child task with cancellation and drain tracking, preserving batch ownership and holding the parent’s object scopes until running local writers return.

Model: gpt-6.1-terra / max

Session: 01a22aff-bb68-7e31-ae71-ee4ab48ad9d0 · slot 0 · generation 45

Validation:

  • Private-runtime preflight passed. Native prerequisites were built for the frozen head and verified with the repository’s provenance checker.

  • The jobs package passed under the race detector. Each new cancellation test also passed 100 separate race repetitions.

  • The existing table-tail error and successful-flush engine tests passed in normal mode; the error test also passed under the race detector in short mode. The parent uses an OpWorker in these tests, while dispatcher scope-release ordering was verified by source tracing.

  • Successful checks have matching frozen-head receipts and retained logs in the diagnostic directory.

Limitations:

  • The author’s MinIO latency measurements were not independently reproduced, and no real S3 service was exercised locally. A backend that does not return after cancellation can still delay parent cleanup.

@mergify

mergify Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request merged manually

57 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 30 Nov, 09:22 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 10:19 · a1e20b8

Reason

Pull request #33494 has been merged manually at 7e8130e

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 7e8130e into matrixorigin:main Nov 30, 2026
28 of 33 checks passed
@mergify mergify Bot removed the queued label Nov 30, 2026
XuPeng-SH added a commit that referenced this pull request Nov 30, 2026
## What type of PR is this?

- [x] Documentation
- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #30150 for the required check on cancelled producers. The
rollout uses the control runner support from #28717 and addresses the
queue observed on #33494 and #33501.

## What this PR does / why we need it:

On #33501 the old required check waited 7m35s for a hosted runner and
ran for four seconds. The replacement workflow was unable to start
preflight during that wait. On #33494 the old required check and the
cancellation controller also queued together. [Required check from
#33501](https://github.com/matrixorigin/matrixone/actions/runs/46374859836/job/141702801415)
· [Required check from
#33494](https://github.com/matrixorigin/matrixone/actions/runs/46368023504/job/141705095759)

The repository setting for preflight, the required check and the
cancellation controller now selects the shared CS medium pool. This
update records the operational setting and how to restore hosted
execution and release a superseded run if a runner label stops serving
work.

Two simultaneous jobs using the shared label started on MTY and RUH in 7
and 11 seconds. A hosted reference submitted with them waited 61
seconds. JED and MNL2 also ran the same checkout, PR metadata read and
required-check verification. [Shared-label
comparison](https://github.com/matrixorigin/matrixone/actions/runs/46378188128)
· [JED and
MNL2](https://github.com/matrixorigin/matrixone/actions/runs/46380046197)

In a branch-isolated handoff, cancellation made the old required check
fail and the successor reached a runner 50 seconds after its workflow
was created. A second exercise held the old required check on a
nonexistent label, restored the hosted default for the successor, and
used GitHub's force-cancel operation on the obsolete probe. The 65
existing scope and cancellation tests passed locally. [Cancelled
producer](https://github.com/matrixorigin/matrixone/actions/runs/46379765379)
· [Successful
successor](https://github.com/matrixorigin/matrixone/actions/runs/46379836410)
· [Hosted
recovery](https://github.com/matrixorigin/matrixone/actions/runs/46380130392)

After the repository setting changed on November 30 at 08:20 UTC, the
production preflight picked up this main PR on RUH in 15 seconds and a
4.2-dev PR on MTY in 5 seconds. The cancellation controller for this PR
picked up on RUH in 10 seconds. [Main
preflight](https://github.com/matrixorigin/matrixone/actions/runs/46380837572/job/141720723388)
· [4.2-dev
preflight](https://github.com/matrixorigin/matrixone/actions/runs/46381492276/job/141721422578)
· [Cancellation
controller](https://github.com/matrixorigin/matrixone/actions/runs/46380847802/job/141719313212)

On main PR #33502 the deployed controller picked up on RUH in 11
seconds, waited the existing grace period, and automatically
force-cancelled the superseded run while its hosted required check was
queued. The successor preflight picked up on MTY in 5 seconds. From the
new workflow being created to preflight starting took 2m48s. This
documentation PR's required check also passed on MTY after a 6-second
queue. [Automatic
cancellation](https://github.com/matrixorigin/matrixone/actions/runs/46382877728/job/141725947578)
· [Successor
preflight](https://github.com/matrixorigin/matrixone/actions/runs/46382871951/job/141727210246)
· [Passing required
check](https://github.com/matrixorigin/matrixone/actions/runs/46380837572/job/141731647152)

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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DN snapshot writes keep I/O workers busy after the parent flush times out

3 participants