Don't wait for pending events to process on startup Previously, on large Gerrit installations with many projects and/or many replication destinations, the replication plugin could take very long periods of time to startup. This was particularly a problem if the pending(persisted) event count was large as they all were rescheduled before the plugin finished initializing. Change this behavior so that startup merely begins the process of scheduling the pending events, but does not wait for them to complete. Bug: Issue 12769 Change-Id: I224c2ce2a35f987af2343089b9bb00a7fcb7e3be
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java index e704978..f2d8ec5 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -99,7 +99,9 @@ if (!running) { config.startup(workQueue); running = true; - firePendingEvents(); + Thread t = new Thread(this::firePendingEvents, "firePendingEvents"); + t.setDaemon(true); + t.start(); fireBeforeStartupEvents(); } } @@ -216,6 +218,8 @@ repLog.error("Encountered malformed URI for persisted event %s", t); } } + } catch (Throwable e) { + repLog.error("Unexpected error while firing pending events", e); } finally { replaying = false; }