Skip to content

A block that committed part of its work fails with PartialCommitError, not a retryable ConflictError - #508

Merged
tae898 merged 3 commits into
mainfrom
fix/504-partial-commit-not-retryable
Nov 27, 2026
Merged

tae898 merged 3 commits into
mainfrom
fix/504-partial-commit-not-retryable

Conversation

@tae898

@tae898 tae898 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #504.

When a block that had already committed part of its work (a BATCH n boundary, or commit() and begin() inside it) lost a conflict, both packages raised ConflictError, whose hint says to run the transaction again. Running it again applies the committed part a second time. This PR raises a different, non-retryable error for that case.

The first commit holds only tests, run on the old code. Its CI run shows the problem, and the second commit is the fix.

Test on the old code arcadedb-jvm, engine 26.12.1 snapshot arcadedb, engine 26.11.1
A caller that retries on ConflictError applies the committed part twice fails fails
The engine's own COMMIT RETRY refusal gets partial_commit fails (unknown) not applicable: this engine raises the conflict
A nested block that committed nothing is retried passes fails (refused)
A nested block with a commit() inside is not replayed passes fails (replayed)

The engine pinned for dev releases (snapshot of 2026-11-06) is older than the engine change, so it raises no refusal of its own. The bindings' own refusal does not depend on the engine.

Case Before After
db.run_in_transaction(fn), also on the last attempt ConflictError, code conflict PartialCommitError, code partial_commit
with db.transaction(): ConflictError, code conflict the same PartialCommitError
Engine's own refusal (engine PR 13406), for example a COMMIT RETRY block code unknown PartialCommitError, code partial_commit
A block that committed nothing retried, or ConflictError unchanged
DuplicateKeyError after a commit raised, not replayed unchanged

Two decisions:

  • The with block raises the same error, because its conflict carried the same hint, and the engine does the same for a block that joined a caller's transaction.
  • The conflict is the new error's __context__, not its __cause__, so neither _retry_verdict nor the native retry reply finds it, and an outer run_in_transaction does not replay it.

Also fixed, in the arcadedb (native) package only: for a block that begins inside a caller's transaction, the guard compared the commit count of the caller's context instead of the block's own. The library now remembers the context of a nested block (arcadedb_n_tx ops 4 and 5), which costs one extra call into the library for a nested block and none otherwise.

The with block gets its commit count from the call that already reads the transaction state before begin(), so a transaction outside another one costs no extra call in either package.

Docs: how-to/errors.adoc (table row and a runnable example), how-to/transactions.adoc, how-to/concurrency.adoc (the hand-written retry loop does not see a commit inside the block), and the changed behaviour section of upgrading.adoc.

…twice

Reproduction on the old code, before the fix: run_in_transaction refuses to replay a block that committed part of its
work, but raises the conflict itself, so a program that follows the hint runs the block again. The second test runs the
engine's own COMMIT RETRY refusal (engine PR 13406) and expects the same class from it.
@tae898 tae898 self-assigned this Nov 27, 2026
…CommitError, not a retryable conflict

run_in_transaction and with db.transaction() raise PartialCommitError (code partial_commit) for a conflict after a
commit inside the block, on the last attempt too. It is not a ConflictError and the conflict is its __context__, not its
__cause__, so no retry loop finds it. The engine's own TransactionException for the same refusal (engine PR 13406) gets
the same class and code. A duplicated key keeps its class, as in the engine.

The native build read the commit count of the thread's current context, which for a nested block is the caller's after
the unwind: it refused a nested conflict that committed nothing and replayed a nested block with a commit (both seen in
the CI run of the previous commit). arcadedb_n_tx ops 4 and 5 remember and read the nested block's own context.

stackMark now carries the commit count too, so a with block outside a transaction costs no extra call.
@tae898
tae898 merged commit adfdbbf into main Nov 27, 2026
23 checks passed
@tae898
tae898 deleted the fix/504-partial-commit-not-retryable branch November 27, 2026 10:29
@github-actions github-actions Bot added this to the 26.12.1 milestone Nov 27, 2026
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.

run_in_transaction: a block that already committed part of its work fails as a retryable ConflictError

1 participant