Repository navigation
Fix LogService required LSN and WAL recovery across failover - #32330
mergify[bot] merged 20 commits into
Conversation
Recover LogService LSN operations from isolated established connections, bound WAL-only proposals, retry background truncation, and persist checkpointed DSN with physical WAL truncation. Addresses matrixorigin#32320, matrixorigin#32316, matrixorigin#32304, matrixorigin#32248, matrixorigin#32246, and matrixorigin#32240.
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? |
Preserve matrixorigin#32149 truncation bounds for the new WAL command and align WAL watermark retries with the upstream cancellation budget.
|
mo-bot review · Commit: PR changed before dispatch |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head c8d1bfffdc1c5151a31b3f930147a837303ac0fe against main base de2790be20948f9d99cb833ddbbaa8a792b7a2ac.
Request changes for one confirmed process-crash regression:
- [P0]
pkg/datasync/log_client.go:258— Add a deadline before querying the ownership leader state. The production consumer runs throughsyncer.start→Stopper.RunNamedTask, whose context comes fromcontext.WithCancel(context.Background()). Once shard 3 is led locally,consumer.Startpasses that deadline-free context intoclaimRequiredLsn. This call toGetLeaderStateforwards it unchanged throughmanagedClient→client.request→ MORPC.Future.init(pkg/common/morpc/future.go:76–77) unconditionally panics withcontext deadline not setfor this ordinary unary request. The stopper goroutine does not recover, so enabling standby DataSync terminates the LogService process when the consumer first claims ownership. Wrap the leader-state query in the existingcontextTimeoutchild context, asgetLeaderIDalready does, and cover a cancel-only parent with the real client. The new consumer test mocks this RPC, while the real-client required-LSN test supplies an explicit deadline, so neither exercises this production input.
All three previous findings were checked against the current code and are addressed: legacy snapshot/replay revisions now agree, ownership conflicts restart the consumer without cleanup, and shutdown cancellation reaches the production TN → TAE → WAL client factory. The author explicitly replied to each: snapshot revision, ownership restart, factory cancellation. These resolved findings are not counted again.
Validation: inspected the complete 33-file diff and relevant callers; checked protobuf descriptor compatibility and ran the read-only PR artifact check successfully. Local package/cluster tests were not rerun: the new finding follows the explicit panic condition on the traced production path; existing exact-head CI evidence was reused. No runtime reproduction is claimed. Documentation checks are inapplicable because no documentation changed. Repairing old shards already truncated without an authenticated checkpoint boundary remains outside the recorded scope.
The supplied CI snapshot contains 37 checks: 21 success, 14 skipped, 2 neutral. None failed or remain pending, but they are not all successful. Exact-head workflow results.
|
mo-bot review · Commit: Review discussion changed before publication; a fresh contextual review is queued. |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head 97364e7e43a661012c5ea2c252e71af711be3c0c against main base 11d2e1ef7e1b3ed3a20e6d7f29f912e55118db5b.
Approve. No confirmed in-scope findings remain.
All four previous findings are addressed in the current code and have explicit author replies: legacy snapshot revisions, ownership-loss restart, production factory cancellation, and leader-state RPC deadline. The latest fix supplies a timeout before GetLeaderState; the real-client TestRequiredLsn now exercises ownership claiming with a cancel-only parent. The remaining ownership RPCs create bounded attempt contexts in the managed client.
Validation: inspected the complete 33-file diff, relevant production callers, regression tests, and the Dragonboat production dependency delta. Exact-SHA source comparisons, protobuf descriptor/schema compatibility checks, git diff --check, and the read-only PR artifact check passed. Local package, race, and cluster tests were not rerun; supplied CI results and the author's reported package/race validation were reviewed, without claiming an independent runtime reproduction.
The supplied CI snapshot has 37 checks: 21 success, 14 skipped, and 2 neutral. None failed or remain pending, but they are not all successful. Current-head workflow results.
Documentation-specific checks were skipped because no documentation changed. Repairing older WAL shards already truncated without an authenticated checkpoint boundary remains outside the recorded scope.
|
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: 97364e7e43a661012c5ea2c252e71af711be3c0c
Assessment: request_changes
One P2 regression remains: read-only clients can invoke WAL truncation. The durable ownership/checkpoint state is justified within the existing RSM/WAL owners, and the four earlier findings are resolved. This new API-contract evidence changes the supplied same-head approval.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
- P2
pkg/logservice/client.go:871: Create a client with ClientConfig.ReadOnly=true and call TruncateWAL with an otherwise valid advancing PSN/checkpointed-DSN pair.
Impact: The call can advance durable TruncatedLsn and CheckpointedDSN from a read-only handle instead of returning ErrInvalidInput, bypassing the restriction enforced by Truncate.
Evidence: client.truncate checks readOnly() at client.go:808, but managedClient.TruncateWAL and client.truncateWAL send the new mutation without that guard. service.go:585 and store.go:987 forward it to rsm.go:317, which accepts a valid boundary. The unchanged TestReadOnlyClientRejectWriteRequests at client_test.go:978 covers only Append and Truncate. Add the same read-only guard before the RPC and extend that regression to verify rejection and unchanged truncation state. Source trace: readonly-truncate-trace.json.
Validation:
-
Completed source review, nine linked issues and all 21 discussion entries; discussion-assessment.json accounts for every key once.
-
Reused frozen exact-head CI: 21 successful, 14 skipped and 2 neutral checks, plus attributed author owning-package and focused race reports.
-
Dependency checksum audit and protobuf/source audit passed; released snapshot fields were preserved. Receipts: checks/1794296526023256034-3.json and checks/1794296833661897720-3.json.
-
git diff --check and gofmt -l on all 30 changed Go files passed. Receipts: checks/1794297247553356411-3.json and checks/1794297247809584168-3.json.
-
Final source, discussion and receipt/log reconciliation passed; checkout unchanged. Receipt: checks/1794297552664678627-3.json; retained validation-ledger.json.
Limitations:
-
No fresh local Go, race or live failover execution; raw author test logs were unavailable. The read-only finding is established by source tracing, without an integrated reproduction.
-
Already-stranded old-format WAL without checkpoint proof remains the explicitly accepted recovery limit.
|
Addressed the latest read-only TruncateWAL change request in 010a4fd (current head a1d12c6). The client now returns ErrInvalidInput before the RPC. TestReadOnlyClientRejectWriteRequests uses a writable peer to create a valid advancing PSN, then verifies the read-only call is rejected and the durable PSN/DSN is unchanged. Full pkg/logservice tests passed, and the focused regression passed again after merging the latest main. |
|
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: a1d12c6d8661d02085aea6c53d0699fd485a6922
Assessment: approve
All five prior findings are resolved, including read-only WAL truncation. The fencing and checkpoint metadata extend existing recovery owners with justified, bounded state. No actionable correctness or design issue remains.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all 33 changed files, affected consumers, nine linked issues and all 24 discussion entries; reconciliation retained in discussion-assessment.json.
-
Receipt-backed schema, codec-source, gofmt and diff checks passed. Source remains unchanged.
-
Reused frozen-head CI: 21 successful, 14 skipped and 2 neutral checks, including successful UT and multi-CN BVT. Verified unchanged inputs before reusing prior analysis.
Limitations:
-
No local Go/race/cluster tests rerun; author-reported package and race results lack supplied raw logs.
-
Legacy WAL already truncated without a checkpoint boundary remains fail-closed, consistent with the disclosed Addresses #32240 scope.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32320
Fixes #32316
Fixes #32304
Fixes #32248
Fixes #32246
Fixes #32329
Fixes #32322
Addresses #32240
Related to #32133
What this PR does / why we need it:
TruncateWALfrom read-only LogService clients before sending an RPC, preserving the durable PSN/DSN boundary.matrixorigin/dragonboattransport fix for forwarded proposals. No personal Dragonboat fork is used.Validation
After merging upstream
mainatde2790be2094, the full test suites passed forpkg/logservice,pkg/datasync,pkg/tnservice,pkg/vm/engine/tae/db,pkg/vm/engine/tae/logstore/driver/logservicedriver, andpkg/vm/engine/tae/logstore/wal. Focused race tests passed for DataSync ownership reclaim and WAL driver in-flight client cancellation. The fullpkg/datasyncsuite passed after the next main merge. The fullpkg/logservicesuite passed with the read-only fix; its real-client regression also passed after mergingmainat0c8bd5e5f3. MatrixOne CI is running on heada1d12c6d86.Remaining limit
An older WAL shard already physically truncated without a persisted checkpointed-DSN boundary has no authenticated proof for an interior gap. Replay keeps failing closed; repairing such old-format shards needs separate authenticated checkpoint metadata. This is why #32240 is linked as “Addresses” rather than auto-closed.