retry creating snapshot

This commit is contained in:
2025-02-22 18:44:28 +01:00
parent f5c815f02a
commit dfa2fe78bd
2 changed files with 18 additions and 2 deletions

View File

@@ -50,7 +50,12 @@ public class JObjectManager {
public TransactionPrivate createTransaction() {
verifyReady();
return transactionFactory.createTransaction(_txCounter.get());
while (true) {
try {
return transactionFactory.createTransaction(_txCounter.get());
} catch (SnapshotManager.IllegalSnapshotIdException ignored) {
}
}
}
public TransactionHandle commit(TransactionPrivate tx) {

View File

@@ -143,6 +143,17 @@ public class SnapshotManager {
}
}
public static class IllegalSnapshotIdException extends IllegalArgumentException {
public IllegalSnapshotIdException(String message) {
super(message);
}
@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
}
public class Snapshot implements AutoCloseableNoThrow {
private final long _id;
private static final Cleaner CLEANER = Cleaner.create();
@@ -157,7 +168,7 @@ public class SnapshotManager {
synchronized (SnapshotManager.this) {
verify();
if (_lastSnapshotId > id)
throw new IllegalArgumentException("Snapshot id less than last? " + id + " vs " + _lastSnapshotId);
throw new IllegalSnapshotIdException("Snapshot id " + id + " is less than last snapshot id " + _lastSnapshotId);
_lastSnapshotId = id;
if (_lastAliveSnapshotId == -1)
_lastAliveSnapshotId = id;