You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Core dumps are triggered by rocksdb compacting when shutdown the bookkeeper #4705
Core dumps are triggered rocksdb compacting when shutdown the bookkeeper process
[db-storage-cleanup-23-1:SingleDirectoryDbLedgerStorage@329] - Failed to trigger entry location index RocksDB compact
java.io.IOException: Error in RocksDB compact
at org.apache.bookkeeper.bookie.storage.ldb.KeyValueStorageRocksDB.compact(KeyValueStorageRocksDB.java:415)
at org.apache.bookkeeper.bookie.storage.ldb.EntryLocationIndex.compact(EntryLocationIndex.java:200)
at org.apache.bookkeeper.bookie.storage.ldb.SingleDirectoryDbLedgerStorage.lambda$entryLocationCompact$6(SingleDirectoryDbLedgerStorage.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:833)
Caused by: org.rocksdb.RocksDBException: Database shutdown
at org.rocksdb.RocksDB.compactRange(Native Method)
at org.rocksdb.RocksDB.compactRange(RocksDB.java:3344)
at org.rocksdb.RocksDB.compactRange(RocksDB.java:3319)
at org.apache.bookkeeper.bookie.storage.ldb.KeyValueStorageRocksDB.compact(KeyValueStorageRocksDB.java:407)
To Reproduce
Steps to reproduce the behavior:
Setting entryLocationCompactionInterval in bk_server.conf to enable entryLocationCompaction
Start the bookkeeper
Try to shutdown the bookkeeper when GarbageCollectorThread is running
We also hit shutdown crashes with entryLocationCompactionInterval enabled. Sharing what we observed; it looks related to this issue but is a different stack.
The stack in the issue body is a caught RocksDBException: Database shutdown from entryLocationCompact → compactRange. In our environment the JVM SIGSEGV'd. The crashing thread was always db-storage-cleanup-* (the single-thread cleanupExecutor), and the Java frames were the checkpoint cleanup task queued on that executor, not compact:
SingleDirectoryDbLedgerStorage.lambda$checkpoint$9
→ EntryLocationIndex.removeOffsetFromDeletedLedgers
→ RocksDBBatch.flush → RocksDB.write0 // locations DB
// or
→ LedgerMetadataIndex.removeDeletedLedgers
→ KeyValueStorageRocksDB.delete → rocksdb_delete_helper // ledgers DB
What we saw:
entryLocationCompact() submits a sync compactRange() onto cleanupExecutor and occupies that thread for a long time.
checkpoint() / flush()finally submits a different task onto the same executor: removeOffsetFromDeletedLedgers() then removeDeletedLedgers(). That task sits in the ThreadPoolExecutor queue behind compact.
SingleDirectoryDbLedgerStorage.shutdown() does cleanupExecutor.shutdown() + awaitTermination(1, SECONDS) (return value unused), then ledgerIndex.close() and entryLocationIndex.close().
#4706 looks helpful for the compactRange vs close case in this issue. For our queued-checkpoint-cleanup SIGSEGV, we are not sure it would fix the scenario: close() waits on the compacting flag rather than draining cleanupExecutor, so after compact finishes the checkpoint cleanup task may still run, and ledgerIndex.close() still happens first. Happy to share more stacks if useful.
Activity
yangxianjungree commentedon Aug 27, 2026
We also hit shutdown crashes with
entryLocationCompactionIntervalenabled. Sharing what we observed; it looks related to this issue but is a different stack.The stack in the issue body is a caught
RocksDBException: Database shutdownfromentryLocationCompact→compactRange. In our environment the JVM SIGSEGV'd. The crashing thread was alwaysdb-storage-cleanup-*(the single-threadcleanupExecutor), and the Java frames were the checkpoint cleanup task queued on that executor, not compact:What we saw:
entryLocationCompact()submits a synccompactRange()ontocleanupExecutorand occupies that thread for a long time.checkpoint()/flush()finallysubmits a different task onto the same executor:removeOffsetFromDeletedLedgers()thenremoveDeletedLedgers(). That task sits in theThreadPoolExecutorqueue behind compact.SingleDirectoryDbLedgerStorage.shutdown()doescleanupExecutor.shutdown()+awaitTermination(1, SECONDS)(return value unused), thenledgerIndex.close()andentryLocationIndex.close().flush()/delete(). Those write paths are not covered by theclosedLockthat PR Fix the coredump that occurs when calling KeyValueStorageRocksDB.count after rocksdb has been closed #4581 added forcount(). We then get a native write/delete vs close race. Compact widened the window; it was not the crashing frame.#4706 looks helpful for the
compactRangevs close case in this issue. For our queued-checkpoint-cleanup SIGSEGV, we are not sure it would fix the scenario:close()waits on thecompactingflag rather than drainingcleanupExecutor, so after compact finishes the checkpoint cleanup task may still run, andledgerIndex.close()still happens first. Happy to share more stacks if useful.