HBASE-27704 Quotas can drastically overflow configured limit#5099
HBASE-27704 Quotas can drastically overflow configured limit#5099bbeaudreault merged 1 commit intoapache:masterfrom
Conversation
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
|
@infraio any chance you might have time to take a look at this? |
|
The implementation of RateLimiter is a bit strange to me. The name of the 'canExecute' method indicates that it just tests whether a request can be executed, which should be read only, but in the method we will update avail? Then what is the purpose for consume method? And in consume method Why we do a 'Long.MAX_VALUE + amount'? It will always overflow? |
|
@Apache9 Thanks for taking a look. I agree the API is weird. I think the main reason is, unlike a normal RateLimiter, in HBase we can't simply do So at a higher level, we do
Once the request finishes, we know how much bytes it consumed. At that point we call I was not around for the initial implementation of this. I tried looking up reviews from back then, but we weren't on GitHub yet so it's only in reviewboard where the review was minimal. My guess on why they went with 2 loops is to minimize the chance that the 5th rate limiter (or whatever) fails to consume, and then you have to rollback all the ones that succeeded in consuming.
In that code snippet, |
|
Is there an off-the-shelf rate limiter that we can use instead of our own implementation? |
|
Thanks again nick! I agree it'd be nice if there were an OTS rate limiter we can use. That was my first thought here as well, since it took me a bit to really grok what was happening here. The most obvious candidate is guava, but unfortunately it doesn't really work with how we currently use rate limiters in quotas. As described above, we need sort of a multi-phase commit rate limiter where you can lease and return permits, check for permits without consuming, and consume non-blocking (after request is finished, when we finally know how much we needed). For this issue I'm partial to merging as is. I can give a quick search around for rate limiters like this and file a jira if any look promising. |
…5099) Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
…5099) Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
Removes limits in
refillwhich did not allow to go negative.FixedIntervalRateLimiter also needed some changes in getWaitInterval to properly match with how refilling really works.
Updated the tests to revive the original intended logic for quotas, where we really test for overconsumption.