You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Task] Fix thread safety of PendingAckHandleImpl #21304
PendingAckHandleImpl seems to contain some thread safety issues:
individualAckOfTransaction uses org.apache.commons.collections4.map.LinkedMap which is not thread safe.
Another thread safety issue is the mutation of MutablePair instance. MutablePair is not thread safe.
HashMaps are also used as mutable state.
This state is mutated without a guarantee that the same thread is reading and writing the state or there's some other way to ensure consistency according to the Java Memory Model.
It seems that the intention would be use a single thread execution model to address this. There's a internalPinnedExecutor in PendingAckHandleImpl which is used to run some operations on the single executor thread.
However, the thread could possibly get switched multiple times in the call chain because of asynchronous method calls.
There's also some code where synchronized blocks are used as a way to ensure consistency such as synchronized (org.apache.pulsar.broker.transaction.pendingack.impl.PendingAckHandleImpl.this) { and synchronized (PendingAckHandleImpl.this) {.
This is bad since the thread that gets synchronized is whatever thread is completing the asynchronous call. This might for example block threads from the bookkeeper client.
If the odds are not high that thread safety issue will happen, maybe no need to be proactive on this, but at least can set up mechanism to easily catch up on this.
If the odds are not high that thread safety issue will happen, maybe no need to be proactive on this, but at least can set up mechanism to easily catch up on this.
@JooHyukKim Perhaps in some software that's an acceptable way. Thread safety problems could be extremely rare. Let's say 1 out of 10 million operations fails. That is still a big problem for a messaging system.
Activity
codelipenghui commentedon Oct 7, 2023
@liangyepianzhou Could you please help take a look at this issue?
github-actions commentedon Nov 7, 2023
The issue had no activity for 30 days, mark with Stale label.
JooHyukKim commentedon Nov 8, 2023
If the odds are not high that thread safety issue will happen, maybe no need to be proactive on this, but at least can set up mechanism to easily catch up on this.
lhotari commentedon Feb 26, 2024
@JooHyukKim Perhaps in some software that's an acceptable way. Thread safety problems could be extremely rare. Let's say 1 out of 10 million operations fails. That is still a big problem for a messaging system.