Skip to content

[fix][broker] Handle missing replicator during snapshot request processing#22

Open
Denovo1998 wants to merge 1 commit intomasterfrom
snapshot_request_when_replicator_removed_concurrently
Open

[fix][broker] Handle missing replicator during snapshot request processing#22
Denovo1998 wants to merge 1 commit intomasterfrom
snapshot_request_when_replicator_removed_concurrently

Conversation

@Denovo1998
Copy link
Owner

Fixes #xyz

Main Issue: #xyz

PIP: #xyz

Motivation

A race condition can happen when a replicated subscription snapshot request is being processed while the corresponding replicator is removed concurrently. In this case, topic.getReplicators().get(...) may return null, which can lead to an exception path instead of graceful handling. This affects broker reliability under concurrent replication policy updates and marker handling.

Modifications

  • Added a null-check in ReplicatedSubscriptionsController#receivedSnapshotRequest for the source-cluster replicator.
  • When the replicator is missing, the broker now logs a warning with topic, snapshot id, and source cluster, then safely returns.
  • Kept the existing reconnect path (startReplProducers) for non-null but disconnected replicators.
  • Added ReplicatedSubscriptionsControllerTest#testSnapshotRequestWhenReplicatorRemovedConcurrentlyDoesNotThrow.
  • The test deterministically reproduces the race by blocking replicators.get(...), removing the replicator through PersistentTopic#removeReplicator, then resuming marker handling.
  • The test verifies replicator termination and cursor cleanup are invoked through the production removal path, and confirms marker handling completes without throwing.

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: apache#25266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant