Repository navigation
Description
Summary
JSONImporterFormat's per-record catch rolls back whatever transaction is active after a failed
database.commit(). By then that is no longer the record loop's own transaction -
LocalDatabase.commit() pops it in a finally whether or not the commit succeeded - so on an
externally-managed database with a caller transaction open, the rollback lands on the CALLER's transaction and
silently discards its unrelated pending work. This is the mechanism issue #7732 fixed for the TimeSeries
append, one module over. JSONImporterFormat is the one row loop that never adopted
ImporterContext.importOwnsTransaction, which exists precisely so the five loops cannot answer this
differently.
Where (HEAD 06b033d)
integration/src/main/java/com/arcadedb/integration/importer/format/JSONImporterFormat.java:227-231 - the
commit and the ungated rollback:
database.commit();
} catch (final RuntimeException e) {
if (database.isTransactionActive())
database.rollback();engine/src/main/java/com/arcadedb/database/LocalDatabase.java:673-691 - why the transaction active at
:229 is not the one :227 tried to commit:
public void commit() {
executeInReadLock(() -> {
checkTransactionIsActive(false);
final DatabaseContext.DatabaseContextTL current =
DatabaseContext.INSTANCE.getContext(LocalDatabase.this.getDatabasePath());
try {
final Binary result = current.getLastTransaction().commit();
...
} finally {
current.popIfNotLastTransaction();
}The nesting is the loop's own documented premise,
JSONImporterFormat.java:142-147:
// Each record below commits/rolls back its own nested transaction (database.begin() nests rather than reusing
// an already-active one - see LocalDatabase#begin()) ...
if (settings.isSkipOnRowError() && context.callerTransactionActiveOnEntry)
throw ImporterSettings.newExclusiveTransactionRequiredException();Note what that guard does and does not cover: it refuses only the "skip" combination. The default "abort" mode
with a caller transaction open is explicitly allowed, and is exactly the mode in which :231 rethrows after
rolling back.
The shared answer this loop does not use,
integration/src/main/java/com/arcadedb/integration/importer/ImporterContext.java:109-126:
* The single place this decision is made, so the five row loops that gate on it cannot each answer it slightly
* differently. ...
public boolean importOwnsTransaction(final Database database) {
return !callerTransactionActiveOnEntry || !database.isTransactionActive();
}The four siblings do gate on it - CSVImporterFormat.java:294 (rollbackIfOwned, fed by computeTransactionOwnership at :332-333),
JsonlImporterFormat.java:154, :244 and :253, and RDFImporterFormat.java:106. The Jsonl copy names this
file while doing so, JsonlImporterFormat.java:240-245:
// A per-record failure in default "abort" mode must fail the whole import loudly (issue #6468): rolling
// back the in-flight batch here - instead of committing it below - is what keeps a partial import from
// masquerading as a successful one, and the ownsTransaction guard mirrors JSONImporterFormat's contract of
// never discarding a caller's own transaction.
if (ownsTransaction && database.isTransactionActive())
database.rollback();so the contract is written down as this file's own and only implemented elsewhere. The same file already
declines to roll back in both of its outer catches for this very reason,
JSONImporterFormat.java:162-168:
} catch (final RuntimeException e) {
// Any RuntimeException reaching here has already passed through parseRecordsArray()'s per-record catch, which
// (in "abort" mode, the only mode where it rethrows) already rolled back its own nested level. Don't roll back
// again here: by this point the transaction stack may have already correctly unwound past our own level to a
// caller's own still-active transaction ...The outer catch is therefore correct only if the inner one is - and it is not.
Repro
Embedded, on a database the caller manages:
database.begin(); create or modify a record the import knows nothing about. Do not commit.- Run
Importerover a JSON array in the default "abort" mode (-skipOnRowErrornot set), against a type
whose commit can fail - e.g. a UNIQUE index the array's second record duplicates, which LSM indexes raise at
commit time, not atsave(). database.commit()at:227throwsDuplicatedKeyException.LocalDatabase.commit()'sfinallyhas
already popped the import's nested transaction, sodatabase.isTransactionActive()at:229reports the
transaction from step 1, and:230rolls it back.- The
DuplicatedKeyExceptionpropagates out of the import, as it should. What the caller is not told is that
its own uncommitted work from step 1 is gone as well: it sees an import failure, not a rollback of its
transaction.
Importer.load()'s own cleanup does not catch this either -
Importer.java:129 is gated on !context.callerTransactionActiveOnEntry, which is false here.
Suggested fix
Capture the ownership answer once, immediately before :152's begin(), and gate the rollback on it, the way
the four sibling formats do:
final boolean ownsTransaction = context.importOwnsTransaction(database);
database.begin();
...
database.commit();
} catch (final RuntimeException e) {
if (ownsTransaction && database.isTransactionActive())
database.rollback();Alternatively hold an OwnTransaction (engine/src/main/java/com/arcadedb/engine/OwnTransaction.java) across
the per-record begin/commit and let it decide. A regression test belongs with the ones the four siblings already
have: caller transaction open, abort mode, a record whose commit fails, then assert the caller's own record is
still pending rather than gone.
Scope / confidence
Checked at today's HEAD that LocalDatabase.commit() still pops in a finally
(popIfNotLastTransaction()), that JSONImporterFormat is still the only importer row loop with no
importOwnsTransaction call, and that its entry guard still refuses only the "skip" combination, leaving abort
mode with a caller transaction reachable. The narrowness matters and is stated deliberately: for a
RuntimeException raised anywhere BEFORE :227 - and that is most of them - the active transaction really is
the loop's own and the unconditional rollback is correct. Only a throw from commit() itself moves the target.
Falsified if database.begin() on an already-active transaction were shown to reuse rather than nest (the
file's own comment at :142-144 and popIfNotLastTransaction's name both say it nests), or if a commit failure
left the failed transaction on the stack rather than popped - in which case isTransactionActive() would still
be pointing at the import's own level and the rollback would be right.
Activity
Merge pull request #7943 from ArcadeData/fix/issues-7891-7886-7867-78…
lvca commentedon Sep 19, 2026
Fixed in #7943, released with 26.10.1.
If you run a JSON import from your own code while you have a transaction open, a failure during the import no longer rolls back your transaction. Previously a record that failed to commit could discard the unrelated work you had pending, and you were only told the import had failed.
The import still fails loudly, and still discards its own partial work - it just no longer reaches past it.
❤️ 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(importer): five importer fixes - RDF typeIdProperty, JSONL schema…