Do not honor gerrit.replicateOnStartup on primary side Before this change the pull-replication plugin on the primary side would perform FetchAll on startup if gerrit.replicateOnStartup was true. Relying on gerrit.replicateOnStartup = false setting on the primary side was a weak protection against that. Change-Id: I2a674e6784cb255dba3178d3c94469f082564a65
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/OnStartStop.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/OnStartStop.java index 5cf8bb6..8dacc9a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/OnStartStop.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/OnStartStop.java
@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.extensions.registration.DynamicItem; import com.google.gerrit.extensions.systemstatus.ServerInformation; +import com.google.gerrit.server.config.GerritIsReplica; import com.google.gerrit.server.events.EventDispatcher; import com.google.gerrit.server.git.WorkQueue; import com.google.inject.Inject; @@ -38,6 +39,7 @@ private final ReplicationState.Factory replicationStateFactory; private final SourcesCollection sourcesCollection; private final WorkQueue workQueue; + private boolean isReplica; @Inject protected OnStartStop( @@ -47,7 +49,8 @@ DynamicItem<EventDispatcher> eventDispatcher, ReplicationState.Factory replicationStateFactory, SourcesCollection sourcesCollection, - WorkQueue workQueue) { + WorkQueue workQueue, + @GerritIsReplica Boolean isReplica) { this.srvInfo = srvInfo; this.fetchAll = fetchAll; this.config = config; @@ -56,11 +59,13 @@ this.fetchAllFuture = Atomics.newReference(); this.sourcesCollection = sourcesCollection; this.workQueue = workQueue; + this.isReplica = isReplica; } @Override public void start() { - if (srvInfo.getState() == ServerInformation.State.STARTUP + if (isReplica + && srvInfo.getState() == ServerInformation.State.STARTUP && config.isReplicateAllOnPluginStart()) { ReplicationState state = replicationStateFactory.create(