Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
We've been experiencing RpcThrottlingException with 0ms waitInterval. This seems odd and wasteful, since the client side will immediately retry without backoff. I think the problem is related to the synchronization of RateLimiter.
The TimeBasedLimiter checkQuota method does the following:
if (!reqSizeLimiter.canExecute(estimateWriteSize + estimateReadSize)) {
RpcThrottlingException.throwRequestSizeExceeded(
reqSizeLimiter.waitInterval(estimateWriteSize + estimateReadSize));
}
Both canExecute and waitInterval are synchronized, but we're calling them independently. So it's possible under high concurrency for canExecute to return false, but then waitInterval returns 0 (would have been true)
I think we should simplify the API to have a single synchronized call:
long waitInterval = reqSizeLimiter.tryAcquire(estimateWriteSize + estimateReadSize); if (waitInterval > 0) { RpcThrottlingException.throwRequestSizeExceeded(waitInterval); }
Attachments
Issue Links
- links to