Ensure failures are only incremented in RunnableWithMetrics To maintain consistency, task and fetch ref failure counters should only be incremented within RunnableWithMetrics. The Runnable::run() method is the only place with visibility into the final outcome of a task, which can either complete successfully or fail. The following metric should always converge to zero: plugins_pull_replication_tasks_started_total - plugins_pull_replication_tasks_completed_total - plugins_pull_replication_tasks_failed_total Intermediate statuses should continue to be handled outside the Runnable implementation, but final state metrics must be updated only from within it. Change-Id: I2f07a12b7afca32d3d222d1c06262e4d34ae003f
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index b1d553d..a5d1e9e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -705,8 +705,6 @@ ? RefUpdate.Result.NOT_ATTEMPTED : RefUpdate.Result.REJECTED_OTHER_REASON; postReplicationFailedEvent(fetchOp, trackingRefUpdate); - queueMetrics.incrementTaskFailed(this); - queueMetrics.incrementFetchRefsFailed(this, fetchOp); if (fetchOp.setToRetry()) { postReplicationScheduledEvent(fetchOp);