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 b528871..21a5dae 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 @@ -1081,6 +1081,11 @@ class FSHLog implements HLog, Syncable { private long lastWrittenTxid = 0; private Object writeLock = new Object(); + /** + * Keep time of last time we logged incidence of a negative offset. + */ + private volatile long lastLogOfNegativeIndex = 0; + public AsyncWriter(String name) { super(name); } @@ -1146,6 +1151,15 @@ class FSHLog implements HLog, Syncable { } if (!hasIdleSyncer) { int idx = (int)(this.lastWrittenTxid % asyncSyncers.length); + if (idx < 0) { + long now = System.nanoTime(); + if ((this.lastLogOfNegativeIndex - now) > 60000000000L/*One minute*/) { + this.lastLogOfNegativeIndex = now; + LOG.warn("Negative index! " + idx + ", lastWrittenTxid=" + this.lastWrittenTxid + + ", asyncSyncers.length=" + asyncSyncers.length); + } + idx = Math.abs(idx); + } asyncSyncers[idx].setWrittenTxid(this.lastWrittenTxid); } }