less commitSnapshots created

This commit is contained in:
2025-08-22 23:19:39 +02:00
parent 19016d5e46
commit acf2ae2cef
2 changed files with 13 additions and 2 deletions

View File

@@ -307,6 +307,15 @@ public class WritebackObjectPersistentStore {
return r -> asyncFence(bundleId, r); return r -> asyncFence(bundleId, r);
} }
/**
* Get the last committed transaction ID.
*
* @return the last committed transaction ID
*/
public long getLastCommitId() {
return _lastCommittedId.get();
}
/** /**
* Get a snapshot of the persistent store, including the pending writes. * Get a snapshot of the persistent store, including the pending writes.
* *

View File

@@ -165,7 +165,6 @@ public class TransactionService {
toUnlock.add(lock); toUnlock.add(lock);
} }
commitSnapshot = writebackObjectPersistentStore.getSnapshot();
} else { } else {
Log.trace("Committing transaction - no changes"); Log.trace("Committing transaction - no changes");
@@ -201,7 +200,10 @@ public class TransactionService {
Log.trace("Committing transaction start"); Log.trace("Committing transaction start");
var snapshotId = tx.snapshot().id(); var snapshotId = tx.snapshot().id();
if (snapshotId != commitSnapshot.id()) { // All dependencies are locked and could not be changed concurrently now
if (snapshotId != writebackObjectPersistentStore.getLastCommitId()) {
commitSnapshot = writebackObjectPersistentStore.getSnapshot();
for (var read : readSet.entrySet()) { for (var read : readSet.entrySet()) {
var current = commitSnapshot.readObject(read.getKey()); var current = commitSnapshot.readObject(read.getKey());