Skip to content

refactor(admin): cancel_tx / cancel_by_unique_key_tx take &mut PgConnection (0.6.0-rc.3)#358

Merged
hardbyte merged 2 commits into
mainfrom
feat/cancel-tx-pgconnection-rc3
Jun 25, 2026
Merged

refactor(admin): cancel_tx / cancel_by_unique_key_tx take &mut PgConnection (0.6.0-rc.3)#358
hardbyte merged 2 commits into
mainfrom
feat/cancel-tx-pgconnection-rc3

Conversation

@hardbyte

Copy link
Copy Markdown
Owner

cancel_tx / cancel_by_unique_key_tx&mut PgConnection

Corrects 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 a transact!-style helper that derefs the transaction to &mut PgConnection (exactly the downstream consumer's situation).

Change

  • cancel_tx / cancel_by_unique_key_tx now take &mut PgConnection. A &mut Transaction deref-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").
  • The public fns 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.
  • Test exercises both a Transaction caller (deref coercion) and a bare &mut PgConnection caller.

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; the cancel(pool) + _tx(conn) split already covers the cases.
  • impl PgExecutor: unsafe for a multi-statement atomic op (a &Pool executor may use a different connection per statement).
  • &mut PgConnection is the superset that fits every consumer and is consistent with insert_many_copy.

Verification

  • fmt / clippy --all-targets --all-features -- -D warnings / build: clean.
  • cargo test --test integration_test cancel: 10/10.
  • TLA+ AwaSegmentedStorage: No error has been found.

Cuts 0.6.0-rc.3.

hardbyte added 2 commits June 25, 2026 16:46
…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.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@hardbyte, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b439fb17-2906-4b03-862d-4d984635b713

📥 Commits

Reviewing files that changed from the base of the PR and between 862b3e1 and a361dc5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • CHANGELOG.md
  • Cargo.toml
  • awa-cli/Cargo.toml
  • awa-cli/pyproject.toml
  • awa-model/src/admin.rs
  • awa-python/Cargo.toml
  • awa-python/pyproject.toml
  • awa-seaorm/Cargo.toml
  • awa/Cargo.toml
  • awa/tests/integration_test.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hardbyte hardbyte merged commit 7b568c9 into main Jun 25, 2026
23 checks passed
@hardbyte hardbyte deleted the feat/cancel-tx-pgconnection-rc3 branch June 25, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant