GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — [fix][client] Fix ACK timeout backoff deadlocks during receive and redelivery by void-ptr974 · Pull Request #27065 · apache/pulsar Conversation
|
| Step | ACK timeout timer thread | Consumer operation thread |
|---|---|---|
| 1 | Acquires T and selects due messages | |
| 2 | Holds T | Acquires C in messageProcessed() or explicit redelivery |
| 3 | Holds T | Calls tracker.add() or tracker.clear() and waits for T, retaining C |
| 4 | Enters full consumer redelivery and waits for C, retaining T | Holds C and waits for T |
Both threads retain their first lock while waiting for the lock owned by the other, so neither can progress. This cycle can occur in a normal receive loop as well as during explicit redelivery. It is the same consumer/tracker lock inversion previously addressed in the non-backoff tracker by #10768.
onAckTimeoutSend() and consumer redelivery, matching UnAckedMessageTracker.With this ordering, a timer thread waiting for C no longer holds T. The consumer operation can acquire T, finish its tracker update, and release C, allowing timeout redelivery to continue.
Added deterministic regression coverage for both consumer callbacks and for receive processing / explicit redelivery on both Exclusive and Failover subscriptions.
ThreadMXBean confirms that timeout redelivery is actually waiting for the consumer monitor. While owning that monitor, the test probes the tracker lock with tryLock() before executing the consumer operation. The unfixed implementation fails at this bounded probe without leaving deadlocked test threads. The receive-processing cases call the real synchronized messageProcessed() method shared by receive() and receiveAsync(). Subsequent timer ticks must still progress.
Local validation with test retries disabled:
quickCheck passed../gradlew :pulsar-client-original:test \ --tests org.apache.pulsar.client.impl.UnAckedMessageRedeliveryTrackerTest \ --tests org.apache.pulsar.client.impl.UnAckedMessageTrackerTest \ --tests org.apache.pulsar.client.impl.UnAckedTopicMessageRedeliveryTrackerTest \ quickCheck -PtestRetryCount=0 -PtestFailFast=false ./gradlew :pulsar-broker:test \ --tests org.apache.pulsar.client.impl.ConsumerDedupPermitsUpdateTest \ --tests org.apache.pulsar.client.impl.UnAcknowledgedMessagesTimeoutTest.testCheckUnAcknowledgedMessageRedeliveryTimer \ -PtestRetryCount=0 -PtestFailFast=false
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…plicit redelivery Invoke ACK timeout callbacks after releasing the backoff tracker write lock so timeout and explicit redelivery cannot invert tracker and consumer locks. Add deterministic Exclusive and Failover monitor-contention tests and verify that both consumer callbacks run outside the tracker write lock. Assisted-by: OpenAI Codex
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Releasing the tracker write lock before onAckTimeoutSend() / redeliverUnacknowledgedMessages() makes the backoff tracker follow the same pattern UnAckedMessageTracker has used since #10768, which fixed the same lock-order inversion with the consumer monitor. Due IDs are still collected/removed and the next tick is still scheduled under the lock, so tracker state and close() cancellation stay consistent. The new interleaving (ack/clear between collection and redelivery) is the same one the non-backoff tracker already allows.
Verified locally on this head: the 3 focused test classes pass (7/7). Against the pre-PR tracker, testConcurrentExplicitRedelivery[Exclusive] and testConsumerCallbacksRunWithoutTrackerLock fail at the intended assertions without hanging, so the new tests do cover the regression.
A couple of non-blocking comments inline. Also, CI - Unit - Brokers - Client Impl failed on this run; please check/rerun it to confirm it's unrelated before merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…ssion Exercise Exclusive and Failover consumers with both receive processing and explicit redelivery while timeout redelivery waits for the consumer monitor. Use persistent topics and the consumer tracking path so the regression models reachable ACK-timeout behavior after merging master. Document the common lock-order rule and use threadId in the Java 21 tests. Assisted-by: Codex
|
Thanks for the review and for pointing out the receive path. The backoff tracker now releases its write lock before both consumer callbacks, applying #10768’s non-backoff fix to this path. Due-message updates and timer registration remain under the lock, preserving shutdown coordination. I also added Exclusive/Failover receive-processing coverage, clarified the deadlock cycle in the title/description, and replaced both Merged
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM on 5a820a3. Both previous comments are addressed, and the added receive-processing coverage exercises the real synchronized messageProcessed() path for Exclusive and Failover consumers.
Verified locally with retries disabled: all 22 focused cases passed (11 tracker, 7 deduplication/reconnect, and 4 broker ACK-timeout backoff cases). The unfixed tracker failed the new Exclusive/RECEIVE case at the expected lock-availability assertion; after restoring the fix, all four concurrency combinations passed again. This checks the unsafe locking condition without deliberately leaving threads deadlocked.
No further findings from the follow-up review. Please wait for the required CI checks before merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…delivery (apache#27065) (cherry picked from commit a72adf7)
…delivery (apache#27065) (cherry picked from commit a72adf7)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.