Skip to content

Commit 524f1d7

Browse files
authored
Fix client connection rejected due to throttler token overflow
Reviewers: kezhuw, tisonkun, li4wang Author: damumu0625 Closes #2264 from damumu0625/ZOOKEEPER-4933
1 parent aeadf57 commit 524f1d7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,13 @@ public synchronized boolean checkLimit(int need) {
325325
long diff = now - lastTime;
326326

327327
if (diff > fillTime) {
328-
int refill = (int) (diff * fillCount / fillTime);
329-
tokens = Math.min(tokens + refill, maxTokens);
328+
long refill = diff * fillCount / fillTime;
329+
tokens = (int) Math.min(tokens + refill, maxTokens);
330+
if (tokens < 0) {
331+
tokens = maxTokens;
332+
LOG.error("Throttle config values {}({}) and {}({}) are insane and cause long integer overflow after {}ms",
333+
CONNECTION_THROTTLE_FILL_TIME, fillTime, CONNECTION_THROTTLE_FILL_COUNT, fillCount, diff);
334+
}
330335
lastTime = now;
331336
}
332337

0 commit comments

Comments
 (0)