Repository navigation
fix(disttae): fence latest logtail reads with pending table apply - #25649
Merged
XuPeng-SH merged 1 commit intoJul 13, 2026
Merged
Conversation
…trixorigin#25515) ## 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#25232 ## What this PR does / why we need it: When a CN receives a logtail update response, the global logtail timestamp can advance before every table logtail in that response has been applied to its latest `PartitionState`. The latest subscribed table state can still have a `[start, MaxTs]` serving range, so checking only `CanServe(snapshot)` can let a read use a table state that has not applied updates below `snapshot.Prev()`. In a cross-table consistency check, this can expose one updated table and one stale table from the same committed transaction. This PR fences that latest-state fast path: - tracks a per-table `appliedTo` watermark in `PartitionState` - marks subscribed tables as pending when an update response contains their logtail - clears the pending mark only after that table logtail has been consumed - makes `txnTable.getPartitionState` wait for the latest table state to apply through `snapshot.Prev()` when that table has a known pending update - preserves the original fast path when there is no pending update, and preserves snapshot checkpoint fallback when the latest state truly cannot serve the snapshot Validation: - `git diff --check base/main...HEAD` - `go test -v -count=1 -run 'TestCanServeTableSnapshotBlocksPendingUpdate|TestWaitCanServeTableSnapshotWaitsForPendingUpdate|TestDispatchUpdateResponseAdvancesTimestampAfterLastLogtail|TestDispatchUpdateResponseCoalescesTimestampCommands' ./pkg/vm/engine/disttae` - `go test -race -v -count=1 -run 'TestCanServeTableSnapshotBlocksPendingUpdate|TestWaitCanServeTableSnapshotWaitsForPendingUpdate|TestDispatchUpdateResponseAdvancesTimestampAfterLastLogtail|TestDispatchUpdateResponseCoalescesTimestampCommands' ./pkg/vm/engine/disttae` - verified on a 2-CN dev cluster with temporary fault-injection hooks that force the global logtail timestamp to advance before table apply; 3 runs all hit the new pending-table wait path and returned consistent `20/20` counts Note: full `./pkg/vm/engine/disttae` package test was also attempted locally, but the sandbox cannot bind the unix socket used by `TestWaitServerReady/ok` (`operation not permitted`), so it timed out on that unrelated test. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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? |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25232
What this PR does / why we need it:
When a CN receives a logtail update response, the global logtail timestamp can advance before every table logtail in that response has been applied to its latest
PartitionState. The latest subscribed table state can still have a[start, MaxTs]serving range, so checking onlyCanServe(snapshot)can let a read use a table state that has not applied updates belowsnapshot.Prev(). In a cross-table consistency check, this can expose one updated table and one stale table from the same committed transaction.This PR fences that latest-state fast path:
appliedTowatermark inPartitionStatetxnTable.getPartitionStatewait for the latest table state to apply throughsnapshot.Prev()when that table has a known pending updateValidation:
git diff --check base/main...HEADgo test -v -count=1 -run 'TestCanServeTableSnapshotBlocksPendingUpdate|TestWaitCanServeTableSnapshotWaitsForPendingUpdate|TestDispatchUpdateResponseAdvancesTimestampAfterLastLogtail|TestDispatchUpdateResponseCoalescesTimestampCommands' ./pkg/vm/engine/disttaego test -race -v -count=1 -run 'TestCanServeTableSnapshotBlocksPendingUpdate|TestWaitCanServeTableSnapshotWaitsForPendingUpdate|TestDispatchUpdateResponseAdvancesTimestampAfterLastLogtail|TestDispatchUpdateResponseCoalescesTimestampCommands' ./pkg/vm/engine/disttae20/20countsNote: full
./pkg/vm/engine/disttaepackage test was also attempted locally, but the sandbox cannot bind the unix socket used byTestWaitServerReady/ok(operation not permitted), so it timed out on that unrelated test.