This commit is contained in:
Andrea Cavalli 2024-11-25 21:57:10 +01:00
parent e3abbd0bfa
commit ccd84e729e

View File

@ -173,6 +173,8 @@ public class EmbeddedDB implements RocksDBSyncAPI, InternalConnection, Closeable
logger.debug("Cleaning expired transactions...");
var idsToRemove = new LongArrayList();
var startTime = System.currentTimeMillis();
ops.beginOp();
try {
EmbeddedDB.this.txs.forEach(((txId, tx) -> {
if (startTime >= tx.expirationTimestamp()) {
idsToRemove.add((long) txId);
@ -188,6 +190,9 @@ public class EmbeddedDB implements RocksDBSyncAPI, InternalConnection, Closeable
}
}
});
} finally {
ops.endOp();
}
var endTime = System.currentTimeMillis();
var removedCount = idsToRemove.size();
if (removedCount > 2) {
@ -202,6 +207,8 @@ public class EmbeddedDB implements RocksDBSyncAPI, InternalConnection, Closeable
logger.debug("Cleaning expired iterators...");
var idsToRemove = new LongArrayList();
var startTime = System.currentTimeMillis();
ops.beginOp();
try {
EmbeddedDB.this.its.forEach(((itId, entry) -> {
if (entry.expirationTimestamp() != null && startTime >= entry.expirationTimestamp()) {
idsToRemove.add((long) itId);
@ -217,6 +224,9 @@ public class EmbeddedDB implements RocksDBSyncAPI, InternalConnection, Closeable
}
}
});
} finally {
ops.endOp();
}
var endTime = System.currentTimeMillis();
var removedCount = idsToRemove.size();
if (removedCount > 2) {