Skip to content

Commit 6f876f3

Browse files
committed
db: add support for blob files to versionSet
Adapt the versionSet to write extant blob files to new manifests during a manifest rollover and support tracking zombie and obsolete blob files. Informs #112.
1 parent 7149af5 commit 6f876f3

File tree

6 files changed

+409
-63
lines changed

6 files changed

+409
-63
lines changed

metrics.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,36 @@ type Metrics struct {
312312
}
313313
}
314314

315+
BlobFiles struct {
316+
// The count of all live blob files.
317+
LiveCount uint64
318+
// The size of all live blob files.
319+
LiveSize uint64
320+
// The count of all obsolete blob files.
321+
ObsoleteCount uint64
322+
// The size of all obsolete blob files.
323+
ObsoleteSize uint64
324+
// The count of all zombie blob files.
325+
ZombieCount uint64
326+
// The size of all zombie blob files.
327+
ZombieSize uint64
328+
// Local file sizes.
329+
Local struct {
330+
// LiveSize is the number of bytes in live blob files.
331+
LiveSize uint64
332+
// LiveCount is the number of live blob files.
333+
LiveCount uint64
334+
// ObsoleteSize is the number of bytes in obsolete blob files.
335+
ObsoleteSize uint64
336+
// ObsoleteCount is the number of obsolete blob files.
337+
ObsoleteCount uint64
338+
// ZombieSize is the number of bytes in zombie blob files.
339+
ZombieSize uint64
340+
// ZombieCount is the number of zombie blob files.
341+
ZombieCount uint64
342+
}
343+
}
344+
315345
FileCache CacheMetrics
316346

317347
// Count of the number of open sstable iterators.

objstorage/objstorage.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ func Copy(ctx context.Context, r ReadHandle, out Writable, offset, length uint64
395395
return nil
396396
}
397397

398+
// IsLocalBlobFile returns true if a blob file with the given fileNum exists and is
399+
// local.
400+
func IsLocalBlobFile(provider Provider, fileNum base.DiskFileNum) bool {
401+
meta, err := provider.Lookup(base.FileTypeBlob, fileNum)
402+
return err == nil && !meta.IsRemote()
403+
}
404+
398405
// IsLocalTable returns true if a table with the given fileNum exists and is
399406
// local.
400407
func IsLocalTable(provider Provider, fileNum base.DiskFileNum) bool {

obsolete_files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func (d *DB) scanObsoleteFiles(list []string, flushableIngests []*ingestedFlusha
439439

440440
d.mu.versions.obsoleteTables = mergeObjectInfos(d.mu.versions.obsoleteTables, obsoleteTables)
441441
d.mu.versions.obsoleteBlobs = mergeObjectInfos(d.mu.versions.obsoleteBlobs, obsoleteBlobs)
442-
d.mu.versions.updateObsoleteTableMetricsLocked()
442+
d.mu.versions.updateObsoleteObjectMetricsLocked()
443443
d.mu.versions.obsoleteManifests = mergeObsoleteFiles(d.mu.versions.obsoleteManifests, obsoleteManifests)
444444
d.mu.versions.obsoleteOptions = mergeObsoleteFiles(d.mu.versions.obsoleteOptions, obsoleteOptions)
445445
}

0 commit comments

Comments
 (0)