fix: fix round handling at worker removal in IWRR
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 7 May 2023 20:49:55 +0000 (22:49 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 7 May 2023 20:49:55 +0000 (22:49 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts

index 89576e33873f2bfeed8cbb0308b2abd28e0ab13c..24f7ac9a4cec4c151774c74b8ecaa6f50f23f02a 100644 (file)
@@ -114,11 +114,12 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
     if (this.currentWorkerNodeId === workerNodeKey) {
       if (this.pool.workerNodes.length === 0) {
         this.currentWorkerNodeId = 0
-      } else {
-        this.currentWorkerNodeId =
-          this.currentWorkerNodeId > this.pool.workerNodes.length - 1
-            ? this.pool.workerNodes.length - 1
-            : this.currentWorkerNodeId
+      } else if (this.currentWorkerNodeId > this.pool.workerNodes.length - 1) {
+        this.currentWorkerNodeId = this.pool.workerNodes.length - 1
+        this.currentRoundId =
+          this.currentRoundId === this.roundWeights.length - 1
+            ? 0
+            : this.currentRoundId + 1
       }
     }
     return true