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
I searched in the issues and found nothing similar.
Version
master
Minimal reproduce step
The ongoingTxns field is a LinkedMap which isn't thread safe.
What did you expect to see?
thread safe handling in TopicTransactionBuffer
What did you see instead?
ongoingTxns is handled in a problematic way. There are multiple threads that both mutate and read the collection.
It's possible that this isn't a problem, but it's very hard to reason about the thread safetyness of the code currently.
There definitely have been attempts to ensure thread safety. There seems to be an assumption that it's fine to either have synchronized (TopicTransactionBuffer.this) { or run on a single thread such as topic.getBrokerService().getPulsar().getTransactionExecutorProvider().getExecutor(this), to make it thread safe.
One note about topic.getBrokerService().getPulsar().getTransactionExecutorProvider().getExecutor(this) is that this is pointing to different object instances in the code base. It wouldn't be ensuring single threaded access to all accesses of the object instances that are handled.
It is possible that thread safety is achieved through ways that are hard to observe. As long as all accesses form a "happens-before" chain, even through "piggy backing", it's possible that the code is after all thread safe. The problem is that a small change might break that and the solution is very brittle. Thread safety issues are very hard to notice. The best way to prevent them is to write code that is thread safe.
Activity