merlimat opened a new pull request #9787:
URL: https://github.com/apache/pulsar/pull/9787
### Motivation
As discussed in #9764 the fact that we're potentially holding a read-lock
while scanning through a section of the map has several implications:
1. If the process functions is taking a long time (eg: making a blocking
request to ZK that might even timeout), the writes operations on that section
of the map are stalled during that time.
2. It's deadlock prone:
1. If a thread tries to use the map while scanning through it can
deadlock itself
2. If the processing operation waits for the completion of some
operation from a different thread and that thread tries to use the same map, it
can create a deadlock.
Instead of holding the lock throughout the scan of the section, we should
instead release the read lock before calling the processing function, going
back into the optimistic read mode.
This will not add any overhead (in terms of volatile reads) compared to the
current implementation, but will avoid all the possible deadlock traps, since
we're never going to be holding the lock while calling the user code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]