diff --git a/table/builder.go b/table/builder.go index d32d9c6aa..adf064d9a 100644 --- a/table/builder.go +++ b/table/builder.go @@ -149,13 +149,13 @@ func (b *Builder) handleBlock() { blockBuf = eBlock } - // The newend should always be less than or equal to the original end - // plus the padding. If the new end is greater than item.end+padding - // that means the data from this block cannot be stored in its existing - // location and trying to copy it over would mean we would over-write - // some data of the next block. - y.AssertTruef(uint32(len(blockBuf)) <= item.end+padding, - "newend: %d item.end: %d padding: %d", len(blockBuf), item.end, padding) + // BlockBuf should always less than or equal to allocated space. If the blockBuf is greater + // than allocated space that means the data from this block cannot be stored in its + // existing location and trying to copy it over would mean we would over-write some data + // of the next block. + allocatedSpace := (item.end - item.start) + padding + 1 + y.AssertTruef(uint32(len(blockBuf)) <= allocatedSpace, "newend: %d oldend: %d padding: %d", + item.start+uint32(len(blockBuf)), item.end, padding) // Acquire the buflock here. The builder.grow function might change // the b.buf while this goroutine was running.