Skip to content

Commit c45d966

Browse files
authored
Fix assert in background compression and encryption. (#1366)
* use assert to find whether, the async compression/encryption able to fit the destination block in the allocated space. Allocated space is calculated using (item.end-item.start) + padding +1
1 parent 14386ac commit c45d966

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

table/builder.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ func (b *Builder) handleBlock() {
149149
blockBuf = eBlock
150150
}
151151

152-
// The newend should always be less than or equal to the original end
153-
// plus the padding. If the new end is greater than item.end+padding
154-
// that means the data from this block cannot be stored in its existing
155-
// location and trying to copy it over would mean we would over-write
156-
// some data of the next block.
157-
y.AssertTruef(uint32(len(blockBuf)) <= item.end+padding,
158-
"newend: %d item.end: %d padding: %d", len(blockBuf), item.end, padding)
152+
// BlockBuf should always less than or equal to allocated space. If the blockBuf is greater
153+
// than allocated space that means the data from this block cannot be stored in its
154+
// existing location and trying to copy it over would mean we would over-write some data
155+
// of the next block.
156+
allocatedSpace := (item.end - item.start) + padding + 1
157+
y.AssertTruef(uint32(len(blockBuf)) <= allocatedSpace, "newend: %d oldend: %d padding: %d",
158+
item.start+uint32(len(blockBuf)), item.end, padding)
159159

160160
// Acquire the buflock here. The builder.grow function might change
161161
// the b.buf while this goroutine was running.

0 commit comments

Comments
 (0)