Avoid crashes during sst errors
This commit is contained in:
parent
77f3e012ce
commit
4e14ae77db
@ -440,6 +440,7 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
||||
try {
|
||||
var cf = new CompletableFuture<Void>();
|
||||
batchPublisher.subscribe(new Subscriber<>() {
|
||||
private boolean stopped;
|
||||
private Subscription subscription;
|
||||
private ColumnInstance col;
|
||||
private ArrayList<AutoCloseable> refs;
|
||||
@ -476,6 +477,9 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
||||
|
||||
@Override
|
||||
public void onNext(KVBatch kvBatch) {
|
||||
if (stopped) {
|
||||
return;
|
||||
}
|
||||
var keyIt = kvBatch.keys().iterator();
|
||||
var valueIt = kvBatch.values().iterator();
|
||||
try (var arena = Arena.ofConfined()) {
|
||||
@ -516,6 +520,7 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
||||
}
|
||||
|
||||
private void doFinally() {
|
||||
stopped = true;
|
||||
for (int i = refs.size() - 1; i >= 0; i--) {
|
||||
try {
|
||||
var c = refs.get(i);
|
||||
|
@ -85,7 +85,6 @@ public record SSTWriter(RocksDB db, it.cavallium.rockserver.core.impl.ColumnInst
|
||||
|
||||
public void put(byte[] key, byte[] value) throws RocksDBException {
|
||||
try {
|
||||
checkOwningHandle();
|
||||
sstFileWriter.put(key, value);
|
||||
} catch (org.rocksdb.RocksDBException e) {
|
||||
throw RocksDBException.of(RocksDBException.RocksDBErrorType.PUT_UNKNOWN_ERROR, e);
|
||||
@ -94,7 +93,6 @@ public record SSTWriter(RocksDB db, it.cavallium.rockserver.core.impl.ColumnInst
|
||||
|
||||
public void put(ByteBuffer key, ByteBuffer value) throws RocksDBException {
|
||||
try {
|
||||
checkOwningHandle();
|
||||
sstFileWriter.put(key, value);
|
||||
} catch (org.rocksdb.RocksDBException e) {
|
||||
throw RocksDBException.of(RocksDBException.RocksDBErrorType.PUT_UNKNOWN_ERROR, e);
|
||||
|
Loading…
Reference in New Issue
Block a user