Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix producer stucks on creating ledger timeout (apache#7319)
* Fix producer stucks on creating ledger timeout *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. * Change to use CAS
- Loading branch information