[fix][meta] Fix deadlock causes session notification not to work - #19754
Conversation
|
@mattisonchao Please add the following content to your PR description and select a checkbox: |
| }).thenCompose(leaderElectionState -> { | ||
| // make sure that the cache contains the current leader | ||
| // so that getLeaderValueIfPresent works on all brokers | ||
| cache.refresh(path); |
There was a problem hiding this comment.
I checked the logic. This method looks changed and no blocking call anymore. /cc @lhotari
| cache.refresh(path); | ||
| return cache.get(path) | ||
| .thenApply(__ -> leaderElectionState); | ||
| }, executor); |
There was a problem hiding this comment.
We can't use this single thread executor here because session notification method ( handleSessionNotification )also uses this executor to do blocking get. It will cause a deadlock.
There was a problem hiding this comment.
Nice catch!
And I think it should be a critical bug introduced to 2.8.5, 2.9.4, 2.10.3, 2.11.1.
IMO, we should notice it in the mailing list to clarify it. It will help users decide
whether to upgrade to 2.8.5, 2.9.4, 2.10.3, or 2.11.0. Or whether to downgrade
to 2.8.4, 2.9.3, 2.10.2.
As I know, 2.9.5, 2.10.4, and 2.11.1 is in the release process. We should ship this
fix to the subsequent patch releases. For 2.8.5, maybe we also need to plan 2.8.6.
For the solution that the PR introduced. Yes, I think it can fix the issue.
IMO, instead of changing the thread, can we change the handleSessionNotification
method to an async method? I mean just to avoid any cases that block the executor
specified to the LeaderElectionImpl. I think it is not expected, right?
A possible solution is when the session event arrives. We can just put the event
in a queue and process it asynchronously. Like processing the next event if the
future of the current event is done. So that we don't need to block any thread.
Yes, that is what I thought, which may change much logic here. The async changes are just an improvement, not a bug fix. We can do it in the next PR. since the more complex changes will need more time to review. We can just revert the part of #17401 to cherry-pick it to previous branches. WDYT? @codelipenghui |
@mattisonchao Ok, sounds good to me. Let's revert the problem change to the old version, then find a better solution. |
|
nice catch! |
) ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock. (cherry picked from commit cbd799f)
) ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock. (cherry picked from commit cbd799f)
…ot to work (#19754) (#19768) Co-authored-by: Qiang Zhao <mattisonchao@apache.org> Master #19754 ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock. (cherry picked from commit cbd799f)
) ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock.
…ot to work (apache#19754) (apache#19768) Co-authored-by: Qiang Zhao <mattisonchao@apache.org> Master apache#19754 ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock. (cherry picked from commit cbd799f) (cherry picked from commit 36794d9)
…che#19754) ### Motivation This is a namespace bundle double-owners problem. We found it in the memory dumps. The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well. For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/74767115/223670419-c4319f44-f1e1-4361-8c79-04c7f0dabe3c.png"> ^^ blocked thread <img width="949" alt="image" src="https://user-images.githubusercontent.com/74767115/223672000-fb4ce22c-6a45-4cb6-9d23-c36e3afbc93a.png"> ^^ executor queue ### Modifications - Avoid putting the new task to single thread executor causes deadlock. (cherry picked from commit cbd799f)
Motivation
This is a namespace bundle double-owners problem. We found it in the memory dumps.
The memory dumps show that the notification thread has been blocked for a long time by the leader election deadlock, And many notifications are blocked in the executor queue. This causes we can't to revalidate the locks, and they are still thinking them working well.
For private reasons, I can't share the namespace bundle snapshot, but the blocked thread easily explains it.

^^ blocked thread^^ executor queue
Modifications
Verifying this change
Documentation
doc-not-needed