Skip to content
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

[pulsar-broker] check replicator periodically to avoid issue due to zk missing watch #6674

Merged
merged 2 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ replicationProducerQueueSize=1000
# Replicator prefix used for replicator producer name and cursor name
replicatorPrefix=pulsar.repl

# Duration to check replication policy to avoid replicator inconsistency
# due to missing ZooKeeper watch (disable with value 0)
replicatioPolicyCheckDurationSeconds=600

# Default message retention time
defaultRetentionTimeInMinutes=0

Expand Down
4 changes: 4 additions & 0 deletions conf/standalone.conf
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ replicationConnectionsPerBroker=16
# Replicator producer queue size
replicationProducerQueueSize=1000

# Duration to check replication policy to avoid replicator inconsistency
# due to missing ZooKeeper watch (disable with value 0)
replicatioPolicyCheckDurationSeconds=600

# Default message retention time
defaultRetentionTimeInMinutes=0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,12 @@ public class ServiceConfiguration implements PulsarConfiguration {
doc = "Replicator producer queue size"
)
private int replicationProducerQueueSize = 1000;
@FieldContext(
category = CATEGORY_REPLICATION,
doc = "Duration to check replication policy to avoid replicator "
+ "inconsistency due to missing ZooKeeper watch (disable with value 0)"
)
private int replicatioPolicyCheckDurationSeconds = 600;
@Deprecated
@FieldContext(
category = CATEGORY_REPLICATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ public void start() throws Exception {
this.startMessagePublishBufferMonitor();
this.startBacklogQuotaChecker();
this.updateBrokerPublisherThrottlingMaxRate();
this.startCheckReplicationPolicies();
// register listener to capture zk-latency
ClientCnxnAspect.addListener(zkStatsListener);
ClientCnxnAspect.registerExecutor(pulsar.getExecutor());
Expand Down Expand Up @@ -446,6 +447,14 @@ protected void startMessageExpiryMonitor() {
TimeUnit.MINUTES);
}

protected void startCheckReplicationPolicies() {
int interval = pulsar.getConfig().getReplicatioPolicyCheckDurationSeconds();
if (interval > 0) {
messageExpiryMonitor.scheduleAtFixedRate(safeRun(this::checkReplicationPolicies), interval, interval,
TimeUnit.SECONDS);
}
}

protected void startCompactionMonitor() {
int interval = pulsar().getConfiguration().getBrokerServiceCompactionMonitorIntervalInSeconds();
if (interval > 0) {
Expand Down Expand Up @@ -1143,6 +1152,10 @@ public void checkMessageExpiry() {
forEachTopic(Topic::checkMessageExpiry);
}

public void checkReplicationPolicies() {
forEachTopic(Topic::checkReplication);
}

public void checkCompaction() {
forEachTopic((t) -> {
if (t instanceof PersistentTopic) {
Expand Down