Kaynağa Gözat

Fix client connection rejected due to throttler token overflow

Reviewers: kezhuw, tisonkun, li4wang
Author: damumu0625
Closes #2264 from damumu0625/ZOOKEEPER-4933
Yongming Zhang 1 ay önce
ebeveyn
işleme
524f1d750c

+ 7 - 2
zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java

@@ -325,8 +325,13 @@ public class BlueThrottle {
         long diff = now - lastTime;
         long diff = now - lastTime;
 
 
         if (diff > fillTime) {
         if (diff > fillTime) {
-            int refill = (int) (diff * fillCount / fillTime);
-            tokens = Math.min(tokens + refill, maxTokens);
+            long refill = diff * fillCount / fillTime;
+            tokens = (int) Math.min(tokens + refill, maxTokens);
+            if (tokens < 0) {
+                tokens = maxTokens;
+                LOG.error("Throttle config values {}({}) and {}({}) are insane and cause long integer overflow after {}ms",
+                        CONNECTION_THROTTLE_FILL_TIME, fillTime, CONNECTION_THROTTLE_FILL_COUNT, fillCount, diff);
+            }
             lastTime = now;
             lastTime = now;
         }
         }