Skip to content

Commit 6f57a21

Browse files
committed
db: merge in obsolete blob file during failed blob rewrite compaction
If a blob rewrite compaction fails for any reason (eg, the blob becomes unreferenced while the compaction is in-progress), we enqueue the blob file we created as an 'obsolete' blob file. This enqueue did not insert the blob file in sorted order. Fix #5022.
1 parent 20e2cbc commit 6f57a21

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

blob_rewrite.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,18 @@ func (c *blobFileRewriteCompaction) Execute(jobID JobID, d *DB) error {
215215
// Ensure we clean up the blob file we created on failure.
216216
if err != nil {
217217
if objMeta.DiskFileNum != 0 {
218-
d.mu.versions.obsoleteBlobs = append(d.mu.versions.obsoleteBlobs, obsoleteFile{
219-
fileType: base.FileTypeBlob,
220-
fs: d.opts.FS,
221-
path: d.objProvider.Path(objMeta),
222-
fileNum: objMeta.DiskFileNum,
223-
// We don't know the size of the output blob file--it may have
224-
// been half-written. We use the input blob file size as an
225-
// approximation for deletion pacing.
226-
fileSize: c.input.Physical.Size,
227-
isLocal: true,
218+
d.mu.versions.obsoleteBlobs = mergeObsoleteFiles(d.mu.versions.obsoleteBlobs, []obsoleteFile{
219+
{
220+
fileType: base.FileTypeBlob,
221+
fs: d.opts.FS,
222+
path: d.objProvider.Path(objMeta),
223+
fileNum: objMeta.DiskFileNum,
224+
// We don't know the size of the output blob file--it may have
225+
// been half-written. We use the input blob file size as an
226+
// approximation for deletion pacing.
227+
fileSize: c.input.Physical.Size,
228+
isLocal: true,
229+
},
228230
})
229231
}
230232
}

0 commit comments

Comments
 (0)