Repository: hbase Updated Branches: refs/heads/master 64204b96c -> f48c92d14
HBASE-15478 add comments to syncRunnerIndex handling explaining constraints on possible values. Signed-off-by: zhangduo <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f48c92d1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f48c92d1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f48c92d1 Branch: refs/heads/master Commit: f48c92d143429d389821be3347de42fe18f60276 Parents: 64204b9 Author: Sean Busbey <[email protected]> Authored: Thu Mar 17 15:22:07 2016 -0500 Committer: Sean Busbey <[email protected]> Committed: Mon Mar 21 00:28:15 2016 -0500 ---------------------------------------------------------------------- .../apache/hadoop/hbase/regionserver/wal/FSHLog.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/f48c92d1/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index f3f869c..dfbdae5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -1785,10 +1785,19 @@ public class FSHLog implements WAL { // If not a batch, return to consume more events from the ring buffer before proceeding; // we want to get up a batch of syncs and appends before we go do a filesystem sync. if (!endOfBatch || this.syncFuturesCount <= 0) return; - // Below expects that the offer 'transfers' responsibility for the outstanding syncs to - // the syncRunner. We should never get an exception in here. + // syncRunnerIndex is bound to the range [0, Integer.MAX_INT - 1] as follows: + // * The maximum value possible for syncRunners.length is Integer.MAX_INT + // * syncRunnerIndex starts at 0 and is incremented only here + // * after the increment, the value is bounded by the '%' operator to [0, syncRunners.length), + // presuming the value was positive prior to the '%' operator. + // * after being bound to [0, Integer.MAX_INT - 1], the new value is stored in syncRunnerIndex + // ensuring that it can't grow without bound and overflow. + // * note that the value after the increment must be positive, because the most it could have + // been prior was Integer.MAX_INT - 1 and we only increment by 1. this.syncRunnerIndex = (this.syncRunnerIndex + 1) % this.syncRunners.length; try { + // Below expects that the offer 'transfers' responsibility for the outstanding syncs to + // the syncRunner. We should never get an exception in here. this.syncRunners[this.syncRunnerIndex].offer(sequence, this.syncFutures, this.syncFuturesCount); } catch (Exception e) {
