diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java index e5744bdc1cc..ea2d7fe675c 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java @@ -274,7 +274,7 @@ public Result preIncrement( limitReached = SequenceUtil.checkIfLimitReached(currentValue, minValue, maxValue, incrementBy, cacheSize, numSlotsToAllocate); // update currentValue - currentValue += incrementBy * (SequenceUtil.isBulkAllocation(numSlotsToAllocate) ? numSlotsToAllocate : cacheSize); + currentValue += incrementBy * (SequenceUtil.isBulkAllocation(numSlotsToAllocate) ? Math.max(numSlotsToAllocate, cacheSize) : cacheSize); // update the currentValue of the Result row Cell newCurrentValueKV = createKeyValue(row, PhoenixDatabaseMetaData.CURRENT_VALUE_BYTES, currentValue, timestamp); Sequence.replaceCurrentValueKV(cells, newCurrentValueKV);