Repository: hbase Updated Branches: refs/heads/branch-1.0 d8a5820be -> d5eb75604
HBASE-15478 add comments to syncRunnerIndex handling explaining constraints on possible values. Signed-off-by: zhangduo <[email protected]> Conflicts: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d5eb7560 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d5eb7560 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d5eb7560 Branch: refs/heads/branch-1.0 Commit: d5eb756044cb8819e2881b7dc6fd0f7c772b6561 Parents: d8a5820 Author: Sean Busbey <[email protected]> Authored: Thu Mar 17 15:22:07 2016 -0500 Committer: Sean Busbey <[email protected]> Committed: Mon Mar 21 00:36:53 2016 -0500 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/wal/FSHLog.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/d5eb7560/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 9e886a7..85de419 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 @@ -1871,12 +1871,21 @@ public class FSHLog implements WAL { LOG.trace("Sequence=" + sequence + ", syncCount=" + this.syncFuturesCount); } - // Below expects that the offer 'transfers' responsibility for the outstanding syncs to the - // syncRunner. We should never get an exception in here. HBASE-11145 was because queue - // was sized exactly to the count of user handlers but we could have more if we factor in - // meta handlers doing opens and closes. + // 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. HBASE-11145 was because queue + // was sized exactly to the count of user handlers but we could have more if we factor in + // meta handlers doing opens and closes. this.syncRunners[this.syncRunnerIndex].offer(sequence, this.syncFutures, this.syncFuturesCount); } catch (Exception e) { cleanupOutstandingSyncsOnException(sequence, e);
