More lmdb logs

This commit is contained in:
2025-05-14 11:18:05 +02:00
parent d1df6b705f
commit 2206c13466

View File

@@ -67,12 +67,15 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
Log.info("Initializing with root " + _root);
_root.toFile().mkdirs();
}
Log.info("Opening LMDB with root " + _root);
_env = create()
.setMapSize(lmdbSize)
.setMaxDbs(1)
.open(_root.toFile(), EnvFlags.MDB_NOTLS);
_db = _env.openDbi(DB_NAME, MDB_CREATE);
Log.info("Opened LMDB with root " + _root);
try (Txn<ByteBuffer> txn = _env.txnWrite()) {
var read = readTxId(txn);
if (read.isPresent()) {
@@ -87,6 +90,7 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
}
_ready = true;
Log.info("LMDB storage ready");
}
private Optional<Long> readTxId(Txn<ByteBuffer> txn) {
@@ -95,6 +99,9 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
}
void shutdown(@Observes @Priority(900) ShutdownEvent event) throws IOException {
if (!_ready) {
return;
}
_ready = false;
_db.close();
_env.close();
@@ -112,6 +119,7 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
*/
@Override
public Snapshot<JObjectKey, ByteBuffer> getSnapshot() {
verifyReady();
var txn = _env.txnRead();
try {
long commitId = readTxId(txn).orElseThrow();