Skip to content

test(postgres): make cancelled BEGIN regression deterministic - #4425

Open
shuvroroy wants to merge 1 commit into
transact-rs:mainfrom
shuvroroy:test/postgres-cancel-begin-4423
Open

shuvroroy wants to merge 1 commit into
transact-rs:mainfrom
shuvroroy:test/postgres-cancel-begin-4423

Conversation

@shuvroroy

Copy link
Copy Markdown
Contributor

Cancelling Pool::begin_with after PostgreSQL executes BEGIN must roll back before the backend is reused. The driver fix is already on main via #4394; this PR replaces its sleep-based regression test with the deterministic advisory-lock reproduction from #4423.

The test waits until pg_stat_activity confirms the backend is blocked after BEGIN, drops the pending future, and releases the lock. It then verifies that the same backend returns idle and that a subsequent pooled write survives a later transaction rollback. The synchronization works across supported runtimes without spawning a task.

Does your PR solve an issue?

Fixes #4423 by verifying the existing driver fix with the reported reproduction and strengthening regression coverage.

Is this a breaking change?

No. This only changes the PostgreSQL integration test.

Validation

Tested with PostgreSQL 17.11 and Rust 1.94.1:

  • cargo test --no-default-features --features postgres,macros,runtime-tokio --test postgres --test postgres-error -- --skip test_pg_copy_chunked: 63 passed, 2 already ignored; the large COPY test is run separately by CI.
  • The focused regression passes with Tokio, Smol, async-global-executor, and async-std.
  • Temporarily restoring the pre-fix(postgres): roll back a transaction cancelled during BEGIN聽#4394 transaction-depth accounting makes the regression fail with idle in transaction instead of idle; restoring the existing fix makes it pass.
  • cargo fmt --all -- --check passes.
  • cargo clippy --no-default-features --features postgres,macros,runtime-tokio -- -D warnings passes.

Strict Clippy checks including --test postgres encounter existing warnings in sqlx-test/src/lib.rs and unchanged portions of tests/postgres/postgres.rs.

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.

PostgreSQL: cancelling Pool::begin_with can return an open transaction to the pool (0.9.0)

1 participant