Skip to content

Commit 4cb1291

Browse files
committed
metrics: fix DiskSpaceUsage after reopen with value sep
We weren't initializing `BlobFiles.Local.LiveSize` on open, which should be the dominating term in disk space when values are separated. Informs #5493
1 parent 7d01920 commit 4cb1291

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

recovery.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,10 @@ func recoverVersion(
320320
vs.metrics.Table.Live.Local.Inc(localSize)
321321
}
322322
}
323+
for blobFile := range newVersion.BlobFiles.All() {
324+
if objstorage.IsLocalBlobFile(provider, blobFile.Physical.FileNum) {
325+
vs.metrics.BlobFiles.Live.Local.Inc(blobFile.Physical.Size)
326+
}
327+
}
323328
return vs, nil
324329
}

testdata/metrics

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,3 +2190,38 @@ Iter category stats:
21902190
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
21912191
----
21922192
----
2193+
2194+
init
2195+
----
2196+
2197+
batch
2198+
set a 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
2199+
set b 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
2200+
set c 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
2201+
set d 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
2202+
----
2203+
2204+
flush
2205+
----
2206+
L0.0:
2207+
000005:[a#10,SET-a#10,SET]
2208+
000007:[b#11,SET-b#11,SET]
2209+
000009:[c#12,SET-c#12,SET]
2210+
000011:[d#13,SET-d#13,SET]
2211+
Blob files:
2212+
B000006 physical:{000006 size:[208 (208B)] vals:[120 (120B)]}
2213+
B000008 physical:{000008 size:[208 (208B)] vals:[120 (120B)]}
2214+
B000010 physical:{000010 size:[208 (208B)] vals:[120 (120B)]}
2215+
B000012 physical:{000012 size:[208 (208B)] vals:[120 (120B)]}
2216+
2217+
disk-usage
2218+
----
2219+
7,614B
2220+
2221+
init reopen
2222+
----
2223+
2224+
# The disk usage is expected to go down a bit because we remove the WALs.
2225+
disk-usage
2226+
----
2227+
7,097B

0 commit comments

Comments
 (0)