refactor(admin): cancel_tx / cancel_by_unique_key_tx take &mut PgConnection (0.6.0-rc.3)#358
Conversation
…ection (0.6.0-rc.3) The rc.2 transaction-participating cancel APIs took &mut sqlx::Transaction, but that excludes callers that only hold a connection mid-transaction (e.g. behind a transact!-style helper that derefs the transaction to &mut PgConnection). Switch to &mut PgConnection: a &mut Transaction deref-coerces to it, so existing callers are unaffected, and it matches awa's existing multi-statement consumer convention (insert_many_copy). Internally the public wrappers open a nested transaction (conn.begin(), a SAVEPOINT when the connection is already in one) and delegate to the unchanged &mut Transaction-based cancel_in_tx / cancel_by_unique_key_in_tx, so a cancel error rolls back only the cancel rather than poisoning the caller's transaction. The integration test now exercises both a Transaction caller and a bare &mut PgConnection caller. Bumps the workspace to 0.6.0-rc.3.
|
Warning Review limit reached
More reviews will be available in 57 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
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 |
cancel_tx/cancel_by_unique_key_tx→&mut PgConnectionCorrects the rc.2 transaction-participating cancel API. rc.2 typed these as
&mut sqlx::Transaction, which excludes callers that only hold a connection mid-transaction — e.g. behind atransact!-style helper that derefs the transaction to&mut PgConnection(exactly the downstream consumer's situation).Change
cancel_tx/cancel_by_unique_key_txnow take&mut PgConnection. A&mut Transactionderef-coerces to it, so existing callers are unaffected; connection-only callers now work too. This matches awa's existing multi-statement consumer convention (insert_many_copy, which takes&mut PgConnection"so callers can use pool connections or transactions").conn.begin()→ aSAVEPOINTwhen the connection is already in one) and delegate to the unchanged&mut Transaction-basedcancel_in_tx/cancel_by_unique_key_in_tx, so a cancel error rolls back only the cancel rather than poisoning the caller's transaction.Transactioncaller (deref coercion) and a bare&mut PgConnectioncaller.Why this over the alternatives
&mut Transaction(rc.2): excludes connection-only callers.impl Acquire: would unify pool+conn+tx into one fn, but adds generics/lifetimes and isn't a style awa uses anywhere; thecancel(pool)+_tx(conn)split already covers the cases.impl PgExecutor: unsafe for a multi-statement atomic op (a&Poolexecutor may use a different connection per statement).&mut PgConnectionis the superset that fits every consumer and is consistent withinsert_many_copy.Verification
fmt/clippy --all-targets --all-features -- -D warnings/build: clean.cargo test --test integration_test cancel: 10/10.AwaSegmentedStorage: No error has been found.Cuts 0.6.0-rc.3.