Deadlock occurred when entryLogPerLedgerEnabled is true
- Dominant language
- Java
- Stars
- 2k
- Forks
- 976
- Avg merge
- 6d 15h
- Merged PRs (30d)
- 7
Description
**BUG REPORT**
Recently I'm doing benchmark on bookie with entryLogPerLedgerEnabled = true, I found the process happened deadlock and hence cann't service normally, here is the threaddump information while error occured.


Bookkeer Versoin: 4.15.0
Here is our customize configuration
`ledgerStorageClass=org.apache.bookkeeper.bookie.SortedLedgerStorage`
`entryLogPerLedgerEnabled=true`
`maximumNumberOfActiveEntryLogs=10000`
It seems caused by acquire lock while EntryMemTableParallelFlusher is running , and the deadlock may happen like this
1. Memtable reach size limit
2. ledger A and ledger B start flush asynchronous, and they both acquire lock successfully
3. when thread enters getCurrentLogWithDirInfoForLedger method, it will calls ledgerIdEntryLogMap#get(ledgerId), if ledgerIdEntryLogMap is out of capacity and trigger cleanup ledger A、B, thus onCacheEntryRemoval is invoked, this method attempt to acquire lock , Note if thread A(thread which run ledger A) exactly execute cleanup ledger B ,and thread B execute cleanup ledger A, deadlock is happened.


Contributor guide
Assessment
This issue has not been assessed yet.