Repository navigation
Description
GraphBatch.createVertices begins its own transaction and rolls it back only when the failure is a NeedRetryException. Any other failure, such as a DuplicatedKeyException on a unique index or a SchemaException for an unknown type, leaves the transaction active: isTransactionActive() stays true after the call and after the batch is closed. A write made afterwards outside any transaction is accepted instead of refused with TransactionException: Transaction not begun (the repro prints the refusal as a control), is visible to reads, and is gone after the database is closed and reopened, because the transaction it joined never committed.
createVerticesWithRetry calls beginTx() (GraphBatch.java#L662) and has a single catch (final NeedRetryException e) (GraphBatch.java#L678-L680), whose body is the only place that rolls back. The Javadoc says the method "Handles transaction begin/commit internally" (GraphBatch.java#L596), and the documentation describes createVertices(typeName, count) as "Creates vertices in bulk within a single transaction." (Graph Batch); neither sentence says what becomes of that transaction when the call fails.
Related: #7272 and #7289 (closed and merged) fixed the same class in five importer row loops, a transaction opened before a loop and not resolved when a row throws, and #7948 (merged) did it for the GraphSON importer; #8828 (merged 2026-10-03) did it for GraphBatch.create_vertex and insert_many in the Python package, and its sweep covers that package and its Java bridge classes, not this engine method. Searches of the open and closed issues and pull requests for createVertices, createVerticesWithRetry, GraphBatch createVertices rollback, createVertices transaction left open, and GraphBatch transaction active after failure found nothing about createVertices.
Repro
# lib/ holds the engine jar built at the commit under test and its dependencies (not the shaded HA jar)
javac -cp "lib/*" CreateVerticesLeavesTransaction.java
java -XX:+UseCompactObjectHeaders --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp "lib/*:." CreateVerticesLeavesTransaction ./dbimport com.arcadedb.database.*;
import com.arcadedb.graph.GraphBatch;
public class CreateVerticesLeavesTransaction {
static String first(final Exception e) {
return e.getClass().getSimpleName() + ": " + e.getMessage().lines().findFirst().get();
}
public static void main(String[] args) {
System.out.println("ArcadeDB " + com.arcadedb.Constants.getRawVersion() + " (" + com.arcadedb.Constants.getBuildNumber() + "), Java "
+ System.getProperty("java.version"));
final DatabaseFactory factory = new DatabaseFactory(args[0]);
try (Database db = factory.create()) {
db.command("sql", "CREATE VERTEX TYPE Person");
db.command("sql", "CREATE PROPERTY Person.id INTEGER");
db.command("sql", "CREATE INDEX ON Person (id) UNIQUE");
db.command("sql", "CREATE DOCUMENT TYPE Note");
try {
db.command("sql", "INSERT INTO Note SET text = 'control'");
System.out.println("control: an INSERT outside a transaction was accepted");
} catch (Exception e) {
System.out.println("control: an INSERT outside a transaction -> " + first(e));
}
try (GraphBatch batch = GraphBatch.builder(db).build()) {
System.out.println("before : isTransactionActive = " + db.isTransactionActive());
try {
batch.createVertices("Person", new Object[][] { { "id", 2 }, { "id", 2 } });
} catch (Exception e) {
System.out.println("createVertices (duplicate key) : " + first(e));
}
System.out.println("after the failed call : isTransactionActive = " + db.isTransactionActive());
if (db.isTransactionActive())
db.rollback(); // the caller cleans up, to try the next failure from a clean state
try {
batch.createVertices("NoSuchType", 3);
} catch (Exception e) {
System.out.println("createVertices (unknown type) : " + first(e));
}
System.out.println("after the failed call : isTransactionActive = " + db.isTransactionActive());
}
System.out.println("after the batch is closed : isTransactionActive = " + db.isTransactionActive());
try {
db.command("sql", "INSERT INTO Note SET text = 'written outside any transaction'");
System.out.println("INSERT outside a transaction : accepted");
} catch (Exception e) {
System.out.println("INSERT outside a transaction : " + first(e));
}
System.out.println("Note rows visible now : " + db.countType("Note", true));
}
try (Database db = factory.open()) {
System.out.println("after close and reopen : Person = " + db.countType("Person", true) + ", Note = " + db.countType("Note", true));
}
}
}Output on main cecb369df9 (the engine jar's build stamp is 04bb03ebec, the newest commit in it that is not a merge), Temurin 25.0.4 with -XX:+UseCompactObjectHeaders. Temurin 21.0.12 printed the same lines apart from the Java version on the first line; the number in the generated index name differs from run to run.
ArcadeDB 26.10.1-SNAPSHOT (04bb03ebec07fce19101595d65ca1e3bdf516755), Java 25.0.4
control: an INSERT outside a transaction -> TransactionException: Transaction not begun
before : isTransactionActive = false
createVertices (duplicate key) : DuplicatedKeyException: Duplicated key [2] found on index 'Person_0_3596111279054693' already assigned to record #1:0
after the failed call : isTransactionActive = true
createVertices (unknown type) : SchemaException: Type with name 'NoSuchType' was not found
after the failed call : isTransactionActive = true
after the batch is closed : isTransactionActive = true
INSERT outside a transaction : accepted
Note rows visible now : 1
after close and reopen : Person = 0, Note = 0
Versions affected: main cecb369df9 on Temurin 25 and 21, main 417314c18 (2026-09-17), and release 26.9.1 print the same lines apart from that number. The same lines print on current main, b22b5e9954 (2026-10-03, engine build stamp b22b5e99547576dc8ce804d22fe9cdca4573cf29), on Temurin 25.0.4 and 21.0.12, apart from the number in the generated index name.
Expected: after a failed createVertices the database has no active transaction that the call started, and the bare write is refused as it is in the control.
A direction, tested: createVerticesWithRetry could roll back for any other RuntimeException before rethrowing, as its NeedRetryException branch does at lines 679 and 680 (that branch rolls back whatever transaction is active, so this one would too).
backoffBeforeRetry(attempt);
+ } catch (final RuntimeException e) {
+ if (database.isTransactionActive())
+ database.rollback();
+ throw e;
}I built the engine at cecb369df9 with that change alone and ran the same file with Temurin 25, which printed the following; Temurin 21 printed the same lines apart from the first (the generated index name differs). I did not run the engine's test suite with the change.
ArcadeDB 26.10.1-SNAPSHOT (04bb03ebec07fce19101595d65ca1e3bdf516755), Java 25.0.4
control: an INSERT outside a transaction -> TransactionException: Transaction not begun
before : isTransactionActive = false
createVertices (duplicate key) : DuplicatedKeyException: Duplicated key [2] found on index 'Person_0_3597306197529985' already assigned to record #1:0
after the failed call : isTransactionActive = false
createVertices (unknown type) : SchemaException: Type with name 'NoSuchType' was not found
after the failed call : isTransactionActive = false
after the batch is closed : isTransactionActive = false
INSERT outside a transaction : TransactionException: Transaction not begun
Note rows visible now : 0
after close and reopen : Person = 0, Note = 0
Activity
Merge pull request #9163 from ArcadeData/fix/9032-9037-9038-9039-9040
lvca commentedon Oct 4, 2026
Fixed in #9163 (26.10.1). A failed
GraphBatch.createVerticesnow rolls back the transaction it started, so no transaction is left open. A transaction you opened yourself is not touched.❤️ 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.
tae898 commentedon Oct 4, 2026
Verified on main at
80ae6c140f(the #9163 merge) with the reproduction from the issue, unchanged, against0bb737d458, the merge's first parent, on Temurin 25 with-XX:+UseCompactObjectHeadersand on Temurin 21. Each build printed the same lines on both JDKs apart from the generated index name:0bb737d458JDK 250bb737d458JDK 2180ae6c140fJDK 2580ae6c140fJDK 21isTransactionActiveafter the failed call (duplicate key)isTransactionActiveafter the failed call (unknown type)isTransactionActiveafter the batch is closedINSERToutside a transactionTransactionException: Transaction not begunNoterows visibleA transaction the caller opened before a failing
createVerticesis still active afterwards on both builds, as the closing comment says. On80ae6c140f, after a failure in a transaction the call began, the nextcreateVerticeson the same batch stores its vertices with no cleanup by the caller.Thanks for the quick fix!
fix: batch of 5 engine issues (ArcadeData#9032 ArcadeData#9037 Arcade…
test: a batch call inside a caller transaction is now refused up fron…
fix: batch of 5 engine issues (#9032 #9037 #9038 #9039 #9040)
test: a batch call inside a caller transaction is now refused up fron…