Revert "Remove replication event from pending when runway is allowed" This reverts commit e780ae61cbbba3f88558a3620065d1fcdc0768c8. Reason for revert: Creates potentially infinite Heap consumption and JVM crash when a PushOp is denied to use the runway. The problem is caused by the late removal of the PushOp from the list of pending operations, which causes the subsequent reschedule to find the same operation and double the number of replication states associated with it. If the loop happens multiple times, the generated consumption grows exponentially causing the JVM to enter a series of continuous stop-the-world GC that eventually lead to complete block of the JVM activity. The method `requestRunway` is thus not telling the truth because it is actually relying on the fact that the PushOne operation is removed also from the pending list, independently from its runway concession status. Change-Id: I6097bc7ad16c8bcc86a7d30af7d2ad331728712d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java index 895e1ac..0a06093 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -501,11 +501,11 @@ if (op.wasCanceled()) { return RunwayStatus.canceled(); } + pending.remove(op.getURI()); PushOne inFlightOp = inFlight.get(op.getURI()); if (inFlightOp != null) { return RunwayStatus.denied(inFlightOp.getId()); } - pending.remove(op.getURI()); inFlight.put(op.getURI(), op); } return RunwayStatus.allowed();