Avoid closing things that have already been closed
This commit is contained in:
parent
6315175dc4
commit
e86965efa7
@ -471,27 +471,47 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
|||||||
|
|
||||||
private void flushAndCloseDb(RocksDB db, List<ColumnFamilyHandle> handles)
|
private void flushAndCloseDb(RocksDB db, List<ColumnFamilyHandle> handles)
|
||||||
throws RocksDBException {
|
throws RocksDBException {
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
flushDb(db, handles);
|
flushDb(db, handles);
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (ColumnFamilyHandle handle : handles) {
|
for (ColumnFamilyHandle handle : handles) {
|
||||||
try {
|
try {
|
||||||
handle.close();
|
if (handle.isOwningHandle()) {
|
||||||
|
handle.close();
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("Can't close column family", ex);
|
logger.error("Can't close column family", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
db.closeE();
|
db.closeE();
|
||||||
} catch (RocksDBException ex) {
|
} catch (RocksDBException ex) {
|
||||||
if ("Cannot close DB with unreleased snapshot.".equals(ex.getMessage())) {
|
if ("Cannot close DB with unreleased snapshot.".equals(ex.getMessage())) {
|
||||||
snapshotsHandles.forEach((id, snapshot) -> {
|
snapshotsHandles.forEach((id, snapshot) -> {
|
||||||
try {
|
try {
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!snapshot.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
db.releaseSnapshot(snapshot);
|
db.releaseSnapshot(snapshot);
|
||||||
} catch (Exception ex2) {
|
} catch (Exception ex2) {
|
||||||
// ignore exception
|
// ignore exception
|
||||||
logger.debug("Failed to release snapshot " + id, ex2);
|
logger.debug("Failed to release snapshot " + id, ex2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
db.closeE();
|
db.closeE();
|
||||||
}
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
@ -897,6 +917,12 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
|||||||
if (dbSnapshot == null) {
|
if (dbSnapshot == null) {
|
||||||
throw new IOException("Snapshot " + snapshot.getSequenceNumber() + " not found!");
|
throw new IOException("Snapshot " + snapshot.getSequenceNumber() + " not found!");
|
||||||
}
|
}
|
||||||
|
if (!db.isOwningHandle()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!dbSnapshot.isOwningHandle()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
db.releaseSnapshot(dbSnapshot);
|
db.releaseSnapshot(dbSnapshot);
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user