Skip to content

Commit aa6bce2

Browse files
committed
clean up read transactions more proactively
1 parent cab792b commit aa6bce2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStore.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,12 @@ void endTransaction(boolean commit) throws IOException {
12521252

12531253
public void commit() throws IOException {
12541254
endTransaction(true);
1255+
threadLocalReadTxn.get().close();
12551256
}
12561257

12571258
public void rollback() throws IOException {
12581259
endTransaction(false);
1260+
threadLocalReadTxn.get().close();
12591261
}
12601262

12611263
/**
@@ -1315,9 +1317,6 @@ private void closeReadTransactions() {
13151317
ReadTxn[] snapshot = readTransactions.toArray(new ReadTxn[0]);
13161318
for (ReadTxn readTxn : snapshot) {
13171319
readTxn.close();
1318-
if (readTransactions.remove(readTxn)) {
1319-
readTxn.unregister();
1320-
}
13211320
}
13221321
threadLocalReadTxn.remove();
13231322
} finally {
@@ -1464,13 +1463,17 @@ private void registerIfNeeded() {
14641463
}
14651464

14661465
private void unregister() {
1466+
readTransactions.remove(this);
14671467
registered = false;
14681468
}
14691469

14701470
private void closeInternal() {
14711471
if (state.initialized) {
14721472
cleaner.clean();
14731473
}
1474+
if (registered) {
1475+
unregister();
1476+
}
14741477
}
14751478

14761479
void close() {

0 commit comments

Comments
 (0)