Skip to content

Commit 819cf24

Browse files
committed
manifest: fix bug in accumulating blob file deletions
Previously when accumulating multiple version edits in a BulkVersionEdit, later calls to Accumulate would wipe blob file deletions that had already been accumulated.
1 parent ea3743e commit 819cf24

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

internal/manifest/testdata/version_edit_apply

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,37 @@ new version edit
306306
----
307307
L2:
308308
000002:[c#1,SET-f#1,SET] seqnums:[0-0] points:[c#1,SET-f#1,SET]
309+
310+
# Create a state with two blob files.
311+
312+
apply v10 name=v11
313+
add-blob-file: B000003 physical:{000003 size:[20535 (20KB)] vals:[25935 (25KB)]}
314+
add-blob-file: B000004 physical:{000004 size:[20535 (20KB)] vals:[25935 (25KB)]}
315+
add-table: L0 000005:[a#9,SET-z#9,DEL] seqnums:[9-9] points:[a#9,SET-z#9,DEL] blobrefs:[(B000003: 25935); depth:1]
316+
add-table: L0 000006:[a#9,SET-z#9,DEL] seqnums:[9-9] points:[a#9,SET-z#9,DEL] blobrefs:[(B000004: 25935); depth:1]
317+
----
318+
L0.1:
319+
000006:[a#9,SET-z#9,DEL] seqnums:[9-9] points:[a#9,SET-z#9,DEL] blobrefs:[(B000004: 25935); depth:1]
320+
L0.0:
321+
000005:[a#9,SET-z#9,DEL] seqnums:[9-9] points:[a#9,SET-z#9,DEL] blobrefs:[(B000003: 25935); depth:1]
322+
L1:
323+
000001:[a#2,SET-e#2,SET] seqnums:[0-0] points:[a#2,SET-e#2,SET]
324+
L2:
325+
000002:[c#1,SET-f#1,SET] seqnums:[0-0] points:[c#1,SET-f#1,SET]
326+
Blob files:
327+
B000003 physical:{000003 size:[20535 (20KB)] vals:[25935 (25KB)]}
328+
B000004 physical:{000004 size:[20535 (20KB)] vals:[25935 (25KB)]}
329+
330+
# Remove both table+blob file pairs but in separate version edits.
331+
332+
apply v11
333+
del-table: L0 000005
334+
del-blob-file: B000003
335+
new version edit
336+
del-table: L0 000006
337+
del-blob-file: B000004
338+
----
339+
L1:
340+
000001:[a#2,SET-e#2,SET] seqnums:[0-0] points:[a#2,SET-e#2,SET]
341+
L2:
342+
000002:[c#1,SET-f#1,SET] seqnums:[0-0] points:[c#1,SET-f#1,SET]

internal/manifest/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ func NewVersionForTesting(
101101
comparer *base.Comparer, l0Organizer *L0Organizer, files [7][]*TableMetadata,
102102
) *Version {
103103
v := &Version{
104-
cmp: comparer,
104+
cmp: comparer,
105+
BlobFiles: MakeBlobFileSet(nil),
105106
}
106107
for l := range files {
107108
// NB: We specifically insert `files` into the B-Tree in the order

internal/manifest/version_edit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,10 @@ func (b *BulkVersionEdit) Accumulate(ve *VersionEdit) error {
10301030
b.BlobFiles.Added[nbf.FileID] = nbf.Physical
10311031
}
10321032

1033-
b.BlobFiles.Deleted = make(map[base.BlobFileID]*PhysicalBlobFile, len(ve.DeletedBlobFiles))
10341033
for blobFileID, physicalBlobFile := range ve.DeletedBlobFiles {
1034+
if b.BlobFiles.Deleted == nil {
1035+
b.BlobFiles.Deleted = make(map[base.BlobFileID]*PhysicalBlobFile)
1036+
}
10351037
// If the blob file was added in a prior, accumulated version edit we
10361038
// can resolve the deletion by removing it from the added files map.
10371039
// Otherwise the blob file deleted was added prior to this bulk edit,

0 commit comments

Comments
 (0)