Repository navigation
Description
Follow-up to #9529 and #9535 (and #7615 / #7625). I posted the measurement below as a comment on #9529 on 2026-10-09 and, as that issue is closed and the comment has had no reply, I am repeating it here as its own issue: after #9535 the default settings still lose a batch in about 0.4% of runs of the #7615 scenario, and the backoff does not change the loss rate at the defaults.
Checked at the merge commit ac4f75d (CI jars, Temurin 25, 2 cores, one JVM at a time) with the repro from this issue: 9,742 INSERTs through async().command(), 4 workers, commitEvery 1000, one bucket, a per-command callback. A run counts as lost when onError fires for a batch. Runs alternated between the two builds in blocks of 1,500.
| build | settings | runs | runs that lost a batch |
|---|---|---|---|
| before (fd407f1) | defaults | 6,000 | 20 (0.33%) |
| this PR (ac4f75d) | defaults | 6,000 | 24 (0.40%) |
| before | txRetryDelayBase=20 |
1,500 | 3 |
| this PR | txRetryDelayBase=20 |
1,500 | 0 |
| before | txRetries=10 |
1,500 | 0 |
| this PR | txRetries=10 |
1,500 | 0 |
So with the default settings the backoff does not change the loss rate here. Every lost batch is the same ConcurrentModificationException ("Slot rebase not possible on page ... slot ...") after the 3 retries are used up. With the default txRetryDelayBase=2 the three waits are drawn from 0-2, 0-4 and 0-8 ms, which is short next to a replay of 1,000 commands on a shared tail page, so the four workers still collide. A longer window (base 20) lost 0 of 1,500 with the PR against 3 of 1,500 without, which is suggestive but too few events to call. More retries (txRetries=10) lost nothing on either build.
The backoff is still the right behaviour, and the hook-observed tests show it runs. But I would not call the loss fixed for the defaults. Options: replay a batch more times than a single record's txRetries (a batch is 1,000 commands, so a failed attempt costs far more than a single record's retry), or scale the backoff window with the batch size.
Reproduction
The program runs the #7615 scenario (9,742 INSERTs through async().command(), 4 workers, commitEvery 1000, one bucket) many times, each in a fresh database, and counts the runs in which onError fires for a batch. Usage: java --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp '<lib>/*:classes' AsyncBatchLoss <dbDir> <runs> <perCommandCallback:true|false>; the table above used true.
import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.database.async.AsyncResultsetCallback;
import com.arcadedb.database.async.DatabaseAsyncExecutor;
import com.arcadedb.query.sql.executor.ResultSet;
import java.io.File;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
// Usage: java AsyncBatchLoss <dbDir> <runs> <perCommandCallback:true|false> [typeBuckets]
public class AsyncBatchLoss {
static final int ROWS = 9_742;
public static void main(final String[] args) throws Exception {
final String dir = args[0];
final int runs = Integer.parseInt(args[1]);
final boolean perCommand = Boolean.parseBoolean(args[2]);
final int typeBuckets = args.length > 3 ? Integer.parseInt(args[3]) : 0;
int failed = 0;
System.out.println("# availableProcessors=" + Runtime.getRuntime().availableProcessors() + " java=" + System.getProperty("java.version"));
for (int run = 0; run < runs; run++) {
final String path = dir + "/run" + run;
deleteTree(new File(path));
final AtomicInteger executorErrors = new AtomicInteger();
final AtomicInteger commandErrors = new AtomicInteger();
final AtomicInteger commandOk = new AtomicInteger();
final StringBuilder firstError = new StringBuilder();
long stored;
int buckets;
try (DatabaseFactory factory = new DatabaseFactory(path); Database db = factory.create()) {
db.command("sql", typeBuckets > 0 ? "CREATE DOCUMENT TYPE Bulk4 BUCKETS " + typeBuckets : "CREATE DOCUMENT TYPE Bulk4");
buckets = db.getSchema().getType("Bulk4").getBuckets(false).size();
final DatabaseAsyncExecutor async = db.async();
async.setParallelLevel(4);
async.setCommitEvery(1_000);
async.onError(e -> {
executorErrors.incrementAndGet();
synchronized (firstError) {
if (firstError.length() == 0)
firstError.append(String.valueOf(e)).setLength(Math.min(firstError.length(), 200));
}
});
final AsyncResultsetCallback cb = perCommand ? new AsyncResultsetCallback() {
@Override
public void onComplete(final ResultSet rs) {
commandOk.incrementAndGet();
}
@Override
public void onError(final Exception e) {
commandErrors.incrementAndGet();
}
} : null;
for (int i = 0; i < ROWS; i++)
async.command("sql", "INSERT INTO Bulk4 SET id = :id", cb, Map.of("id", i));
async.waitCompletion();
try (ResultSet rs = db.query("sql", "SELECT count(*) AS c FROM Bulk4")) {
stored = ((Number) rs.next().getProperty("c")).longValue();
}
db.drop();
}
deleteTree(new File(path));
final boolean bad = stored != ROWS || executorErrors.get() != 0;
if (bad)
failed++;
System.out.printf("run=%d buckets=%d stored=%d executorOnError=%d commandOnComplete=%d commandOnError=%d%s%s%n", run, buckets, stored,
executorErrors.get(), commandOk.get(), commandErrors.get(), bad ? " FAIL " : "", bad ? firstError : "");
}
System.out.printf("# SUMMARY runs=%d failed=%d perCommand=%s%n", runs, failed, perCommand);
}
static void deleteTree(final File f) {
if (!f.exists())
return;
final File[] kids = f.listFiles();
if (kids != null)
for (File k : kids)
deleteTree(k);
f.delete();
}
}
Activity
review(#9694): type the in-flight page map and pin its release on eve…
review(#9694): note the window between publish and release of a creat…
review(#9694): count by scanning and read every asserted record back …
review(#9694): fail the regression tests clearly when a worker thread…
fix(#9694): an insert turned away from a reserved page no longer open…
review(#9694): list a rejected page again when its last reservation i…
fix(#9694): relist a released page with its measured free tail
fix(#9694): measure a released page on the next allocation, not at tr…
7 remaining items
fix(ArcadeData#9694): stop concurrent inserts into one bucket from co…
docs: weekly audit fixes 2026-10-13 (#317)
docs: the fixes that shipped in 26.10.2 are no longer "not released y…
docs: the fixes that shipped in 26.10.2 are no longer "not released y…
fix(#9694): stop concurrent inserts into one bucket from conflicting …
review(#9694): type the in-flight page map and pin its release on eve…
review(#9694): note the window between publish and release of a creat…
review(#9694): count by scanning and read every asserted record back …
review(#9694): fail the regression tests clearly when a worker thread…
fix(#9694): an insert turned away from a reserved page no longer open…
review(#9694): list a rejected page again when its last reservation i…
fix(#9694): relist a released page with its measured free tail
fix(#9694): measure a released page on the next allocation, not at tr…
review(#9694): reject a negative insert slot explicitly and bound the…
review(#9694): track a created page before registering it and relist …