-
Notifications
You must be signed in to change notification settings - Fork 888
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
Concurrent ReplayMerges fail #1340
Comments
…at it should have its own Archive client. Issue #1340.
|
You added a comment to the javadoc saying "ReplayMerge is not threadsafe and should not be used with a shared AeronArchive client" but I did not intend to refer to thread safety or multi-threaded use. As written in the issue, this is about
My mention of the locking in Having to use several The |
If you think you can achieve this in a consistent way with the API preserved then feel free to submit a PR. However be aware that few would think they are on the hot path when catching up with a replay. |
Function
ReplayMerge#pollForResponse
is called whenever theReplayMerge
awaits a control response from the archive, namely when it tries to start the replay or when it requests the current recording position. It returnstrue
if a response to the currently active request has been received,false
otherwise.To do so, it polls the
archive.controlResponsePoller()
and, once that has received a full control response, checks thecorrelationId
of that response. If thecorrelationId
is not the expectedactiveCorrelationId
, it simply moves on and returnsfalse
.This prevents using several
ReplayMerge
s in an interleaved fashion in a single duty cycle, because control responses intended for oneReplayMerge
might be discarded by another when it callspollForResponse
. As a consequence,only one of thetheReplayMerge
s will ever finishReplayMerge
s often will never finish. Please do tell me if I've misunderstood anything so far.It seems to me that this very issue is why the more "naïve" parts of the
AeronArchive
's interface use a global lock, making the operations slower because synchronous but correct. For aReplayMerge
which could be a long operation however that is not possible.I have circumvented this issue of stolen control responses by modifying
ReplayMerge
to instead use aControlResponseDispatcher
that I wrote that storesRunnable
callbacks associated to correlation IDs, wraps the originalControlResponsePoller
and calls the appropriate callback (if any) when a control response is received. However I think this mechanism should be natively integrated to theControlResponsePoller
. Eager to read your thoughts on this.The text was updated successfully, but these errors were encountered: