Skip to content

fix(logtail): propagate checkpoint iterator errors - #26233

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/26210-checkpoint-iterator-error
Jul 27, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix/26210-checkpoint-iterator-error

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #26210

What this PR does / why we need it:

After task_kill_cn, a replacement CN must rebuild table state by consuming the latest checkpoint before serving the subscription. consumeCheckpointWithTableID stopped its data and tombstone loops when ObjectIter.Next() returned an error, but discarded that error and returned nil. A context/FileService failure could therefore publish a partially reconstructed partition and finalize the table as Subscribed.

Incident evidence for #26210

The production logs pin the reported storm to this failed-reconstruction shape rather than to ordinary TPCC contention:

  1. At 17:25:22–17:25:44 UTC, TN merge MT-1299 compacted bmsql_stock and deleted its 18 source objects. The merge committed at 1785000344282453036-0.
  2. The ICKP covering 17:24:33–17:29:33 UTC was completed at 17:31:58, so it includes that merge deletion. A CN subscribing after this checkpoint must not serve rows from those source objects as live.
  3. Replacement CN mo-chaos-regression-dis-tp-cn-jndns received the bmsql_stock subscription response at 17:32:15.660916 and logged subscribe-ok at 17:32:15.705894. The triggering migrated SELECT ... FROM bmsql_stock ... FOR UPDATE prepare failed with context deadline exceeded at 17:32:15.707491, immediately at the lazy checkpoint-consumption boundary.
  4. The first reported 20618 at 17:32:55.368 is identified by TN as TRANSFER-ERR, old-err=ExpectedEOB, table 273124 (bmsql_stock). Its transaction ID maps back to CN jndns.
  5. Full-window Loki counts match exactly: all 10,531 CN-side r-w conflict errors came from jndns, and TN logged exactly 10,531 TRANSFER-ERR/ExpectedEOB failures for table 273124.
  6. Those failures contain only 13 block-row IDs from seven objects. All seven are source objects deleted by the same MT-1299 merge. Their TN transfer entries had already expired, which is why TN returned ExpectedEOB; a correctly rebuilt post-merge CN partition could not continue selecting those objects.
  7. task_kill_dn started at 18:15:10; the last conflict was at 18:15:13. After logtail recovery, jndns subscribed bmsql_stock again with a new partition state at 18:16:23, and the storm disappeared.

The affected binary cannot emit the iterator error itself: S3FS.Read may return ctx.Err() before installing its event logger, ObjectIter.Next() returns that error, and the old loop then discards it. The observable production signature is consequently false subscribe-ok followed by a partition that still serves objects whose checkpointed merge deletion was not applied. The deterministic regression supplies the missing direct function-level proof: with an expired context, ObjectIter.Next() returns context.DeadlineExceeded while the affected consumeCheckpointWithTableID returns nil.

Failure path

  1. ObjectIter.Next() returns a context/FileService error from ioutil.LoadColumnsData.
  2. The old loop exits without returning that error.
  3. Partition.ConsumeCheckpoints receives nil, publishes the partially populated copy, and sets checkpointConsumed=true.
  4. loadAndConsumeLatestCkp receives nil and advances the table to Subscribed.
  5. The CN serves stale checkpoint objects. Updates using their row IDs reach TN after the merge transfer entries have expired, and txnimpl/table.go converts TransferTable.Pin(...)=ExpectedEOB into 20618 r-w conflict.

Fix

This PR:

  • checks every data and tombstone iterator result explicitly and returns the original error;
  • prevents partial checkpoint state from being published or marked consumed;
  • prevents a failed initial load from becoming Subscribed, allowing retry with a fresh context;
  • preserves normal EOF, callback-error, and cleanup behavior;
  • adds real checkpoint/FileService coverage for successful consumption and data/tombstone iterator failures.

There is no protocol, storage-format, RPC, locking, or normal-path I/O change. Legitimate r-w conflicts remain unchanged; this prevents the incomplete CN state that generated #26210’s pathological conflict storm.

Testing

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=5m ./pkg/vm/engine/tae/logtail
  • .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=10m -run 'TestConsumeCheckpointWithTableID($|PropagatesIteratorError)' ./pkg/vm/engine/tae/logtail
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m ./pkg/vm/engine/disttae
  • go vet -mod=readonly ./pkg/vm/engine/tae/logtail
  • go build -mod=readonly ./pkg/vm/engine/tae/logtail ./pkg/vm/engine/disttae
  • PR CI: UT, race-sensitive package tests, SCA, BVT, and coverage passed

@LeftHandCold
LeftHandCold requested a review from XuPeng-SH as a code owner July 27, 2026 07:46
@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 →

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

Blocking: please remove or correct fixes #26210 in the PR description before merge. Issue #26210 tracks the unresolved production Chaos/TPCC 20618 r-w conflict storm after killing a CN; this checkpoint-iterator patch does not address that incident. With the current closing keyword, merging this PR into main will automatically close that unrelated production issue and hide outstanding work.

The code change itself looks sound: iterator errors are propagated before the copy-on-write partition state is published or the subscription becomes Subscribed; normal EOF, callback errors, cleanup, and retry behavior are preserved. Local validation passed 10 repeated targeted runs, 5 race-enabled runs, and the dependent disttae subscription-consumption test.

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

Updated the PR description and removed the auto-closing keyword.

The patch is scoped to checkpoint iterator error propagation. It was found while investigating #26210, but it does not prove that this defect resolves the complete post-CN-kill 20618 r-w conflict storm. #26210 will remain open for the unresolved production recovery path.

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

I re-evaluated the closing-keyword review against the incident-specific RCA rather than the issue body’s original, pre-RCA hypotheses.

fixes #26210 has been restored. The PR is intended to fix the reported post-task_kill_cn 20618 storm: the iterator error was converted to false checkpoint success, which published a partial CN partition state and finalized the table as Subscribed. That incomplete state explains the co-timed stock misses and the stale/incomplete object references that TN surfaces as r-w conflicts. Returning the error prevents both publication and subscription finalization, so the load retries instead of sustaining the storm.

I expanded the PR description and added the full root-cause update to #26210: #26210 (comment)

This corrects my earlier overly conservative comment. The patch is not a generic r-w conflict mitigation; it removes the proven state-publication defect that generated this incident’s pathological conflicts.

@LeftHandCold
LeftHandCold requested a review from XuPeng-SH July 27, 2026 09:59

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

Re-review after considering the latest PR and issue comments:

The code change itself is sound and I found no additional code blocker. The iterator error now exits before the copy-on-write PartitionState is published, before checkpointConsumed is set, and before the subscription advances to Subscribed; EOF, callback errors, cleanup, and retry behavior remain intact. Targeted race runs (10x), the dependent subscription-consumption test, and PR CI pass.

The closing-keyword blocker remains. The new RCA comment establishes a plausible code-level failure chain, but its direct validation proves only the generic iterator-error propagation defect. It does not provide direct incident evidence that this iterator path failed and published partial state during #26210, nor a same-topology chaos replay showing that this change eliminates the reported ~43-minute 20618 storm. In particular, the link from an incomplete CN object view to that incident’s 20618 burst is still an inference.

Please replace fixes #26210 with Refs #26210 and keep the incident open for replay verification, or provide direct incident/replay evidence sufficient to close it. No further code changes are requested.

@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

I agree that the previous description only showed temporal correlation plus the generic iterator regression. I went back to the complete Loki history and correlated the incident at object and transaction granularity.

The new evidence changes the assessment:

  • all 10,531 CN-side conflicts came from replacement CN jndns;
  • TN has exactly 10,531 corresponding TRANSFER-ERR, old-err=ExpectedEOB records for table 273124 (bmsql_stock);
  • all failed row IDs belong to seven old objects, and every one was deleted by the same MT-1299 merge committed at 17:25:44;
  • the ICKP completed before the subscription covers 17:24:33–17:29:33, so it contains that merge deletion;
  • jndns nevertheless reported subscribe-ok at 17:32:15.705894, immediately followed at 17:32:15.707491 by context deadline exceeded in the migrated stock statement that triggered the subscription;
  • after TN restart forced logtail recovery, jndns rebuilt the table with a new partition state and the storm ended.

A correctly consumed post-merge checkpoint cannot expose those source objects. The affected loop is the concrete path that converts the checkpoint read/cancellation into success, publishes the partial state, and marks it subscribed. The iterator error itself cannot exist in historical logs because this bug discards it, and S3FS.Read can return ctx.Err() before installing its event logger.

I added the full evidence and counts to the PR description and to the issue: #26210 (comment)

Based on this object-level closure, I am retaining fixes #26210. A same-topology replay remains valuable verification, but it is not the only way to establish causality when the affected binary necessarily suppresses the triggering error and the surviving state/row IDs identify the missed checkpoint deletion.

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

No blocking findings on ae46ab5.

The added incident evidence resolves my earlier causality concern around fixes #26210: the exact CN/TN error-count match, the seven stale source objects deleted by MT-1299 and covered by the checkpoint, and the deadline at the lazy checkpoint-load boundary form a sufficiently specific production chain to the swallowed ObjectIter.Next() error.

The implementation now propagates iterator failures for both data and tombstone ranges. The downstream partition update is copy-on-write, so an error neither publishes partial state nor sets checkpointConsumed; subscription state likewise does not advance to Subscribed, preserving retry with a fresh context. EOF, callback errors, and iterator cleanup remain intact.

Verified locally on the exact head:

  • focused regression under -race -count=5
  • full pkg/vm/engine/tae/logtail package under -race

The PR checks currently reported by GitHub are green.

@mergify mergify Bot added the queued label Jul 27, 2026
@mergify

mergify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-27 16:44 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-27 17:25 UTC · at 75fa352fa58bd6a63f3f1f3bf207a73598c29ecc

This pull request spent 40 minutes 33 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection] (documentation)
  • github-review-decision = APPROVED [🛡 GitHub branch protection] (documentation)

Reason

Pull request #26233 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

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

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 4f82ab5 into matrixorigin:main Jul 27, 2026
21 of 23 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 27, 2026
XuPeng-SH added a commit that referenced this pull request Jul 27, 2026
## Summary

- Remove the obsolete post-merge MOC coverage-status workflow. The
current coverage pipeline is self-contained and no longer creates the
legacy MOC record this workflow expects.
- Stabilize three user-level-lock cleanup tests by asserting durable
terminal state instead of transient asynchronous-worker
ownership/progress, and always reset shared test state on early
assertion exit.
- Add the read-only `mo-pr-radar` skill for deterministic PR review
queues, conflict/CI/approval filters, request-changes freshness, and
per-PR blocker explanations. Its review model uses each reviewer's
latest opinionated review, so a later comment cannot erase an
approval/change request and a later approval clears historical change
requests.
- Strengthen `mo-self-review` with exact affected-test selection,
adaptive per-test race budgets, deterministic flake checks, and one
complete owning-package race run. Zero/under-resolution JSON test
durations safely use the adaptive ceiling.

## Validation

- Confirmed the removed workflow runs only after a merged PR closes, is
not a required check on main or 4.2-dev, and has no repository/Mergify
references.
- PR radar: 22 offline unit tests, Bash syntax checks, both skill
validators, and live GitHub regressions: #25089 remains
`CHANGES_REQUESTED` after a later comment; approved #26233 is absent
from the stale-change queue.
- Adaptive race measurements from `go test -json`, with `B=30s`:
release-cleanup `T=0.07s, N=100`; timed-out cleanup `T=1.06s, N=28`;
successful-probe cleanup `T=0.05s, N=100`.
- Final focused race stress passed for all three exact tests
(`-count=100/28/100`); matching non-race stress also passed.
- Full `pkg/sql/plan/function` owning package passed with `-race
-count=1`.
- `go build` and `go vet` passed for `pkg/sql/plan/function`.
- `git diff --check` passed after merging the latest main.

Fixes #26262.
Related to #26253.
LeftHandCold added a commit to LeftHandCold/matrixone that referenced this pull request Jul 29, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

fixes matrixorigin#26210

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

After `task_kill_cn`, a replacement CN must rebuild table state by
consuming the latest checkpoint before serving the subscription.
`consumeCheckpointWithTableID` stopped its data and tombstone loops when
`ObjectIter.Next()` returned an error, but discarded that error and
returned nil. A context/FileService failure could therefore publish a
partially reconstructed partition and finalize the table as
`Subscribed`.

### Incident evidence for matrixorigin#26210

The production logs pin the reported storm to this failed-reconstruction
shape rather than to ordinary TPCC contention:

1. At `17:25:22–17:25:44 UTC`, TN merge `MT-1299` compacted
`bmsql_stock` and deleted its 18 source objects. The merge committed at
`1785000344282453036-0`.
2. The ICKP covering `17:24:33–17:29:33 UTC` was completed at
`17:31:58`, so it includes that merge deletion. A CN subscribing after
this checkpoint must not serve rows from those source objects as live.
3. Replacement CN `mo-chaos-regression-dis-tp-cn-jndns` received the
`bmsql_stock` subscription response at `17:32:15.660916` and logged
`subscribe-ok` at `17:32:15.705894`. The triggering migrated `SELECT ...
FROM bmsql_stock ... FOR UPDATE` prepare failed with `context deadline
exceeded` at `17:32:15.707491`, immediately at the lazy
checkpoint-consumption boundary.
4. The first reported `20618` at `17:32:55.368` is identified by TN as
`TRANSFER-ERR`, `old-err=ExpectedEOB`, table `273124` (`bmsql_stock`).
Its transaction ID maps back to CN `jndns`.
5. Full-window Loki counts match exactly: all **10,531** CN-side `r-w
conflict` errors came from `jndns`, and TN logged exactly **10,531**
`TRANSFER-ERR/ExpectedEOB` failures for table `273124`.
6. Those failures contain only 13 block-row IDs from seven objects. All
seven are source objects deleted by the same `MT-1299` merge. Their TN
transfer entries had already expired, which is why TN returned
`ExpectedEOB`; a correctly rebuilt post-merge CN partition could not
continue selecting those objects.
7. `task_kill_dn` started at `18:15:10`; the last conflict was at
`18:15:13`. After logtail recovery, `jndns` subscribed `bmsql_stock`
again with a new partition state at `18:16:23`, and the storm
disappeared.

The affected binary cannot emit the iterator error itself: `S3FS.Read`
may return `ctx.Err()` before installing its event logger,
`ObjectIter.Next()` returns that error, and the old loop then discards
it. The observable production signature is consequently false
`subscribe-ok` followed by a partition that still serves objects whose
checkpointed merge deletion was not applied. The deterministic
regression supplies the missing direct function-level proof: with an
expired context, `ObjectIter.Next()` returns `context.DeadlineExceeded`
while the affected `consumeCheckpointWithTableID` returns nil.

### Failure path

1. `ObjectIter.Next()` returns a context/FileService error from
`ioutil.LoadColumnsData`.
2. The old loop exits without returning that error.
3. `Partition.ConsumeCheckpoints` receives nil, publishes the partially
populated copy, and sets `checkpointConsumed=true`.
4. `loadAndConsumeLatestCkp` receives nil and advances the table to
`Subscribed`.
5. The CN serves stale checkpoint objects. Updates using their row IDs
reach TN after the merge transfer entries have expired, and
`txnimpl/table.go` converts `TransferTable.Pin(...)=ExpectedEOB` into
`20618 r-w conflict`.

### Fix

This PR:

- checks every data and tombstone iterator result explicitly and returns
the original error;
- prevents partial checkpoint state from being published or marked
consumed;
- prevents a failed initial load from becoming `Subscribed`, allowing
retry with a fresh context;
- preserves normal EOF, callback-error, and cleanup behavior;
- adds real checkpoint/FileService coverage for successful consumption
and data/tombstone iterator failures.

There is no protocol, storage-format, RPC, locking, or normal-path I/O
change. Legitimate r-w conflicts remain unchanged; this prevents the
incomplete CN state that generated matrixorigin#26210’s pathological conflict storm.

## Testing

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=5m
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10
-timeout=10m -run
'TestConsumeCheckpointWithTableID($|PropagatesIteratorError)'
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m
./pkg/vm/engine/disttae`
- `go vet -mod=readonly ./pkg/vm/engine/tae/logtail`
- `go build -mod=readonly ./pkg/vm/engine/tae/logtail
./pkg/vm/engine/disttae`
- PR CI: UT, race-sensitive package tests, SCA, BVT, and coverage passed

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

fixes matrixorigin#26210

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

After `task_kill_cn`, a replacement CN must rebuild table state by
consuming the latest checkpoint before serving the subscription.
`consumeCheckpointWithTableID` stopped its data and tombstone loops when
`ObjectIter.Next()` returned an error, but discarded that error and
returned nil. A context/FileService failure could therefore publish a
partially reconstructed partition and finalize the table as
`Subscribed`.

### Incident evidence for matrixorigin#26210

The production logs pin the reported storm to this failed-reconstruction
shape rather than to ordinary TPCC contention:

1. At `17:25:22–17:25:44 UTC`, TN merge `MT-1299` compacted
`bmsql_stock` and deleted its 18 source objects. The merge committed at
`1785000344282453036-0`.
2. The ICKP covering `17:24:33–17:29:33 UTC` was completed at
`17:31:58`, so it includes that merge deletion. A CN subscribing after
this checkpoint must not serve rows from those source objects as live.
3. Replacement CN `mo-chaos-regression-dis-tp-cn-jndns` received the
`bmsql_stock` subscription response at `17:32:15.660916` and logged
`subscribe-ok` at `17:32:15.705894`. The triggering migrated `SELECT ...
FROM bmsql_stock ... FOR UPDATE` prepare failed with `context deadline
exceeded` at `17:32:15.707491`, immediately at the lazy
checkpoint-consumption boundary.
4. The first reported `20618` at `17:32:55.368` is identified by TN as
`TRANSFER-ERR`, `old-err=ExpectedEOB`, table `273124` (`bmsql_stock`).
Its transaction ID maps back to CN `jndns`.
5. Full-window Loki counts match exactly: all **10,531** CN-side `r-w
conflict` errors came from `jndns`, and TN logged exactly **10,531**
`TRANSFER-ERR/ExpectedEOB` failures for table `273124`.
6. Those failures contain only 13 block-row IDs from seven objects. All
seven are source objects deleted by the same `MT-1299` merge. Their TN
transfer entries had already expired, which is why TN returned
`ExpectedEOB`; a correctly rebuilt post-merge CN partition could not
continue selecting those objects.
7. `task_kill_dn` started at `18:15:10`; the last conflict was at
`18:15:13`. After logtail recovery, `jndns` subscribed `bmsql_stock`
again with a new partition state at `18:16:23`, and the storm
disappeared.

The affected binary cannot emit the iterator error itself: `S3FS.Read`
may return `ctx.Err()` before installing its event logger,
`ObjectIter.Next()` returns that error, and the old loop then discards
it. The observable production signature is consequently false
`subscribe-ok` followed by a partition that still serves objects whose
checkpointed merge deletion was not applied. The deterministic
regression supplies the missing direct function-level proof: with an
expired context, `ObjectIter.Next()` returns `context.DeadlineExceeded`
while the affected `consumeCheckpointWithTableID` returns nil.

### Failure path

1. `ObjectIter.Next()` returns a context/FileService error from
`ioutil.LoadColumnsData`.
2. The old loop exits without returning that error.
3. `Partition.ConsumeCheckpoints` receives nil, publishes the partially
populated copy, and sets `checkpointConsumed=true`.
4. `loadAndConsumeLatestCkp` receives nil and advances the table to
`Subscribed`.
5. The CN serves stale checkpoint objects. Updates using their row IDs
reach TN after the merge transfer entries have expired, and
`txnimpl/table.go` converts `TransferTable.Pin(...)=ExpectedEOB` into
`20618 r-w conflict`.

### Fix

This PR:

- checks every data and tombstone iterator result explicitly and returns
the original error;
- prevents partial checkpoint state from being published or marked
consumed;
- prevents a failed initial load from becoming `Subscribed`, allowing
retry with a fresh context;
- preserves normal EOF, callback-error, and cleanup behavior;
- adds real checkpoint/FileService coverage for successful consumption
and data/tombstone iterator failures.

There is no protocol, storage-format, RPC, locking, or normal-path I/O
change. Legitimate r-w conflicts remain unchanged; this prevents the
incomplete CN state that generated matrixorigin#26210’s pathological conflict storm.

## Testing

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=5m
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10
-timeout=10m -run
'TestConsumeCheckpointWithTableID($|PropagatesIteratorError)'
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m
./pkg/vm/engine/disttae`
- `go vet -mod=readonly ./pkg/vm/engine/tae/logtail`
- `go build -mod=readonly ./pkg/vm/engine/tae/logtail
./pkg/vm/engine/disttae`
- PR CI: UT, race-sensitive package tests, SCA, BVT, and coverage passed

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Remove the obsolete post-merge MOC coverage-status workflow. The
current coverage pipeline is self-contained and no longer creates the
legacy MOC record this workflow expects.
- Stabilize three user-level-lock cleanup tests by asserting durable
terminal state instead of transient asynchronous-worker
ownership/progress, and always reset shared test state on early
assertion exit.
- Add the read-only `mo-pr-radar` skill for deterministic PR review
queues, conflict/CI/approval filters, request-changes freshness, and
per-PR blocker explanations. Its review model uses each reviewer's
latest opinionated review, so a later comment cannot erase an
approval/change request and a later approval clears historical change
requests.
- Strengthen `mo-self-review` with exact affected-test selection,
adaptive per-test race budgets, deterministic flake checks, and one
complete owning-package race run. Zero/under-resolution JSON test
durations safely use the adaptive ceiling.

## Validation

- Confirmed the removed workflow runs only after a merged PR closes, is
not a required check on main or 4.2-dev, and has no repository/Mergify
references.
- PR radar: 22 offline unit tests, Bash syntax checks, both skill
validators, and live GitHub regressions: matrixorigin#25089 remains
`CHANGES_REQUESTED` after a later comment; approved matrixorigin#26233 is absent
from the stale-change queue.
- Adaptive race measurements from `go test -json`, with `B=30s`:
release-cleanup `T=0.07s, N=100`; timed-out cleanup `T=1.06s, N=28`;
successful-probe cleanup `T=0.05s, N=100`.
- Final focused race stress passed for all three exact tests
(`-count=100/28/100`); matching non-race stress also passed.
- Full `pkg/sql/plan/function` owning package passed with `-race
-count=1`.
- `go build` and `go vet` passed for `pkg/sql/plan/function`.
- `git diff --check` passed after merging the latest main.

Fixes matrixorigin#26262.
Related to matrixorigin#26253.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

fixes matrixorigin#26210

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

After `task_kill_cn`, a replacement CN must rebuild table state by
consuming the latest checkpoint before serving the subscription.
`consumeCheckpointWithTableID` stopped its data and tombstone loops when
`ObjectIter.Next()` returned an error, but discarded that error and
returned nil. A context/FileService failure could therefore publish a
partially reconstructed partition and finalize the table as
`Subscribed`.

### Incident evidence for matrixorigin#26210

The production logs pin the reported storm to this failed-reconstruction
shape rather than to ordinary TPCC contention:

1. At `17:25:22–17:25:44 UTC`, TN merge `MT-1299` compacted
`bmsql_stock` and deleted its 18 source objects. The merge committed at
`1785000344282453036-0`.
2. The ICKP covering `17:24:33–17:29:33 UTC` was completed at
`17:31:58`, so it includes that merge deletion. A CN subscribing after
this checkpoint must not serve rows from those source objects as live.
3. Replacement CN `mo-chaos-regression-dis-tp-cn-jndns` received the
`bmsql_stock` subscription response at `17:32:15.660916` and logged
`subscribe-ok` at `17:32:15.705894`. The triggering migrated `SELECT ...
FROM bmsql_stock ... FOR UPDATE` prepare failed with `context deadline
exceeded` at `17:32:15.707491`, immediately at the lazy
checkpoint-consumption boundary.
4. The first reported `20618` at `17:32:55.368` is identified by TN as
`TRANSFER-ERR`, `old-err=ExpectedEOB`, table `273124` (`bmsql_stock`).
Its transaction ID maps back to CN `jndns`.
5. Full-window Loki counts match exactly: all **10,531** CN-side `r-w
conflict` errors came from `jndns`, and TN logged exactly **10,531**
`TRANSFER-ERR/ExpectedEOB` failures for table `273124`.
6. Those failures contain only 13 block-row IDs from seven objects. All
seven are source objects deleted by the same `MT-1299` merge. Their TN
transfer entries had already expired, which is why TN returned
`ExpectedEOB`; a correctly rebuilt post-merge CN partition could not
continue selecting those objects.
7. `task_kill_dn` started at `18:15:10`; the last conflict was at
`18:15:13`. After logtail recovery, `jndns` subscribed `bmsql_stock`
again with a new partition state at `18:16:23`, and the storm
disappeared.

The affected binary cannot emit the iterator error itself: `S3FS.Read`
may return `ctx.Err()` before installing its event logger,
`ObjectIter.Next()` returns that error, and the old loop then discards
it. The observable production signature is consequently false
`subscribe-ok` followed by a partition that still serves objects whose
checkpointed merge deletion was not applied. The deterministic
regression supplies the missing direct function-level proof: with an
expired context, `ObjectIter.Next()` returns `context.DeadlineExceeded`
while the affected `consumeCheckpointWithTableID` returns nil.

### Failure path

1. `ObjectIter.Next()` returns a context/FileService error from
`ioutil.LoadColumnsData`.
2. The old loop exits without returning that error.
3. `Partition.ConsumeCheckpoints` receives nil, publishes the partially
populated copy, and sets `checkpointConsumed=true`.
4. `loadAndConsumeLatestCkp` receives nil and advances the table to
`Subscribed`.
5. The CN serves stale checkpoint objects. Updates using their row IDs
reach TN after the merge transfer entries have expired, and
`txnimpl/table.go` converts `TransferTable.Pin(...)=ExpectedEOB` into
`20618 r-w conflict`.

### Fix

This PR:

- checks every data and tombstone iterator result explicitly and returns
the original error;
- prevents partial checkpoint state from being published or marked
consumed;
- prevents a failed initial load from becoming `Subscribed`, allowing
retry with a fresh context;
- preserves normal EOF, callback-error, and cleanup behavior;
- adds real checkpoint/FileService coverage for successful consumption
and data/tombstone iterator failures.

There is no protocol, storage-format, RPC, locking, or normal-path I/O
change. Legitimate r-w conflicts remain unchanged; this prevents the
incomplete CN state that generated matrixorigin#26210’s pathological conflict storm.

## Testing

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=5m
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10
-timeout=10m -run
'TestConsumeCheckpointWithTableID($|PropagatesIteratorError)'
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m
./pkg/vm/engine/disttae`
- `go vet -mod=readonly ./pkg/vm/engine/tae/logtail`
- `go build -mod=readonly ./pkg/vm/engine/tae/logtail
./pkg/vm/engine/disttae`
- PR CI: UT, race-sensitive package tests, SCA, BVT, and coverage passed

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Remove the obsolete post-merge MOC coverage-status workflow. The
current coverage pipeline is self-contained and no longer creates the
legacy MOC record this workflow expects.
- Stabilize three user-level-lock cleanup tests by asserting durable
terminal state instead of transient asynchronous-worker
ownership/progress, and always reset shared test state on early
assertion exit.
- Add the read-only `mo-pr-radar` skill for deterministic PR review
queues, conflict/CI/approval filters, request-changes freshness, and
per-PR blocker explanations. Its review model uses each reviewer's
latest opinionated review, so a later comment cannot erase an
approval/change request and a later approval clears historical change
requests.
- Strengthen `mo-self-review` with exact affected-test selection,
adaptive per-test race budgets, deterministic flake checks, and one
complete owning-package race run. Zero/under-resolution JSON test
durations safely use the adaptive ceiling.

## Validation

- Confirmed the removed workflow runs only after a merged PR closes, is
not a required check on main or 4.2-dev, and has no repository/Mergify
references.
- PR radar: 22 offline unit tests, Bash syntax checks, both skill
validators, and live GitHub regressions: matrixorigin#25089 remains
`CHANGES_REQUESTED` after a later comment; approved matrixorigin#26233 is absent
from the stale-change queue.
- Adaptive race measurements from `go test -json`, with `B=30s`:
release-cleanup `T=0.07s, N=100`; timed-out cleanup `T=1.06s, N=28`;
successful-probe cleanup `T=0.05s, N=100`.
- Final focused race stress passed for all three exact tests
(`-count=100/28/100`); matching non-race stress also passed.
- Full `pkg/sql/plan/function` owning package passed with `-race
-count=1`.
- `go build` and `go vet` passed for `pkg/sql/plan/function`.
- `git diff --check` passed after merging the latest main.

Fixes matrixorigin#26262.
Related to matrixorigin#26253.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

fixes matrixorigin#26210

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

After `task_kill_cn`, a replacement CN must rebuild table state by
consuming the latest checkpoint before serving the subscription.
`consumeCheckpointWithTableID` stopped its data and tombstone loops when
`ObjectIter.Next()` returned an error, but discarded that error and
returned nil. A context/FileService failure could therefore publish a
partially reconstructed partition and finalize the table as
`Subscribed`.

### Incident evidence for matrixorigin#26210

The production logs pin the reported storm to this failed-reconstruction
shape rather than to ordinary TPCC contention:

1. At `17:25:22–17:25:44 UTC`, TN merge `MT-1299` compacted
`bmsql_stock` and deleted its 18 source objects. The merge committed at
`1785000344282453036-0`.
2. The ICKP covering `17:24:33–17:29:33 UTC` was completed at
`17:31:58`, so it includes that merge deletion. A CN subscribing after
this checkpoint must not serve rows from those source objects as live.
3. Replacement CN `mo-chaos-regression-dis-tp-cn-jndns` received the
`bmsql_stock` subscription response at `17:32:15.660916` and logged
`subscribe-ok` at `17:32:15.705894`. The triggering migrated `SELECT ...
FROM bmsql_stock ... FOR UPDATE` prepare failed with `context deadline
exceeded` at `17:32:15.707491`, immediately at the lazy
checkpoint-consumption boundary.
4. The first reported `20618` at `17:32:55.368` is identified by TN as
`TRANSFER-ERR`, `old-err=ExpectedEOB`, table `273124` (`bmsql_stock`).
Its transaction ID maps back to CN `jndns`.
5. Full-window Loki counts match exactly: all **10,531** CN-side `r-w
conflict` errors came from `jndns`, and TN logged exactly **10,531**
`TRANSFER-ERR/ExpectedEOB` failures for table `273124`.
6. Those failures contain only 13 block-row IDs from seven objects. All
seven are source objects deleted by the same `MT-1299` merge. Their TN
transfer entries had already expired, which is why TN returned
`ExpectedEOB`; a correctly rebuilt post-merge CN partition could not
continue selecting those objects.
7. `task_kill_dn` started at `18:15:10`; the last conflict was at
`18:15:13`. After logtail recovery, `jndns` subscribed `bmsql_stock`
again with a new partition state at `18:16:23`, and the storm
disappeared.

The affected binary cannot emit the iterator error itself: `S3FS.Read`
may return `ctx.Err()` before installing its event logger,
`ObjectIter.Next()` returns that error, and the old loop then discards
it. The observable production signature is consequently false
`subscribe-ok` followed by a partition that still serves objects whose
checkpointed merge deletion was not applied. The deterministic
regression supplies the missing direct function-level proof: with an
expired context, `ObjectIter.Next()` returns `context.DeadlineExceeded`
while the affected `consumeCheckpointWithTableID` returns nil.

### Failure path

1. `ObjectIter.Next()` returns a context/FileService error from
`ioutil.LoadColumnsData`.
2. The old loop exits without returning that error.
3. `Partition.ConsumeCheckpoints` receives nil, publishes the partially
populated copy, and sets `checkpointConsumed=true`.
4. `loadAndConsumeLatestCkp` receives nil and advances the table to
`Subscribed`.
5. The CN serves stale checkpoint objects. Updates using their row IDs
reach TN after the merge transfer entries have expired, and
`txnimpl/table.go` converts `TransferTable.Pin(...)=ExpectedEOB` into
`20618 r-w conflict`.

### Fix

This PR:

- checks every data and tombstone iterator result explicitly and returns
the original error;
- prevents partial checkpoint state from being published or marked
consumed;
- prevents a failed initial load from becoming `Subscribed`, allowing
retry with a fresh context;
- preserves normal EOF, callback-error, and cleanup behavior;
- adds real checkpoint/FileService coverage for successful consumption
and data/tombstone iterator failures.

There is no protocol, storage-format, RPC, locking, or normal-path I/O
change. Legitimate r-w conflicts remain unchanged; this prevents the
incomplete CN state that generated matrixorigin#26210’s pathological conflict storm.

## Testing

- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=5m
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10
-timeout=10m -run
'TestConsumeCheckpointWithTableID($|PropagatesIteratorError)'
./pkg/vm/engine/tae/logtail`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=10m
./pkg/vm/engine/disttae`
- `go vet -mod=readonly ./pkg/vm/engine/tae/logtail`
- `go build -mod=readonly ./pkg/vm/engine/tae/logtail
./pkg/vm/engine/disttae`
- PR CI: UT, race-sensitive package tests, SCA, BVT, and coverage passed

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

- Remove the obsolete post-merge MOC coverage-status workflow. The
current coverage pipeline is self-contained and no longer creates the
legacy MOC record this workflow expects.
- Stabilize three user-level-lock cleanup tests by asserting durable
terminal state instead of transient asynchronous-worker
ownership/progress, and always reset shared test state on early
assertion exit.
- Add the read-only `mo-pr-radar` skill for deterministic PR review
queues, conflict/CI/approval filters, request-changes freshness, and
per-PR blocker explanations. Its review model uses each reviewer's
latest opinionated review, so a later comment cannot erase an
approval/change request and a later approval clears historical change
requests.
- Strengthen `mo-self-review` with exact affected-test selection,
adaptive per-test race budgets, deterministic flake checks, and one
complete owning-package race run. Zero/under-resolution JSON test
durations safely use the adaptive ceiling.

## Validation

- Confirmed the removed workflow runs only after a merged PR closes, is
not a required check on main or 4.2-dev, and has no repository/Mergify
references.
- PR radar: 22 offline unit tests, Bash syntax checks, both skill
validators, and live GitHub regressions: matrixorigin#25089 remains
`CHANGES_REQUESTED` after a later comment; approved matrixorigin#26233 is absent
from the stale-change queue.
- Adaptive race measurements from `go test -json`, with `B=30s`:
release-cleanup `T=0.07s, N=100`; timed-out cleanup `T=1.06s, N=28`;
successful-probe cleanup `T=0.05s, N=100`.
- Final focused race stress passed for all three exact tests
(`-count=100/28/100`); matching non-race stress also passed.
- Full `pkg/sql/plan/function` owning package passed with `-race
-count=1`.
- `go build` and `go vet` passed for `pkg/sql/plan/function`.
- `git diff --check` passed after merging the latest main.

Fixes matrixorigin#26262.
Related to matrixorigin#26253.

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] Chaos (90e3400): TPCC New-Order 20618 r-w conflict storm (~10.5k / ~43min) right after task_kill_cn

3 participants