Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Wed, 27 May 2026 06:25:58 +0000 Subject: [pgjdbc/pgjdbc] PR #4116: test: budget terminating Sync in BatchDeadlockTest small-RETURNING branch List-Id: X-GitHub-Author-Id: 213894 X-GitHub-Author-Login: vlsi X-GitHub-Issue: 4116 X-GitHub-Labels: building-and-testing X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/pull/4116 Content-Type: text/plain; charset=utf-8 ## Summary - `BatchDeadlockTest.largePreparedBatchWithGeneratedKeysDoesNotDeadlock` for parameter `[6]` (`ReturningInQuery.ID` + `BinaryMode.FORCE`) intermittently fails with `expected: but was: ` for the Sync count. - Root cause is an off-by-one in the test bound, not a driver regression. `flushIfDeadlockRisk` ([`QueryExecutorImpl#L1650`](../blob/master/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java#L1650)) fires a Sync per mid-batch flush, and pgjdbc always sends one extra terminating Sync at the end of the batch. The formula `BATCH_SIZE * 250 * 2 / 64000 = 3` accounted only for the mid-batch flushes, so an observed `Sync=4` (3 + terminator) tripped `syncs <= 3`. ## What changed - Single `expectedSyncs = expectedRoundtrips + 1` budget for both Sync and roundtrip assertions. - Diagnostic messages now include the bound (`expected at most N Syncs, got …`) so future failures show why the bound was set. - Still catches Sync-per-row regressions: the small-RETURNING budget is `~3`, far below `BATCH_SIZE = 500`. ## Test plan - [x] `./gradlew :postgresql:test --tests "org.postgresql.test.jdbc2.BatchDeadlockTest"` x3 — 16 passed, 8 skipped (simple query mode), stable across reruns. Spotted while triaging an unrelated CI failure on https://github.com/pgjdbc/pgjdbc/actions/runs/26447208462/job/77856581962. 🤖 Generated with [Claude Code](https://claude.com/claude-code)