Repository navigation
fix(client): enforce transaction state guard on timeout rollback to guarantee atomicity - #29769
namdamdoi68-oss wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/driver-adapter-utils/src/binder.ts`:
- Around line 116-130: Serialize transaction finalization with adapter dispatch
around checkClosed, markClosed, and `#closeTransaction`: allow the internal
COMMIT/ROLLBACK executeRaw flow to complete, but reject or roll back user
statements once finalization begins, including statements that passed
checkClosed before dispatch was delayed. Ensure transaction closure state is
coordinated at adapter dispatch rather than only when transaction.commit() or
transaction.rollback() invokes markClosed().
- Around line 138-141: Update the transaction binder alongside queryRaw,
executeRaw, commit, and rollback to wrap createSavepoint, rollbackToSavepoint,
and releaseSavepoint with checkClosed before wrapAsync. Preserve their existing
operation behavior while ensuring each savepoint method rejects calls after the
transaction is closed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 75267d7c-7be8-45ad-b5f4-5bc9d5055a5d
📒 Files selected for processing (1)
packages/driver-adapter-utils/src/binder.ts
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/driver-adapter-utils/src/binder.ts (1)
116-141: 🗄️ Data Integrity & Integration | 🟠 MajorThe closure guard still does not serialize in-flight dispatch.
A query can pass
checkClosed()whileisClosedisfalse, then be delayed before adapter dispatch.rollback()setsisClosed = trueand sends the rollback concurrently, but the previously admitted query is not cancelled or ordered behind that rollback. It can therefore execute after rollback and persist writes despite the client receivingP2028.Coordinate closure with the adapter dispatch queue/barrier so rollback or commit excludes all pending user statements, not only calls that begin afterward.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/driver-adapter-utils/src/binder.ts` around lines 116 - 141, The transaction wrappers around checkClosed, markClosed, queryRaw, and executeRaw must serialize in-flight dispatch with commit/rollback. Replace the isClosed-only guard with an adapter dispatch queue or barrier that admits statements in order, prevents commit/rollback from running until previously admitted statements finish, and rejects statements arriving after closure; ensure closure is set atomically with the barrier so no pending query can dispatch after commit or rollback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@packages/driver-adapter-utils/src/binder.ts`:
- Around line 116-141: The transaction wrappers around checkClosed, markClosed,
queryRaw, and executeRaw must serialize in-flight dispatch with commit/rollback.
Replace the isClosed-only guard with an adapter dispatch queue or barrier that
admits statements in order, prevents commit/rollback from running until
previously admitted statements finish, and rejects statements arriving after
closure; ensure closure is set atomically with the barrier so no pending query
can dispatch after commit or rollback.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 108e0780-09ab-457e-a881-cdb7a3f06cfd
📒 Files selected for processing (1)
packages/driver-adapter-utils/src/binder.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/driver-adapter-utils/src/binder.ts`:
- Around line 121-128: Update both TransactionAlreadyClosed throws in the binder
transaction flow to include the required cause string with a stable message.
Preserve the existing kind value and ensure both the immediate check and the
dispatchQueue callback produce the same complete error payload for wrapAsync
consumers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 76868b7c-275c-4cea-ae78-1b707b4f71d0
📒 Files selected for processing (1)
packages/driver-adapter-utils/src/binder.ts
…serialization Prevent post-rollback query dispatch by guarding transaction execution state and serializing dispatch queue in bindTransaction. Signed-off-by: namdamdoi68-oss <namdamdoi68@gmail.com>
d0894eb to
2577dcc
Compare
Enforce transaction execution state guard and serialize adapter dispatch queue in
bindTransactionto prevent post-rollback query dispatch during timeout events.Closes #29762