From 0c98f6ef29bc06d159113cca39e0fdbe4ec3cd6b Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Sat, 30 Mar 2024 03:40:02 +0100 Subject: [PATCH] Flush before exit --- .../rockserver/core/impl/rocksdb/TransactionalDB.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/TransactionalDB.java b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/TransactionalDB.java index 82ed537..ee17318 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/TransactionalDB.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/TransactionalDB.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import org.rocksdb.ColumnFamilyDescriptor; import org.rocksdb.ColumnFamilyHandle; +import org.rocksdb.FlushOptions; import org.rocksdb.OptimisticTransactionDB; import org.rocksdb.OptimisticTransactionOptions; import org.rocksdb.RocksDB; @@ -155,6 +156,16 @@ public sealed interface TransactionalDB extends Closeable { 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 { db.closeE(); } catch (RocksDBException e) {