This is an automated email from the ASF dual-hosted git repository. kezhuw pushed a commit to branch branch-3.9 in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/branch-3.9 by this push: new 392abdfa5 Fix client connection rejected due to throttler token overflow 392abdfa5 is described below commit 392abdfa57c53ff7fe9e10d65fd40bf36cb8443e Author: Yongming Zhang <99642933+damumu0...@users.noreply.github.com> AuthorDate: Thu Jun 5 09:03:13 2025 +0800 Fix client connection rejected due to throttler token overflow Reviewers: kezhuw, tisonkun, li4wang Author: damumu0625 Closes #2264 from damumu0625/ZOOKEEPER-4933 (cherry picked from commit 524f1d750c62920f5fafdb3ee5abf9f69ff54e41) Signed-off-by: Kezhu Wang <kez...@apache.org> --- .../src/main/java/org/apache/zookeeper/server/BlueThrottle.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java index 90be270e8..d040e7a71 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/BlueThrottle.java @@ -325,8 +325,13 @@ public synchronized boolean checkLimit(int need) { long diff = now - lastTime; 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; }