From b9faeb020eec15d32804af9e57d57e9c0e084a00 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Sun, 22 Sep 2024 11:56:43 +0200 Subject: [PATCH] Fix write batches --- .../java/it/cavallium/rockserver/core/impl/EmbeddedDB.java | 2 +- .../java/it/cavallium/rockserver/core/impl/rocksdb/WB.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java b/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java index 348dd00..9c5957e 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/EmbeddedDB.java @@ -431,8 +431,8 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable { var key = keyIt.next(); var value = valusIt.next(); put(arena, wb, col, 0, key, value, requestType); - wb.write(db.get()); } + wb.write(db.get()); } return List.of(); } catch (it.cavallium.rockserver.core.common.RocksDBException ex) { diff --git a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/WB.java b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/WB.java index 3a6cbfc..c017889 100644 --- a/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/WB.java +++ b/src/main/java/it/cavallium/rockserver/core/impl/rocksdb/WB.java @@ -7,9 +7,9 @@ import org.rocksdb.WriteBatch; import org.rocksdb.WriteOptions; import java.io.Closeable; -import java.io.IOException; public record WB(@NotNull WriteBatch wb) implements Closeable, TxOrWb { + private static final boolean MIGRATE = Boolean.parseBoolean(System.getProperty("rocksdb.migrate", "false")); @Override public void close() { wb.close(); @@ -17,6 +17,9 @@ public record WB(@NotNull WriteBatch wb) implements Closeable, TxOrWb { public void write(RocksDB rocksDB) throws RocksDBException { try (var w = new WriteOptions()) { + if (MIGRATE) { + w.setDisableWAL(true); + } rocksDB.write(w, wb); } catch (org.rocksdb.RocksDBException e) { throw RocksDBException.of(RocksDBException.RocksDBErrorType.WRITE_BATCH_1, e);