forked from OpenTSDB/asynchbase
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and enhance increment coalescing.
This closes OpenTSDB#41, whereby a too large number of increments that pile up for a given counter could cause a Deferred chain to blow up. We now guarantee that this will not happen by keeping track of how many times each counter gets incremented, and pro-actively flushing those that reach the limit on the length of the Deferred chain. This has a nice side effect that the *really* busy counters will get flushed more often. This tracking is done without any extra locking or synchronization and only costs an extra 32 bits of memory per coalesced counter. This enhances increment coalescing to support negative increment values as well as values greater than Short.MAX_VALUE (65535). There is still a limit on how big the values can be, but the limit is much higher now (2^48 - 1) and values greater than that are still gracefully handled. The code is also more robust now in face of overflows / underflows, as the previous implementation had one potential race condition, which although it would have been incredibly rare, was still possible anyway. We now explicitly check for overflows / underflows before we CAS the value, so that when an overflow / underflow condition is detected we abort the update gracefully and let the caller know so they can flush the counter and create a new one to start coalescing again. This change also adds extra integration tests for various corner cases.
- Loading branch information
Showing
3 changed files
with
259 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.