sijie opened a new pull request #7319:
URL: https://github.com/apache/pulsar/pull/7319


   *Motivation*
   
   The `ledgerCreated` flag is passed as ctx to the createLedger callback.
   The callback already had the logic on handling `ledgerCreated` flag. But we 
set the flag to `false`
   when timeout happens. It will trigger the following race condition:
   
   a) The createComplete callback is triggered when timeout. But the pending 
add requests are not error'd out.
   b) If the createComplete callback eventually completes, it will see 
`ledgerCreated` flag is set to true,
   so it will cause `checkAndCompleteLedgerOpTask` returns false and exist too 
early without processing the
   pending add requests.
   
   This race condition only happens when creating ledger times out.
   
   ```
       public synchronized void createComplete(int rc, final LedgerHandle lh, 
Object ctx) {
           if (log.isDebugEnabled()) {
               log.debug("[{}] createComplete rc={} ledger={}", name, rc, lh != 
null ? lh.getId() : -1);
           }
   
           if (checkAndCompleteLedgerOpTask(rc, lh, ctx)) {
               return;
           }
   ```
   
   *Modification*
   
   The timeout logic shouldn't modify the `ledgerCreated` context. It should 
let the callback itself to process
   the `ledgerCreated` context.
   
   


----------------------------------------------------------------
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.

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


Reply via email to