Flush before exit

This commit is contained in:
Andrea Cavalli 2024-03-30 03:40:02 +01:00
parent ea6808948b
commit 0c98f6ef29

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.rocksdb.ColumnFamilyDescriptor; import org.rocksdb.ColumnFamilyDescriptor;
import org.rocksdb.ColumnFamilyHandle; import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.FlushOptions;
import org.rocksdb.OptimisticTransactionDB; import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.OptimisticTransactionOptions; import org.rocksdb.OptimisticTransactionOptions;
import org.rocksdb.RocksDB; import org.rocksdb.RocksDB;
@ -155,6 +156,16 @@ public sealed interface TransactionalDB extends Closeable {
exceptions.add(ex); exceptions.add(ex);
} }
} }
try {
db.flushWal(true);
} catch (RocksDBException e) {
exceptions.add(e);
}
try (var options = new FlushOptions().setWaitForFlush(true).setAllowWriteStall(true)) {
db.flush(options);
} catch (RocksDBException e) {
exceptions.add(e);
}
try { try {
db.closeE(); db.closeE();
} catch (RocksDBException e) { } catch (RocksDBException e) {