Merge remote-tracking branch 'origin/sync-grpc' into sync-grpc

This commit is contained in:
Andrea Cavalli 2024-09-23 11:17:34 +02:00
commit 1ca62c5813
2 changed files with 5 additions and 2 deletions

View File

@ -431,8 +431,8 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
var key = keyIt.next(); var key = keyIt.next();
var value = valusIt.next(); var value = valusIt.next();
put(arena, wb, col, 0, key, value, requestType); put(arena, wb, col, 0, key, value, requestType);
wb.write(db.get());
} }
wb.write(db.get());
} }
return List.of(); return List.of();
} catch (it.cavallium.rockserver.core.common.RocksDBException ex) { } catch (it.cavallium.rockserver.core.common.RocksDBException ex) {

View File

@ -7,9 +7,9 @@ import org.rocksdb.WriteBatch;
import org.rocksdb.WriteOptions; import org.rocksdb.WriteOptions;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException;
public record WB(@NotNull WriteBatch wb) implements Closeable, TxOrWb { public record WB(@NotNull WriteBatch wb) implements Closeable, TxOrWb {
private static final boolean MIGRATE = Boolean.parseBoolean(System.getProperty("rocksdb.migrate", "false"));
@Override @Override
public void close() { public void close() {
wb.close(); wb.close();
@ -17,6 +17,9 @@ public record WB(@NotNull WriteBatch wb) implements Closeable, TxOrWb {
public void write(RocksDB rocksDB) throws RocksDBException { public void write(RocksDB rocksDB) throws RocksDBException {
try (var w = new WriteOptions()) { try (var w = new WriteOptions()) {
if (MIGRATE) {
w.setDisableWAL(true);
}
rocksDB.write(w, wb); rocksDB.write(w, wb);
} catch (org.rocksdb.RocksDBException e) { } catch (org.rocksdb.RocksDBException e) {
throw RocksDBException.of(RocksDBException.RocksDBErrorType.WRITE_BATCH_1, e); throw RocksDBException.of(RocksDBException.RocksDBErrorType.WRITE_BATCH_1, e);