-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unlock the write lock of the UnAckedMessageTracker before call redeliverUnacknowledgedMessages #10768
Conversation
…verUnacknowledgedMessages The deadlock will happen in following steps: 1. The client internal thread got the consumer instance lock when call internalBatchReceiveAsync 2. The timer thread got the write lock of the UnAckedMessageTracker and then waiting on the consumer instance lock when call redeliverUnacknowledgedMessages 3. The client internal thread try to get the write lock of the UnAckedMessageTracker when adding unacked messages The deadlock happens. The fix is ensure the timer thread unlock the write lock before call redeliverUnacknowledgedMessages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Write lock is reentrant, why is it deadlock? Please correct me if I am wrong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@315157973 As described in the PR description, they are from different threads, one is the client internal thread, one is timer thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your explanation
…verUnacknowledgedMessages (apache#10768) The deadlock will happen in following steps: 1. The client internal thread got the consumer instance lock when call internalBatchReceiveAsync 2. The timer thread got the write lock of the UnAckedMessageTracker and then waiting on the consumer instance lock when call redeliverUnacknowledgedMessages 3. The client internal thread try to get the write lock of the UnAckedMessageTracker when adding unacked messages The deadlock happens. The fix is ensure the timer thread unlock the write lock before call redeliverUnacknowledgedMessages
…verUnacknowledgedMessages (apache#10768) The deadlock will happen in following steps: 1. The client internal thread got the consumer instance lock when call internalBatchReceiveAsync 2. The timer thread got the write lock of the UnAckedMessageTracker and then waiting on the consumer instance lock when call redeliverUnacknowledgedMessages 3. The client internal thread try to get the write lock of the UnAckedMessageTracker when adding unacked messages The deadlock happens. The fix is ensure the timer thread unlock the write lock before call redeliverUnacknowledgedMessages
Fixes #10767
Motivation
The deadlock will happen in following steps:
The deadlock happens since the timer thread hold the write lock of the UnAckedMessageTracker
The fix is to ensure the timer thread unlock the write lock before call redeliverUnacknowledgedMessages