Reidddddd opened a new issue, #3812:
URL: https://github.com/apache/bookkeeper/issues/3812

   **BUG REPORT**
   
   ***Describe the bug***
   
   Each time after a ledger is created, there will be one more orphan ledger 
with size 0 created as well, which can't be tracked.
   
   ***To Reproduce***
   
   Steps to reproduce the behavior:
   1. list ledgers before creation
   2. DistributedLogManager#openLogWriter
   3. LogWriter#write(LogRecord)
   4. LogWriter#close
   5. list ledgers. Compared with 1. you will find 2 more ledgers
   
   ***Expected behavior***
   
   Should be only 1 ledger
   
   ***Screenshots***
   
   N/A
   
   ***Root Cause***
   
   The root cause lies in the **BKLogWriteHandler#doStartLogSegment**
   line 571: it calls **logSegmentAllocator.allocate();**, which is, in fact, 
SimpleLedgerAllocator#allocate.
        then inside SimpleLedgerAllocator#allocate, whenComplete -> onSuccess, 
it will mark phase: **ALLOCATED**,
        but just one line after, inside **completeAllocation**, it adds one 
ZKSetVersionTxn (together with SimpleLedgerAllocator as listner) and marks the 
phase back to **HANDING_OVER**
   So here now we back to **BKLogWriteHandler#doStartLogSegment**,
   line 579, started a ZK Transactiion
   line 661, txn.execute -> ZKTransaction#processResult -> 
ZKSetVersionTxn#commitOpResult -> listener#onCommit() (listener is 
SimpleLedgerAllocator, so it is SimpleLedgerAllocator#onCommit) --> 
SimpleLedgerAllocator#confirmObtain.
   In side, SimpleLedgerAllocator#confirmObtain, as the phase is changed back 
to **HANDING_OVER**, there **shouldAllocate = true;**, and this is the where 
the orphan ledger comes from
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to