Skip to content

Commit 534dbfb

Browse files
committed
db: assert that blob file rewrites reduce value size
When performing a blob file rewrite compaction, assert that the rewritten blob file has a smaller value size. We should never choose to rewrite a blob file that is fully referenced. If we do, it reflects a bug in our statistics or compaction picking. Informs #5306.
1 parent 9eec172 commit 534dbfb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

blob_rewrite.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ func (c *blobFileRewriteCompaction) Execute(jobID JobID, d *DB) error {
197197

198198
// Update the version with the remapped blob file.
199199
if err == nil {
200+
// Ensure the rewrite did reduce the aggregate value size. If it didn't,
201+
// we should have never selected this blob file for rewrite and there
202+
// must be a bug in the statistics we maintain.
203+
if ve.NewBlobFiles[0].Physical.ValueSize >= c.input.Physical.ValueSize {
204+
return errors.AssertionFailedf("pebble: blob file %s rewrite did not reduce value size", c.input.FileID)
205+
}
206+
200207
info.Output.BlobFileID = ve.NewBlobFiles[0].FileID
201208
info.Output.DiskFileNum = ve.NewBlobFiles[0].Physical.FileNum
202209
info.Output.Size = ve.NewBlobFiles[0].Physical.Size

0 commit comments

Comments
 (0)