Repository navigation
Description
Summary
setErrorInTx() raises the "an error happened" flag ONLY when the session is inside an explicit BEGIN block:
private void setErrorInTx() {
if (explicitTransactionStarted)
errorInTransaction = true;
}errorInTransaction is the single flag that drives both (a) "discard every message until Sync", which every handler
implements as an early return, and (b) Sync's rollback-vs-commit decision. So in autocommit - the mode every JDBC /
psycopg / asyncpg client is in unless it explicitly opened a transaction - an ErrorResponse in the middle of a pipeline
leaves the connection fully live:
- The Parse/Bind/Execute messages that follow the failing one in the same pipeline are executed and answered, instead of
being discarded until Sync as the protocol requires ("the backend discards messages until a Sync is reached", and
pipelining clients such as psycopg3 rely on it to mark the rest of the pipeline aborted). syncCommand()then takes itselse if (!explicitTransactionStarted)arm and commits:
if (errorInTransaction) {
database.rollback();
errorInTransaction = false;
} else if (!explicitTransactionStarted) {
if (database.isTransactionActive())
database.commit();
}PostgreSQL treats a run of extended-protocol messages terminated by one Sync as an implicit transaction block, and an
error anywhere in it rolls the WHOLE block back. Here the block is committed, so the statements that succeeded before
the failure - and the ones that wrongly ran after it - are persisted. That is the classic JDBC executeBatch() in
autocommit shape: pgjdbc sends the whole batch and one Sync, and callers (and BatchUpdateException handling) assume
a failed batch left nothing behind.
Where (HEAD 417314c)
postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:3165
private void setErrorInTx() {
if (explicitTransactionStarted)
errorInTransaction = true;
}postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java:344
if (errorInTransaction) {
// DISCARDED PREVIOUS MESSAGES TILL THIS POINT
database.rollback();
errorInTransaction = false;
} else if (!explicitTransactionStarted) {
if (database.isTransactionActive())
database.commit();
}
writeReadyForQueryMessage();The early-return guards that implement "skip until Sync" and are therefore dead in autocommit:
describeCommand() :392, executeCommand() :583, closeCommand() :368, bindCommand() :2269, parseCommand() :2368.
Repro
Raw-socket integration test (standalone, outside the source tree), one pipeline with NO explicit BEGIN:
parseBindExecute("s1", "INSERT INTO PipeT SET id = 1");
parseBindExecute("s2", "SELECT FROM ThisTypeDoesNotExist"); // errors
parseBindExecute("s3", "INSERT INTO PipeT SET id = 3");
sendSync();
Run against the worktree classes:
$ java -cp <worktree classes + deps> RunIt com.arcadedb.postgres.PipelineSkipUntilSyncIT
REPRO: backend messages after the pipeline = 1 2 T D C 1 2 E 1 2 T D C Z
REPRO: ErrorResponse fields = {M=Error on executing query: Type with name 'ThisTypeDoesNotExist' was not found, S=ERROR, C=42P01}
REPRO: ReadyForQuery status = I
REPRO: rows persisted in PipeT after the failed pipeline = 2 -> ids: 3 1
[ 1 tests successful ]
The message trace is the whole finding: after the E (ErrorResponse) the backend answers 1 2 T D C for s3 - it parsed,
bound, described, returned a row and completed the statement that PostgreSQL would have skipped. And both rows are on
disk afterwards; real PostgreSQL leaves zero.
Suggested fix
Separate the two meanings the one flag carries today:
- a
skipUntilSyncflag set by EVERY ErrorResponse in the extended protocol (i.e.setErrorInTx()unconditionally sets
it), cleared only bysyncCommand(). That is what the existing early-return guards should read. - keep
errorInTransaction(the aborted-block state, SQLSTATE 25P02, ReadyForQuery 'E') gated on
explicitTransactionStarted, as it is now.
Then makesyncCommand()roll back rather than commit wheneverskipUntilSyncis set, so the implicit transaction block
is discarded the way PostgreSQL discards it. The simple-query ('Q') path is unaffected: it has its own
ReadyForQuery per statement and no implicit multi-statement block.
Scope / confidence
Tried to refute it three ways. (1) Maybe the SQL engine autocommits each statement so no block exists: no - the comment
at :2483 ("No explicit database.commit() here ... the Sync that follows this Execute take its implicit-commit branch")
says the transaction deliberately spans the messages up to Sync, and the repro's two rows appearing together confirms it.
(2) Maybe some other guard stops the pipeline: the trace shows 1 2 T D C after the E, so no. (3) Maybe pgjdbc sends a
Sync per statement so this is unreachable: it does for single statements, but not for executeBatch(), and psycopg3
pipeline mode and asyncpg batch paths deliberately pipeline many messages per Sync. Falsified if a client is found that
always Syncs per statement AND the project decides the implicit-block rollback semantics are out of scope - but the
"statements after an ErrorResponse still execute" half is a plain protocol violation either way.
Activity
Merge pull request #7853 from ArcadeData/fix/issues-7851-7801-7775-7470
lvca commentedon Sep 18, 2026
Fixed in #7853, milestone 26.10.1.
Two things changed for pipelined clients (JDBC
executeBatch(), psycopg3 pipeline mode, asyncpg):Sync, instead of being executed and answered.Syncmessages is now one transaction. If anything in it fails, the whole run is rolled back; before, the statements that had already run were kept.Worth knowing when you upgrade: a failed batch in autocommit now leaves nothing behind, which is what PostgreSQL does and what
BatchUpdateExceptionhandling assumes, but it differs from the previous per-statement behaviour.While fixing this we also found and fixed two related problems: a
BEGINsent over the extended protocol never actually opened a transaction (so the matchingROLLBACKsilently kept the writes), and aCOMMITyou had already been told succeeded could still be rolled back by a later failure in the same pipeline.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(#7868,#7905,#7858,#7906,#7895): carry the owner row, answer trans…
Fix four Postgres wire protocol defects (ArcadeData#7851, ArcadeData#…