Using the java library, can any configuration changes take effect without requiring a reopen of the database? For example the level0SlowdownWritesTrigger
.
More context: I'm trying to flip between a bulk-load mode and regular mode. e.g. Disable autocompaction when the app starts up, load the data, then enable autocompaction. In testing this has given me a 75% reduction in initial load time.
The problem is that changes to the Options
don't take effect, at least in the way I'm making them. I don't want to have to reopen the database, because that complicates existing data flow handling.
Sample code I've tried. In this example, I'm changing the auto compaction settings in the options.
import org.rocksdb.ColumnFamilyOptions
import org.rocksdb.DBOptions
import org.rocksdb.Options
import org.rocksdb.RocksDB
class ExampleRocksDbStore(
private val dataDirectory: String,
private val configureOptions: (options: Options) -> Unit = {},
) {
val db: RocksDB
val options: Options
init {
RocksDB.loadLibrary()
ColumnFamilyOptions().use { cfOpts ->
val dbOptions = DBOptions()
options = Options(dbOptions, cfOpts).apply {
setCreateIfMissing(true)
setCreateMissingColumnFamilies(true)
}
configureOptions(options)
db = RocksDB.open(options, dataDirectory)
}
}
fun enableAutoCompaction() {
options.setDisableAutoCompactions(false)
}
fun disableAutoCompaction() {
options.setDisableAutoCompactions(true)
}
}
Dynamically changeable options are a thing, the Basic Operations wiki mentions them:
Some options can be changed dynamically while DB is running. For example: ...
The only record I can find of which options these are is in options.h
here, there are multiple options tagged with "// Dynamically changeable through SetOptions() API", and disable_automatic_compactions
is one of them.
So I think you just need to change your Options
object, then call setOptions()
on your RocksDB instance, unless you're already doing that and it's not working?