Skip to content

fix(#6543): recognize ROLLBACK over the Postgres extended-query protocol - #6546

Merged
robfrank merged 4 commits into
mainfrom
fix/6543-postgres-extended-protocol-rollback
Aug 21, 2026
Merged

robfrank merged 4 commits into
mainfrom
fix/6543-postgres-extended-protocol-rollback

Conversation

@robfrank

@robfrank robfrank commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Closes #6543

Over the Postgres extended query protocol (Parse/Bind/Execute), PostgresNetworkExecutor.parseCommand()'s
dispatch that tracks explicit-transaction state (explicitTransactionStarted) recognized only
BEGIN/BEGIN TRANSACTION and COMMIT. There was no ROLLBACK branch, and worse,
sqlEngine.parse() was called unconditionally before that dispatch ever ran. A bare ROLLBACK sent as its
own Parse/Bind/Execute (as opposed to the simple-query protocol fixed in #6457/#6542) therefore fell through,
parsed successfully as ArcadeDB SQL's own RollbackStatement (whose executeSimple() does call
database.rollback()), but left explicitTransactionStarted set. Since writeReadyForQueryMessage() reports
status 'T' whenever that flag is set, and syncCommand()'s implicit-commit branch only runs once the flag is
clear, the wire-level session stayed reported as "inside an explicit transaction" forever after the ROLLBACK.

The fix:

  • Adds a ROLLBACK branch to the Parse dispatch, alongside the existing BEGIN/COMMIT handling. Unlike
    COMMIT (which can lean on syncCommand()'s implicit-commit branch simply by clearing the flag), ROLLBACK
    calls database.rollback() directly and then clears the flag - clearing it first, without rolling back, would
    make the next Sync commit the transaction instead, the opposite of what the client asked for.
  • Moves the BEGIN/COMMIT/ROLLBACK check ahead of sqlEngine.parse() entirely, the same ordering
    queryCommand()'s simple-query dispatch already uses. This turned out to be necessary, not cosmetic: ArcadeDB
    SQL's beginStatement/commitStatement/rollbackStatement grammar productions accept only the bare keyword
    (plus BEGIN's own ISOLATION clause and COMMIT's own RETRY clause), so sqlEngine.parse("ROLLBACK WORK", ...)
    or sqlEngine.parse("BEGIN TRANSACTION", ...) throws a syntax error. With the unconditional parse still in
    place, widening isCommitStatement/isRollbackStatement to recognize those forms (see below) would have made
    a ROLLBACK WORK reach a CommandParsingException instead of silently falling through - confirmed by a
    regression run before this reordering was added (see "Also worth covering" below).
  • Also folds in the issue's secondary ask: isCommitStatement/isRollbackStatement now recognize the
    SQL-standard COMMIT WORK/ROLLBACK WORK/END WORK forms alongside the bare and ... TRANSACTION forms
    already handled. Since the extended-protocol COMMIT branch previously matched only the exact literal "COMMIT"
    (narrower than the simple-query protocol's isCommitStatement), it now uses the same helper as ROLLBACK,
    so COMMIT TRANSACTION/END/END TRANSACTION/END WORK are recognized there too - matching the simple-query
    protocol's coverage rather than adding new scope.
  • Adds a matching isBeginStatement helper (BEGIN/BEGIN TRANSACTION/BEGIN WORK) and uses it in both
    queryCommand() and parseCommand() in place of the ad hoc literal checks each previously had, per review
    feedback: PostgreSQL's own grammar is BEGIN [ WORK | TRANSACTION ], so BEGIN WORK is a real form a client
    can send, and it now gets the same three-way recognition as COMMIT/ROLLBACK instead of falling through to
    sqlEngine.parse() and erroring.

Motivation

Follow-up from the Claude Code review on PR #6542 (the #6457 fix), which was explicitly scoped to the
simple-query protocol only.

Related issues

Closes #6543. Same class of bug as #6457/#6542, on the extended-query wire path.

Additional Notes

Discovered while testing, left as a separate follow-up (not fixed in this PR): parseCommand()'s BEGIN
branch only sets explicitTransactionStarted = true - unlike queryCommand()'s BEGIN branch, it never calls
database.begin(). So a write made after an extended-query BEGIN currently auto-commits on its own (via the
per-statement auto-transaction wrapping) before any following COMMIT/ROLLBACK is reached - "explicit
transactions" over the extended query protocol don't yet behave transactionally at all. This is independent of
#6543 (which is about wire-status/dispatch correctness, not about starting a real underlying transaction) and is
a materially bigger change - filing it separately seemed better than folding it into this fix. The regression
test's javadoc calls this out explicitly and deliberately does not assert data-discarding for that reason.

Filed as a companion follow-up, per the Claude review on this PR: #6548. parseCommand()/bindCommand()/
executeCommand() all short-circuit with if (errorInTransaction) return; before the new BEGIN/COMMIT/ROLLBACK
dispatch. So once a transaction is aborted, a client that sends an explicit ROLLBACK over the extended
protocol to recover never reaches the dispatch added here - Sync's errorInTransaction branch does roll back
but never clears explicitTransactionStarted, so the client ends up back at status 'T' instead of 'I'. Same
symptom this PR fixes, reached via the aborted-transaction path instead of a plain ROLLBACK. Pre-existing
(the early-return guard predates this diff), touches three call sites instead of one, and needs its own
regression coverage - out of scope here, tracked in #6548.

Review nits closed in this PR: the initial version of the regression test only exercised the ROLLBACK-side
aliases; a follow-up commit added COMMIT WORK/COMMIT TRANSACTION/END/END TRANSACTION/END WORK coverage
so every form isCommitStatement/isRollbackStatement recognizes is now exercised over the extended protocol,
not just the ROLLBACK half. A later review pass also flagged BEGIN WORK as unrecognized (real PostgreSQL
syntax, and the PR's own stated goal was matching the WORK form to the SQL standard) - folded in above with
isBeginStatement and a BEGIN WORK -> ROLLBACK regression case.

Test plan

  • New Issue6543RollbackExtendedProtocolIT (raw-socket, extended-query Parse/Bind/Execute/Sync), 3 tests:
    • rollbackOverExtendedProtocolEndsTransaction: BEGIN -> 'T'; ROLLBACK -> no ErrorResponse, status back to
      'I'; a following statement on the same connection still works (not wedged in 'T').
    • rollbackAliasesAreRecognizedOverExtendedProtocol: ROLLBACK WORK and ROLLBACK TRANSACTION both
      recognized and clear the flag, over the extended query protocol.
    • commitAliasesAreRecognizedOverExtendedProtocol: COMMIT WORK, COMMIT TRANSACTION, END,
      END TRANSACTION, and END WORK all recognized and clear the flag, over the extended query protocol -
      the COMMIT-side counterpart, added in response to review feedback on this PR.
    • All reproduce the bug before the fix (confirmed failing pre-fix: a SocketException/EOFException for the
      WORK/TRANSACTION forms once isCommitStatement/isRollbackStatement were widened without first reordering
      the parse call, and a stuck 'T' status for the bare ROLLBACK case).
  • Existing Issue6457AbortedTransactionSimpleQueryIT (simple-query protocol, Postgres simple-query: an aborted BEGIN block wedges the session (ReadyForQuery never 'E', COMMIT/ROLLBACK unrecognized, statements silently swallowed) #6457/fix(#6457): recognize COMMIT/ROLLBACK/END over the Postgres simple-query protocol #6542) still passes -
    confirms the simple-query dispatch and its COMMIT/ROLLBACK/END handling are unaffected.
  • Full postgresw module test suite: 414 tests, 0 failures, 0 errors.
  • mvn compile/test-compile clean for postgresw and its reactor dependencies.

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

parseCommand()'s Parse-time dispatch tracked explicit-transaction state for
BEGIN/BEGIN TRANSACTION and COMMIT only. There was no ROLLBACK branch, and
sqlEngine.parse() was called unconditionally before that dispatch ever ran,
so a bare ROLLBACK sent as its own Parse/Bind/Execute fell through, parsed
as ArcadeDB SQL's own RollbackStatement (which does call database.rollback()),
but left explicitTransactionStarted set - wedging the wire-level session at
ReadyForQuery status 'T' forever afterwards, since syncCommand()'s implicit-
commit branch only runs once that flag is clear.

Add a ROLLBACK branch that clears the flag and explicitly rolls back (it
cannot lean on Sync's implicit-commit branch the way COMMIT does, since
clearing the flag without rolling back first would make the next Sync
COMMIT the transaction instead). Move the BEGIN/COMMIT/ROLLBACK check ahead
of sqlEngine.parse() entirely, mirroring queryCommand's simple-query
dispatch: the grammar's begin/commit/rollbackStatement productions accept
only the bare keyword, so "BEGIN TRANSACTION"/"COMMIT WORK"/
"ROLLBACK TRANSACTION" all fail to parse as SQL, and calling parse()
unconditionally is what made the follow-up ask - widening
isCommitStatement/isRollbackStatement to the SQL-standard WORK forms -
throw a syntax error instead of silently doing nothing.

Regression test speaks the wire protocol directly over a raw socket so the
extended-query Parse/Bind/Execute path is actually exercised (JDBC/psycopg2
normally send transaction control over the simple-query protocol instead).
@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

codacy-production Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity

Metric Results
Complexity 6

View in Codacy

🟢 Coverage 93.33% diff coverage · -6.55% coverage variation

Metric Results
Coverage variation ✅ -6.55% coverage variation
Diff coverage ✅ 93.33% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (49d2025) 164158 131234 79.94%
Head commit (b7c783d) 196552 (+32394) 144252 (+13018) 73.39% (-6.55%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6546) 15 14 93.33%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review

Solid, well-scoped fix. I traced through parseCommand(), syncCommand(), queryCommand(), writeReadyForQueryMessage(), and the new isCommitStatement/isRollbackStatement usage in getTag() to check consistency, and the change holds together:

  • The new ROLLBACK branch correctly guards with explicitTransactionStarted && database.isTransactionActive() before calling database.rollback(), mirroring queryCommand()'s existing simple-query ROLLBACK handling (lines 654-657) - so behavior is now consistent between the two wire paths.
  • Moving the BEGIN/COMMIT/ROLLBACK check ahead of sqlEngine.parse() is correctly justified: the grammar productions really do reject BEGIN TRANSACTION/COMMIT WORK/ROLLBACK TRANSACTION, so widening the matcher without reordering would have turned "silently falls through" into "throws a syntax error" - good catch, and the PR description documents this was confirmed by an actual pre-fix regression run rather than just reasoned about.
  • getTag() (used for the CommandComplete tag) already delegates to the same isCommitStatement/isRollbackStatement helpers, so the widened forms get the right COMMIT/ROLLBACK tag over the extended protocol too, for free.
  • The asymmetry between COMMIT (defers to syncCommand()'s implicit-commit branch, no direct database.commit()) and ROLLBACK (calls database.rollback() immediately) is explained in both the code comments and PR description, and is correct: clearing the flag without rolling back first would let the next Sync's implicit-commit branch commit instead of discard. This was already the pre-existing pattern for bare COMMIT before this PR - just generalized and reordered, not new behavior.

Minor observations (non-blocking)

  1. Test coverage gap on the COMMIT side. The PR widens isCommitStatement to recognize COMMIT WORK/END/END TRANSACTION/END WORK over the extended protocol (previously only the exact literal "COMMIT" matched there). The new IT class (Issue6543RollbackExtendedProtocolIT) only exercises the ROLLBACK side (ROLLBACK, ROLLBACK WORK, ROLLBACK TRANSACTION). Since this is an actual behavior change for the extended protocol (not just the already-covered simple-query path), a quick COMMIT WORK or END case over the extended protocol would close the loop and guard against regressions in that half of the fix.

  2. Pre-existing style nit, not introduced by this PR: the BEGIN/BEGIN TRANSACTION check still uses portal.query.equalsIgnoreCase(...) while the new COMMIT/ROLLBACK branches use the already-computed upperCaseText via the shared helpers. Harmless (case-insensitive comparison either way), but slightly inconsistent style now that the surrounding code has been touched. Not necessary to fix in this PR since it's out of scope, but worth converging to "BEGIN".equals(upperCaseText) (matching queryCommand()'s own dispatch at line 645) next time this block is touched.

  3. Good transparency in the "Additional Notes" section calling out that parseCommand()'s BEGIN branch still doesn't call database.begin() (so extended-protocol "explicit transactions" don't yet behave transactionally at the storage level). Correctly scoped out of this PR as a separate, larger issue, and the regression test's Javadoc explicitly documents why it doesn't assert data-discarding - that's the right call rather than half-testing a gap this PR doesn't close.

Test coverage

The new Issue6543RollbackExtendedProtocolIT correctly speaks the wire protocol over a raw socket (reusing the existing PostgresWireProtocolTestBase scaffolding), which is necessary here since JDBC/psycopg2 normally route transaction control through the simple-query protocol and wouldn't exercise this code path at all. Assertions on ReadyForQuery status transitions ('T' -> 'I') and absence of ErrorResponse directly target the reported bug. Good regression coverage overall, modulo the COMMIT-side gap noted above.

No security or performance concerns - this is a dispatch-ordering/matching fix with no new allocations or hot-path impact.

… protocol

The Claude review on this PR noted a coverage gap: isCommitStatement() was
widened to COMMIT WORK/END/END TRANSACTION/END WORK alongside the ROLLBACK
fix, but the new IT class only exercised the ROLLBACK side. Add a companion
test exercising COMMIT WORK and END over Parse/Bind/Execute/Sync.
@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review

Solid, well-scoped fix. Mirrors queryCommand()'s simple-query dispatch ordering exactly as intended, the reasoning in the comments is accurate (verified against the grammar's beginStatement/commitStatement/rollbackStatement productions and against syncCommand()), and the new IT class exercises the real wire path with raw sockets rather than JDBC, which is the only way to actually reach the extended-query Parse dispatch. Nice touch keeping the "why not database.rollback() before clearing the flag" and "why COMMIT can lean on Sync's implicit commit" reasoning right next to the code.

Potential follow-up bug (not introduced by this PR, same bug class as #6543)

parseCommand() still has:

if (errorInTransaction)
  return;

before the new BEGIN/COMMIT/ROLLBACK dispatch (PostgresNetworkExecutor.java:1848). That means once a transaction is aborted (errorInTransaction = true), a client that sends an explicit ROLLBACK over the extended protocol to recover never reaches the new isRollbackStatement branch at all - Parse just silently returns. bindCommand()/executeCommand() have the identical early return (lines ~1762, ~439), so nothing in the extended path ever clears explicitTransactionStarted in this case.

Compare with queryCommand()'s simple-query dispatch (lines 582-604), which explicitly special-cases isTransactionEndStatement(...) while errorInTransaction is true and clears both errorInTransaction and explicitTransactionStarted.

When Sync eventually arrives, its errorInTransaction branch (line 320-323) does roll back and clears errorInTransaction, but never touches explicitTransactionStarted. Since writeReadyForQueryMessage() checks errorInTransaction first and explicitTransactionStarted second, the client ends up back at status 'T' instead of 'I' after recovering from an aborted transaction over the extended protocol - the same "wedged forever" symptom this PR fixes, just reached via the aborted-transaction path instead of the plain-ROLLBACK path.

This looks pre-existing (the if (errorInTransaction) return; guard predates this diff) and out of scope for this PR, but given the PR already calls out one deliberately-deferred gap (BEGIN not calling database.begin()), it may be worth filing as a companion follow-up to #6543 rather than leaving it undocumented.

Minor: test coverage gap

The new isCommitStatement/isRollbackStatement widening covers COMMIT TRANSACTION, END TRANSACTION, and END WORK in addition to the forms actually exercised in Issue6543RollbackExtendedProtocolIT (ROLLBACK, ROLLBACK WORK, ROLLBACK TRANSACTION, COMMIT WORK, END). Not a blocker since the logic is identical across all recognized forms and COMMIT/ROLLBACK/END variants are already covered, but COMMIT TRANSACTION/END TRANSACTION/END WORK are untested strings.

Nits

  • Style, error handling, and test structure all look consistent with the rest of the file (final params, no unnecessary braces on single-statement ifs, socket-level test scaffolding reused from PostgresWireProtocolTestBase).
  • No security or performance concerns - the added checks are cheap string comparisons on already-uppercased text, same cost profile as the existing BEGIN check.

Nice writeup in the PR description connecting the fix to the exact mechanics of writeReadyForQueryMessage()/syncCommand() - made this easy to verify.

…ases too

Closes the remaining test-coverage nit from the review: isCommitStatement()
also recognizes COMMIT TRANSACTION/END TRANSACTION/END WORK, which weren't
yet exercised over the extended query protocol. Files a companion follow-up
issue (#6548, referenced in the PR body) for the separately-scoped
errorInTransaction early-return gap the same review flagged.
@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review

Reviewed the diff in PostgresNetworkExecutor.java and the new Issue6543RollbackExtendedProtocolIT.

Correctness

  • The fix is logically sound. Moving the BEGIN/COMMIT/ROLLBACK dispatch ahead of sqlEngine.parse() in parseCommand() mirrors queryCommand()'s existing simple-query ordering, and is necessary (not just cosmetic) since the SQL grammar's commitStatement/rollbackStatement productions reject the WORK/TRANSACTION suffix forms.
  • The asymmetry between COMMIT and ROLLBACK handling is correct and well explained: COMMIT clears the flag and lets syncCommand()'s implicit-commit branch do the actual commit, while ROLLBACK must call database.rollback() directly before clearing the flag, otherwise the next Sync would commit instead of rolling back. Good catch, and the comments explain why, not just what.
  • Verified against writeReadyForQueryMessage() (line ~716): status is driven purely by errorInTransaction/explicitTransactionStarted, confirming the flag-clearing logic is what actually fixes the stuck 'T' status.
  • isCommitStatement/isRollbackStatement are shared between the simple-query and extended-query dispatch, so the new WORK forms are consistently recognized in both, which is good for avoiding drift between the two protocols.

Minor observations (not blockers)

  • BEGIN doesn't gain the same WORK alias treatment. PostgreSQL's actual grammar is BEGIN [ WORK | TRANSACTION ] [...], so BEGIN WORK is a legitimate form a real client could send, and it isn't recognized in either queryCommand() (line 645) or parseCommand() (line 1904) even after this PR. Since the PR's stated goal was to match COMMIT/ROLLBACK's WORK form to the SQL standard, it may be worth filing a follow-up (or folding in here, since it's a small change) for symmetry - currently a client sending BEGIN WORK would fall through to sqlEngine.parse() and get a syntax error.
  • The known gap that parseCommand()'s BEGIN branch never calls database.begin() (only sets explicitTransactionStarted), unlike queryCommand()'s BEGIN which does, is called out clearly in the new test's Javadoc as pre-existing and out of scope - good transparency, and reasonable to leave for a separate PR given the blast radius.
  • The errorInTransaction early-return gap (aborted extended-protocol transactions never reaching this new dispatch) is correctly identified as pre-existing and already tracked in the follow-up issue Postgres extended query protocol: aborted-transaction ROLLBACK recovery never reaches the new dispatch (errorInTransaction early-return) #6548 mentioned in the PR description, rather than silently left undocumented.

Test coverage

  • Issue6543RollbackExtendedProtocolIT is thorough: it exercises the bare ROLLBACK, the WORK/TRANSACTION alias forms for both ROLLBACK and COMMIT, verifies no spurious ErrorResponse, and verifies the session recovers to 'I' and remains usable for a follow-up query. Raw-socket framing is the right approach since it's the only way to actually exercise the extended-query Parse/Bind/Execute path (a JDBC driver wouldn't naturally send transaction control that way).
  • Good instinct to explicitly not assert data-discarding semantics, given the documented BEGIN gap noted above - asserting it would test the wrong thing.
  • Test helpers reuse the shared PostgresWireProtocolTestBase primitives (sendStartupMessage, sendPasswordMessage, writeCString, readMessageOfType) rather than duplicating them; the new readWireMessage/readUntilReadyForQuery helpers are justified since the base class's helpers only skip message bodies and this test needs to inspect the ReadyForQuery status byte.

Security / Performance

  • No security concerns: this only affects transaction-state bookkeeping on an already-authenticated wire connection, no new input-parsing surface introduced beyond string equality/prefix checks.
  • No performance concerns: the added checks are cheap string comparisons on the hot path, same shape as the existing BEGIN/COMMIT checks they sit beside.

Overall this is a well-scoped, well-tested fix with clear reasoning in the comments and PR description. Nice job separating the genuinely-out-of-scope follow-up work (#6548) instead of scope-creeping this PR.

…nt helper

PostgreSQL's own grammar is BEGIN [ WORK | TRANSACTION ], so BEGIN WORK is a
real form a client can send. Add isBeginStatement (BEGIN/BEGIN
TRANSACTION/BEGIN WORK), matching the three-way shape of isCommitStatement/
isRollbackStatement, and use it in queryCommand(), parseCommand(), and
getTag() in place of each site's ad hoc literal check. Extends the extended-
protocol regression test with a BEGIN WORK -> ROLLBACK case.
@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review

Verified against the actual merged file (PostgresNetworkExecutor.java), not just the diff hunks, to check the surrounding context (upperCaseText scope, isTransactionEndStatement, setEmptyResultSet, getTag).

Correctness

  • The core fix is right: moving the BEGIN/COMMIT/ROLLBACK dispatch ahead of sqlEngine.parse() is necessary, not cosmetic, since rollbackStatement/commitStatement in the SQL grammar only accept the bare keyword — ROLLBACK WORK/COMMIT TRANSACTION would otherwise throw CommandParsingException before ever reaching the widened isCommitStatement/isRollbackStatement checks. Good catch, and the PR description explains this reasoning clearly.
  • isTransactionEndStatement() (used by queryCommand()'s aborted-transaction recovery path) composes isCommitStatement/isRollbackStatement, so the new WORK forms flow through consistently everywhere those helpers are used, not just the two new call sites.
  • The ROLLBACK branch's guard, if (explicitTransactionStarted && database.isTransactionActive()) database.rollback();, mirrors the exact pattern queryCommand()'s simple-query ROLLBACK branch already uses (lines 654-658). Good — no inconsistency between the two protocol paths, and it avoids calling rollback() on a non-active transaction.
  • ROLLBACK TO <savepoint> is correctly excluded — it's caught by the earlier upperCaseText.startsWith("ROLLBACK TO ") branch (line 1861) before the switch statement is ever reached, so it can't collide with the new isRollbackStatement check.

Scope discipline

  • The PR explicitly calls out a pre-existing gap: parseCommand()'s BEGIN branch never calls database.begin() (unlike queryCommand()'s, which does), so a write after an extended-protocol BEGIN auto-commits before any later ROLLBACK/COMMIT is reached. This fix only corrects the wire-level status flag ('T' vs 'I'), not actual data rollback for that path. Documenting this clearly in the test class Javadoc rather than silently asserting on it (or scope-creeping to fix it here) is the right call.
  • Similarly good: the errorInTransaction early-return guard in parseCommand()/bindCommand()/executeCommand() means a ROLLBACK sent to recover from an aborted transaction over the extended protocol still never reaches this new dispatch — same symptom, different trigger. Correctly identified as pre-existing and out of scope, filed as Postgres extended query protocol: aborted-transaction ROLLBACK recovery never reaches the new dispatch (errorInTransaction early-return) #6548 instead of folded in here.

Test coverage

  • Good choice to speak the wire protocol over a raw socket directly rather than through JDBC/psycopg2 — those clients route transaction control through the simple-query protocol, which wouldn't exercise this bug at all.
  • Coverage is thorough for the stated fix: bare ROLLBACK, ROLLBACK WORK/TRANSACTION, COMMIT WORK/TRANSACTION, END/END TRANSACTION/END WORK, BEGIN WORK — matches every form the widened helpers now recognize.
  • Minor gap (low priority, not a blocker): no test for a bare ROLLBACK over the extended protocol with no preceding BEGIN (i.e. explicitTransactionStarted == false). The guard makes this a no-op by inspection, but it's the one branch combination the new tests don't touch directly.
  • Also minor: no case with a trailing semicolon (e.g. a client sending ROLLBACK; as its Parse text) — parseCommand() doesn't trim/strip trailing ; the way queryCommand() does before matching, so a semicolon-terminated form would fall through to sqlEngine.parse(). This is pre-existing behavior for BEGIN/COMMIT too (not a regression here), and extended-protocol clients don't typically append semicolons, so it's likely fine — just flagging as unverified.

Nits

  • The doc comments on isBeginStatement/isCommitStatement/isRollbackStatement/isTransactionEndStatement are unusually thorough for private helpers, but they carry real information (why the three-way shape, why ROLLBACK TO is excluded) rather than restating the code, so they're earning their keep per the project's comment guidance.

Overall: a well-scoped, well-tested fix that correctly resists the temptation to also fix the two adjacent gaps it surfaced (database.begin() gap, errorInTransaction gap), and threads the WORK/TRANSACTION alias handling through consistently across all three protocol dispatch points (parseCommand, queryCommand, getTag).

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.22%. Comparing base (49d2025) to head (b7c783d).

Files with missing lines Patch % Lines
...com/arcadedb/postgres/PostgresNetworkExecutor.java 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6546      +/-   ##
==========================================
- Coverage   71.24%   71.22%   -0.02%     
==========================================
  Files        1866     1866              
  Lines      164158   164165       +7     
  Branches    34688    34690       +2     
==========================================
- Hits       116948   116931      -17     
- Misses      32967    32999      +32     
+ Partials    14243    14235       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robfrank
robfrank merged commit 581c231 into main Aug 21, 2026
32 of 33 checks passed
@robfrank
robfrank deleted the fix/6543-postgres-extended-protocol-rollback branch August 26, 2026 09:09
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.

Postgres extended query protocol: Parse dispatch recognizes BEGIN/COMMIT but not ROLLBACK

1 participant