Description
For the following function, if the following situation happens then the blockedoffset is used with the wrong term id.
IF
blockedPosition is within TermId = 0 (the second half because otherwise the pub=lmt doesn't cross two terms)
activeTermCount is now at 1
Then
index = 1
termId = 1
However given that blockedOffset refers to term 0, working with termBuffers[index] doesn't make sense.
It seems like we should use the expectedTermCount to compute the index instead.
LogBufferUnblocker::unblock()
{
final int termLength = termBuffers[0].capacity();
final int positionBitsToShift = Integer.numberOfTrailingZeros(termLength);
final int activeTermCount = activeTermCount(logMetaDataBuffer);
final int expectedTermCount = (int)(blockedPosition >> positionBitsToShift);
final int index = indexByTermCount(activeTermCount);
final long rawTail = rawTailVolatile(logMetaDataBuffer, index);
final int termId = termId(rawTail);
...
final int tailOffset = termOffset(rawTail, termLength);
final int blockedOffset = computeTermOffsetFromPosition(blockedPosition, positionBitsToShift);
}