devinbost commented on pull request #10758:
URL: https://github.com/apache/pulsar/pull/10758#issuecomment-864319361


   @eolivelli I moved the `pendingAddEntries.add(addOperation)` calls to after 
we're done making changes on the `addOperation` in the different code branches. 
   
   What happens if this block in `[ManagedLedgerImpl].createComplete(..)` is 
called before the thread processing `pendingAddEntries` has had a chance to 
process all the operations (for example, if there was backpressure)?
   ```       if (pendingAddEntries.isEmpty()) {
                   STATE_UPDATER.set(this, State.ClosedLedger);
               } else {
                   STATE_UPDATER.set(this, State.WriteFailed);
               }
   ```
   
(https://github.com/apache/pulsar/blob/380cf924f81a906759811b7a5e861ca66bb2c7ab/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1403)
   
   Seems like a race... The state could be set to `State.WriteFailed` when in 
reality the `addOperation` just hasn't been processed yet. If they're set to 
WriteFailed, what happens? Do they get automatically reprocessed? I wonder if 
there could be an edge case there. 


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