Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class RocksDB(
logInfo(log"Loading ${MDC(LogKeys.VERSION_NUM, version)}")
try {
if (loadedVersion != version) {
closeDB()
closeDB(ignoreException = false)
// deep copy is needed to avoid race condition
// between maintenance and task threads
fileManager.copyFileMapping()
Expand Down Expand Up @@ -945,13 +945,17 @@ class RocksDB(
logInfo(log"Opened DB with conf ${MDC(LogKeys.CONFIG, conf)}")
}

private def closeDB(): Unit = {
private def closeDB(ignoreException: Boolean = true): Unit = {
if (db != null) {

// Cancel and wait until all background work finishes
db.cancelAllBackgroundWork(true)
// Close the DB instance
db.close()
if (ignoreException) {
// Close the DB instance
db.close()
} else {
// Close the DB instance and throw the exception if any
db.closeE()
}
db = null
}
}
Expand Down