Skip to content

fix(txn): finalize unknown commits without rollback GC - #25582

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/25198-unknown-commit-finalization
Jul 10, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
aptend:fix/25198-unknown-commit-finalization

Conversation

@aptend

@aptend aptend commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

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 #25198

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

@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 10, 2026

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

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.

@XuPeng-SH
XuPeng-SH merged commit 5b60307 into matrixorigin:main Jul 10, 2026
23 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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

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

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CN transaction: permanent workspace/offheap memory leak in FinalizeCommitWithUnknownResult

3 participants