Skip to content

Commit

Permalink
Fix assert in background compression and encryption. (#1366)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
poonai authored Jun 15, 2020
1 parent 14386ac commit c45d966
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions table/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c45d966

Please sign in to comment.