Quick fix
This commit is contained in:
parent
a80849f241
commit
8075694e15
@ -894,7 +894,7 @@ public class LLLocalDictionary implements LLDictionary {
|
||||
private long exactSizeAll(@Nullable LLSnapshot snapshot) {
|
||||
var readOpts = resolveSnapshot(snapshot);
|
||||
readOpts.setFillCache(false);
|
||||
readOpts.setReadaheadSize(2 * 1024 * 1024);
|
||||
// readOpts.setReadaheadSize(2 * 1024 * 1024);
|
||||
readOpts.setVerifyChecksums(VERIFY_CHECKSUMS_WHEN_NOT_NEEDED);
|
||||
|
||||
if (PARALLEL_EXACT_SIZE) {
|
||||
|
@ -43,7 +43,7 @@ public class LLLocalKeyPrefixReactiveRocksIterator {
|
||||
.generate(() -> {
|
||||
var readOptions = new ReadOptions(this.readOptions);
|
||||
if (!range.hasMin() || !range.hasMax()) {
|
||||
readOptions.setReadaheadSize(2 * 1024 * 1024);
|
||||
// readOptions.setReadaheadSize(2 * 1024 * 1024);
|
||||
readOptions.setFillCache(false);
|
||||
}
|
||||
Slice sliceMin;
|
||||
|
@ -27,6 +27,7 @@ import org.rocksdb.BlockBasedTableConfig;
|
||||
import org.rocksdb.BloomFilter;
|
||||
import org.rocksdb.ColumnFamilyDescriptor;
|
||||
import org.rocksdb.ColumnFamilyHandle;
|
||||
import org.rocksdb.CompactRangeOptions;
|
||||
import org.rocksdb.CompactionStyle;
|
||||
import org.rocksdb.CompressionType;
|
||||
import org.rocksdb.DBOptions;
|
||||
@ -37,6 +38,8 @@ import org.rocksdb.RocksDB;
|
||||
import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.Snapshot;
|
||||
import org.rocksdb.WALRecoveryMode;
|
||||
import org.warp.commonutils.log.Logger;
|
||||
import org.warp.commonutils.log.LoggerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
@ -47,6 +50,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(LLLocalKeyValueDatabase.class);
|
||||
private static final ColumnFamilyDescriptor DEFAULT_COLUMN_FAMILY = new ColumnFamilyDescriptor(
|
||||
RocksDB.DEFAULT_COLUMN_FAMILY);
|
||||
private static final Supplier<Scheduler> lowMemorySupplier = Suppliers.memoize(() ->
|
||||
@ -101,6 +105,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
||||
this.handles.put(columns.get(i), handles.get(i));
|
||||
}
|
||||
|
||||
compactDb(db, handles);
|
||||
flushDb(db, handles);
|
||||
} catch (RocksDBException ex) {
|
||||
throw new IOException(ex);
|
||||
@ -133,6 +138,27 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
||||
// end force flush
|
||||
}
|
||||
|
||||
private void compactDb(RocksDB db, List<ColumnFamilyHandle> handles) throws RocksDBException {
|
||||
// force compact the database
|
||||
for (ColumnFamilyHandle cfh : handles) {
|
||||
var t = new Thread(() -> {
|
||||
try {
|
||||
// Range rangeToCompact = db.suggestCompactRange(cfh);
|
||||
db.compactRange(cfh, null, null, new CompactRangeOptions().setAllowWriteStall(false).setChangeLevel(false));
|
||||
} catch (RocksDBException e) {
|
||||
if ("Database shutdown".equalsIgnoreCase(e.getMessage())) {
|
||||
logger.warn("Compaction cancelled: database shutdown");
|
||||
} else {
|
||||
logger.warn("Failed to compact range", e);
|
||||
}
|
||||
}
|
||||
}, "Compaction");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
// end force compact
|
||||
}
|
||||
|
||||
@SuppressWarnings("CommentedOutCode")
|
||||
private static Options openRocksDb(Path path, boolean crashIfWalError, boolean lowMemory)
|
||||
throws IOException {
|
||||
@ -415,7 +441,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Error when deleting unused log files", ex);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
@ -637,12 +637,14 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
||||
public Mono<Void> close() {
|
||||
return Mono
|
||||
.<Void>fromCallable(() -> {
|
||||
logger.debug("Closing IndexWriter...");
|
||||
this.blockingLuceneSearchScheduler.dispose();
|
||||
scheduledTasksLifecycle.cancelAndWait();
|
||||
//noinspection BlockingMethodInNonBlockingContext
|
||||
indexWriter.close();
|
||||
//noinspection BlockingMethodInNonBlockingContext
|
||||
directory.close();
|
||||
logger.debug("IndexWriter closed");
|
||||
return null;
|
||||
})
|
||||
.subscribeOn(luceneHeavyTasksScheduler);
|
||||
|
@ -38,7 +38,7 @@ public abstract class LLLocalReactiveRocksIterator<T> {
|
||||
.generate(() -> {
|
||||
var readOptions = new ReadOptions(this.readOptions);
|
||||
if (!range.hasMin() || !range.hasMax()) {
|
||||
readOptions.setReadaheadSize(2 * 1024 * 1024);
|
||||
// readOptions.setReadaheadSize(2 * 1024 * 1024);
|
||||
readOptions.setFillCache(false);
|
||||
}
|
||||
Slice sliceMin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user