[improve][broker] Prevent stale replicator pending reads after termination - #25767
Conversation
|
Replicator termination only occurs in the two events of "disabling replication" and closing the topic, and these two events will trigger the JVM GC for the replicator object. So this PR only fixes the state of "pending reads" at the moment when "the topic is turned off, and the replicator object has not been GC", and the state "pending reads" at this moment will not cause any problems. However, this modification is still useful, which makes our project more perfect. I suggest changing the label in the title to "improve". Then in the future, if users discover a replication problem, they won't spend too much time on considering such case |
@poorbarcode Okay. PTAL again. |
…ation (apache#25767) (cherry picked from commit 8f9f5b4) Signed-off-by: Zixuan Liu <nodeces@gmail.com>
…ation (apache#25767) (cherry picked from commit 8f9f5b4) (cherry picked from commit aeda5ca)
Fixes #xyz
Main Issue: #xyz
PIP: #xyz
Motivation
This is a follow-up to #25625 for the replication read-failure path related to #25097.
#25625 completes a replicator
InFlightTaskwhen a managed-ledger read fails, so retryable read failures do not leave stale pending-read state behind. This PR improves the state handling for the race where the read failure callback arrives after the replicator has already leftStarted, for example during termination or producer restart. In that case,readEntriesFailedshould still clear the failed read task so the replicator does not keep stale pending-read state while the object is still alive.Modifications
InFlightTaskcontexts before checking whether the replicator is still in theStartedstate.InFlightTaskinstances.InFlightTask;InFlightTaskalready has non-null entries when the failed callback is handled.readEntriesFailed.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes