Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7428717B53 for ; Fri, 15 May 2015 10:40:00 +0000 (UTC) Received: (qmail 1172 invoked by uid 500); 15 May 2015 10:40:00 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 1133 invoked by uid 500); 15 May 2015 10:40:00 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 1119 invoked by uid 99); 15 May 2015 10:40:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 May 2015 10:40:00 +0000 Date: Fri, 15 May 2015 10:40:00 +0000 (UTC) From: "Ashish Singhi (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-13686) Fail to limit rate in RateLimiter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-13686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14545289#comment-14545289 ] Ashish Singhi commented on HBASE-13686: --------------------------------------- bq. As long as user's request rate is samller than 60 in one minute, the RateLimiter should guarantee the request canExecute. Yes, I totally understand that and even we have internally thought about it. We are internally discussing on this to get to a conclusion. > Fail to limit rate in RateLimiter > --------------------------------- > > Key: HBASE-13686 > URL: https://issues.apache.org/jira/browse/HBASE-13686 > Project: HBase > Issue Type: Bug > Affects Versions: 2.0.0, 1.1.0 > Reporter: Guanghao Zhang > Priority: Minor > > While using the patch in HBASE-11598 , I found that RateLimiter can't to limit the rate right. > {code} > /** > * given the time interval, are there enough available resources to allow execution? > * @param now the current timestamp > * @param lastTs the timestamp of the last update > * @param amount the number of required resources > * @return true if there are enough available resources, otherwise false > */ > public synchronized boolean canExecute(final long now, final long lastTs, final long amount) { > return avail >= amount ? true : refill(now, lastTs) >= amount; > } > {code} > When avail >= amount, avail can't be refill. But in the next time to call canExecute, lastTs maybe update. So avail will waste some time to refill. Even we use smaller rate than the limit, the canExecute will return false. -- This message was sent by Atlassian JIRA (v6.3.4#6332)