Repository navigation
fix(txn): finalize unknown commits without rollback GC - #25582
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the unknown-commit state machine end to end: remote send classification, operator finalization and locking, frontend handle invalidation, disttae/CCPR/clone cleanup, object-GC exclusion, direct later rollback, resource bounds, and production call sites. I found no blocking correctness, robustness, leak/hang/OOM, compatibility, or performance issue.
The safety boundary is sound for this PR: an ambiguous Commit never runs object GC; CN-local batches, caches, pools, clone tracking, segment tracking, and quota are released; the operator is closed and removed; the frontend handle is invalidated; and a retained direct handle cannot later run destructive workspace rollback. The declared durable orphan-object cleanup and unused multi-request WriteAndCommit path are real follow-up gaps, but they do not invalidate this immediate data-safety/CN-resource fix.
Non-blocking: the new comment in pkg/frontend/txn.go above invalidateTxnUnsafe() says that "retaining it lets later rollback/connection cleanup reach destructive cleanup", while the implementation intentionally invalidates the handle to prevent that behavior. Please reword it to match the new invariant.
Local validation passed: full tests for pkg/txn/rpc, pkg/txn/client, pkg/frontend, and pkg/vm/engine/disttae; race tests for txn/rpc+client and the frontend/disttae unknown paths; repeated deadline/finalization tests; go vet; and git diff --check. CI is fully green.
…25582) ## Summary - make ErrTxnUnknown a terminal, non-destructive workspace finalization path - classify every single-request Commit response/transport failure, including context deadline, as ErrTxnUnknown - release CN-local batches, caches, worker pools, clone tracking, and workspace quota through delTransaction - atomically fence any later Rollback from running workspace object GC - invalidate the frontend transaction handle after returning ErrTxnUnknown - keep the transaction outcome unknown instead of rewriting it to Aborted ## Safety invariant A missing Commit response does not prove abort. This PR never deletes transaction objects on the unknown path because TN may already have committed metadata that references them. ## Known remaining gaps If TN actually aborted and never checkpointed a CN-created object, existing TN checkpoint GC cannot discover it. Such objects can remain indefinitely and accumulate until a durable unknown-object candidate manifest and TN consumer are implemented. This PR is the immediate data-safety and CN-resource fix, not complete orphan-object lifecycle closure. The multi-request WriteAndCommit sender path does not yet classify every response failure as unknown. No production caller was found. Fixing that API safely needs stream-generation or in-flight fencing so a late response cannot be delivered after a pooled stream is reused. ## Tests - full pkg/txn/rpc, pkg/txn/client, pkg/frontend, and pkg/vm/engine/disttae - repeated Commit deadline and EOF/reset classification tests - race tests for response-deadline classification and unknown finalization followed by direct rollback Fixes matrixorigin#25198
…25582) ## Summary - make ErrTxnUnknown a terminal, non-destructive workspace finalization path - classify every single-request Commit response/transport failure, including context deadline, as ErrTxnUnknown - release CN-local batches, caches, worker pools, clone tracking, and workspace quota through delTransaction - atomically fence any later Rollback from running workspace object GC - invalidate the frontend transaction handle after returning ErrTxnUnknown - keep the transaction outcome unknown instead of rewriting it to Aborted ## Safety invariant A missing Commit response does not prove abort. This PR never deletes transaction objects on the unknown path because TN may already have committed metadata that references them. ## Known remaining gaps If TN actually aborted and never checkpointed a CN-created object, existing TN checkpoint GC cannot discover it. Such objects can remain indefinitely and accumulate until a durable unknown-object candidate manifest and TN consumer are implemented. This PR is the immediate data-safety and CN-resource fix, not complete orphan-object lifecycle closure. The multi-request WriteAndCommit sender path does not yet classify every response failure as unknown. No production caller was found. Fixing that API safely needs stream-generation or in-flight fencing so a late response cannot be delivered after a pooled stream is reused. ## Tests - full pkg/txn/rpc, pkg/txn/client, pkg/frontend, and pkg/vm/engine/disttae - repeated Commit deadline and EOF/reset classification tests - race tests for response-deadline classification and unknown finalization followed by direct rollback Fixes matrixorigin#25198
…25582) ## Summary - make ErrTxnUnknown a terminal, non-destructive workspace finalization path - classify every single-request Commit response/transport failure, including context deadline, as ErrTxnUnknown - release CN-local batches, caches, worker pools, clone tracking, and workspace quota through delTransaction - atomically fence any later Rollback from running workspace object GC - invalidate the frontend transaction handle after returning ErrTxnUnknown - keep the transaction outcome unknown instead of rewriting it to Aborted ## Safety invariant A missing Commit response does not prove abort. This PR never deletes transaction objects on the unknown path because TN may already have committed metadata that references them. ## Known remaining gaps If TN actually aborted and never checkpointed a CN-created object, existing TN checkpoint GC cannot discover it. Such objects can remain indefinitely and accumulate until a durable unknown-object candidate manifest and TN consumer are implemented. This PR is the immediate data-safety and CN-resource fix, not complete orphan-object lifecycle closure. The multi-request WriteAndCommit sender path does not yet classify every response failure as unknown. No production caller was found. Fixing that API safely needs stream-generation or in-flight fencing so a late response cannot be delivered after a pooled stream is reused. ## Tests - full pkg/txn/rpc, pkg/txn/client, pkg/frontend, and pkg/vm/engine/disttae - repeated Commit deadline and EOF/reset classification tests - race tests for response-deadline classification and unknown finalization followed by direct rollback Fixes matrixorigin#25198
Summary
Safety invariant
A missing Commit response does not prove abort. This PR never deletes transaction objects on the unknown path because TN may already have committed metadata that references them.
Known remaining gaps
If TN actually aborted and never checkpointed a CN-created object, existing TN checkpoint GC cannot discover it. Such objects can remain indefinitely and accumulate until a durable unknown-object candidate manifest and TN consumer are implemented. This PR is the immediate data-safety and CN-resource fix, not complete orphan-object lifecycle closure.
The multi-request WriteAndCommit sender path does not yet classify every response failure as unknown. No production caller was found. Fixing that API safely needs stream-generation or in-flight fencing so a late response cannot be delivered after a pooled stream is reused.
Tests
Fixes #25198