@@ -1739,14 +1739,15 @@ func (d *DB) flush1() (bytesFlushed uint64, err error) {
1739
1739
1740
1740
var ve * manifest.VersionEdit
1741
1741
var stats compact.Stats
1742
+ var outputBlobs []compact.OutputBlob
1742
1743
// To determine the target level of the files in the ingestedFlushable, we
1743
1744
// need to acquire the logLock, and not release it for that duration. Since
1744
1745
// UpdateVersionLocked acquires it anyway, we create the VersionEdit for
1745
1746
// ingestedFlushable outside runCompaction. For all other flush cases, we
1746
1747
// construct the VersionEdit inside runCompaction.
1747
1748
var compactionErr error
1748
1749
if c .kind != compactionKindIngestedFlushable {
1749
- ve , stats , compactionErr = d .runCompaction (jobID , c )
1750
+ ve , stats , outputBlobs , compactionErr = d .runCompaction (jobID , c )
1750
1751
}
1751
1752
1752
1753
_ , err = d .mu .versions .UpdateVersionLocked (func () (versionUpdate , error ) {
@@ -1762,13 +1763,24 @@ func (d *DB) flush1() (bytesFlushed uint64, err error) {
1762
1763
validateVersionEdit (ve , d .opts .Comparer .ValidateKey , d .opts .Comparer .FormatKey , d .opts .Logger )
1763
1764
for i := range ve .NewTables {
1764
1765
e := & ve .NewTables [i ]
1765
- info .Output = append (info .Output , e .Meta .TableInfo ())
1766
+ info .OutputTables = append (info .OutputTables , e .Meta .TableInfo ())
1766
1767
// Ingested tables are not necessarily flushed to L0. Record the level of
1767
1768
// each ingested file explicitly.
1768
1769
if ingest {
1769
1770
info .IngestLevels = append (info .IngestLevels , e .Level )
1770
1771
}
1771
1772
}
1773
+ for i := range outputBlobs {
1774
+ b := & outputBlobs [i ]
1775
+ info .OutputBlobs = append (info .OutputBlobs , BlobFileInfo {
1776
+ BlobFileID : base .BlobFileID (b .Metadata .FileNum ),
1777
+ DiskFileNum : b .ObjMeta .DiskFileNum ,
1778
+ Size : b .Metadata .Size ,
1779
+ ValueSize : b .Stats .UncompressedValueBytes ,
1780
+ MVCCGarbageSize : b .Stats .MVCCGarbageBytes ,
1781
+ })
1782
+
1783
+ }
1772
1784
1773
1785
// The flush succeeded or it produced an empty sstable. In either case we
1774
1786
// want to bump the minimum unflushed log number to the log number of the
@@ -2721,7 +2733,7 @@ func (d *DB) compact1(jobID JobID, c *tableCompaction) (err error) {
2721
2733
d .opts .EventListener .CompactionBegin (info )
2722
2734
startTime := d .timeNow ()
2723
2735
2724
- ve , stats , err := d .runCompaction (jobID , c )
2736
+ ve , stats , outputBlobs , err := d .runCompaction (jobID , c )
2725
2737
2726
2738
info .Annotations = append (info .Annotations , c .annotations ... )
2727
2739
info .Duration = d .timeNow ().Sub (startTime )
@@ -2760,6 +2772,16 @@ func (d *DB) compact1(jobID JobID, c *tableCompaction) (err error) {
2760
2772
e := & ve .NewTables [i ]
2761
2773
info .Output .Tables = append (info .Output .Tables , e .Meta .TableInfo ())
2762
2774
}
2775
+ for i := range outputBlobs {
2776
+ b := & outputBlobs [i ]
2777
+ info .Output .Blobs = append (info .Output .Blobs , BlobFileInfo {
2778
+ BlobFileID : base .BlobFileID (b .Metadata .FileNum ),
2779
+ DiskFileNum : b .ObjMeta .DiskFileNum ,
2780
+ Size : b .Metadata .Size ,
2781
+ ValueSize : b .Stats .UncompressedValueBytes ,
2782
+ MVCCGarbageSize : b .Stats .MVCCGarbageBytes ,
2783
+ })
2784
+ }
2763
2785
d .mu .snapshots .cumulativePinnedCount += stats .CumulativePinnedKeys
2764
2786
d .mu .snapshots .cumulativePinnedSize += stats .CumulativePinnedSize
2765
2787
d .mu .versions .metrics .Keys .MissizedTombstonesCount += stats .CountMissizedDels
@@ -2798,17 +2820,17 @@ func (d *DB) compact1(jobID JobID, c *tableCompaction) (err error) {
2798
2820
// doing IO.
2799
2821
func (d * DB ) runCopyCompaction (
2800
2822
jobID JobID , c * tableCompaction ,
2801
- ) (ve * manifest.VersionEdit , stats compact.Stats , _ error ) {
2823
+ ) (ve * manifest.VersionEdit , stats compact.Stats , blobs []compact. OutputBlob , _ error ) {
2802
2824
if c .cancel .Load () {
2803
- return nil , compact.Stats {}, ErrCancelledCompaction
2825
+ return nil , compact.Stats {}, blobs , ErrCancelledCompaction
2804
2826
}
2805
2827
iter := c .startLevel .files .Iter ()
2806
2828
inputMeta := iter .First ()
2807
2829
if iter .Next () != nil {
2808
- return nil , compact.Stats {}, base .AssertionFailedf ("got more than one file for a move compaction" )
2830
+ return nil , compact.Stats {}, []compact. OutputBlob {}, base .AssertionFailedf ("got more than one file for a move compaction" )
2809
2831
}
2810
2832
if inputMeta .BlobReferenceDepth > 0 || len (inputMeta .BlobReferences ) > 0 {
2811
- return nil , compact.Stats {}, base .AssertionFailedf (
2833
+ return nil , compact.Stats {}, []compact. OutputBlob {}, base .AssertionFailedf (
2812
2834
"copy compaction for %s with blob references (depth=%d, refs=%d)" ,
2813
2835
inputMeta .TableNum , inputMeta .BlobReferenceDepth , len (inputMeta .BlobReferences ),
2814
2836
)
@@ -2821,11 +2843,11 @@ func (d *DB) runCopyCompaction(
2821
2843
2822
2844
objMeta , err := d .objProvider .Lookup (base .FileTypeTable , inputMeta .TableBacking .DiskFileNum )
2823
2845
if err != nil {
2824
- return nil , compact.Stats {}, err
2846
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2825
2847
}
2826
2848
// This code does not support copying a shared table (which should never be necessary).
2827
2849
if objMeta .IsShared () {
2828
- return nil , compact.Stats {}, base .AssertionFailedf ("copy compaction of shared table" )
2850
+ return nil , compact.Stats {}, []compact. OutputBlob {}, base .AssertionFailedf ("copy compaction of shared table" )
2829
2851
}
2830
2852
2831
2853
// We are in the relatively more complex case where we need to copy this
@@ -2885,7 +2907,7 @@ func (d *DB) runCopyCompaction(
2885
2907
ctx , base .FileTypeTable , inputMeta .TableBacking .DiskFileNum , objstorage.OpenOptions {},
2886
2908
)
2887
2909
if err != nil {
2888
- return nil , compact.Stats {}, err
2910
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2889
2911
}
2890
2912
defer func () {
2891
2913
if src != nil {
@@ -2900,7 +2922,7 @@ func (d *DB) runCopyCompaction(
2900
2922
},
2901
2923
)
2902
2924
if err != nil {
2903
- return nil , compact.Stats {}, err
2925
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2904
2926
}
2905
2927
deleteOnExit = true
2906
2928
@@ -2940,9 +2962,9 @@ func (d *DB) runCopyCompaction(
2940
2962
outputMetrics := c .metrics .perLevel .level (c .outputLevel .level )
2941
2963
outputMetrics .TableBytesIn = inputMeta .Size
2942
2964
2943
- return ve , compact.Stats {}, nil
2965
+ return ve , compact.Stats {}, []compact. OutputBlob {}, nil
2944
2966
}
2945
- return nil , compact.Stats {}, err
2967
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2946
2968
}
2947
2969
newMeta .TableBacking .Size = wrote
2948
2970
newMeta .Size = wrote
@@ -2951,7 +2973,7 @@ func (d *DB) runCopyCompaction(
2951
2973
d .objProvider .Path (objMeta ), base .FileTypeTable , newMeta .TableBacking .DiskFileNum ,
2952
2974
objstorage.CreateOptions {PreferSharedStorage : true })
2953
2975
if err != nil {
2954
- return nil , compact.Stats {}, err
2976
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2955
2977
}
2956
2978
deleteOnExit = true
2957
2979
}
@@ -2968,10 +2990,10 @@ func (d *DB) runCopyCompaction(
2968
2990
outputMetrics .TablesCompacted = 1
2969
2991
2970
2992
if err := d .objProvider .Sync (); err != nil {
2971
- return nil , compact.Stats {}, err
2993
+ return nil , compact.Stats {}, []compact. OutputBlob {}, err
2972
2994
}
2973
2995
deleteOnExit = false
2974
- return ve , compact.Stats {}, nil
2996
+ return ve , compact.Stats {}, []compact. OutputBlob {}, nil
2975
2997
}
2976
2998
2977
2999
// applyHintOnFile applies a deleteCompactionHint to a file, and updates the
@@ -3138,7 +3160,7 @@ func fragmentDeleteCompactionHints(
3138
3160
// d.mu must *not* be held when calling this.
3139
3161
func (d * DB ) runDeleteOnlyCompaction (
3140
3162
jobID JobID , c * tableCompaction , snapshots compact.Snapshots ,
3141
- ) (ve * manifest.VersionEdit , stats compact.Stats , retErr error ) {
3163
+ ) (ve * manifest.VersionEdit , stats compact.Stats , blobs []compact. OutputBlob , retErr error ) {
3142
3164
fragments := fragmentDeleteCompactionHints (d .cmp , c .deleteOnly .hints )
3143
3165
ve = & manifest.VersionEdit {
3144
3166
DeletedTables : map [manifest.DeletedTableEntry ]* manifest.TableMetadata {},
@@ -3147,7 +3169,7 @@ func (d *DB) runDeleteOnlyCompaction(
3147
3169
levelMetrics := c .metrics .perLevel .level (cl .level )
3148
3170
err := d .runDeleteOnlyCompactionForLevel (cl , levelMetrics , ve , snapshots , fragments , c .deleteOnly .exciseEnabled )
3149
3171
if err != nil {
3150
- return nil , stats , err
3172
+ return nil , stats , blobs , err
3151
3173
}
3152
3174
}
3153
3175
// Remove any files that were added and deleted in the same versionEdit.
@@ -3197,19 +3219,19 @@ func (d *DB) runDeleteOnlyCompaction(
3197
3219
// Refresh the disk available statistic whenever a compaction/flush
3198
3220
// completes, before re-acquiring the mutex.
3199
3221
d .calculateDiskAvailableBytes ()
3200
- return ve , stats , nil
3222
+ return ve , stats , blobs , nil
3201
3223
}
3202
3224
3203
3225
func (d * DB ) runMoveCompaction (
3204
3226
jobID JobID , c * tableCompaction ,
3205
- ) (ve * manifest.VersionEdit , stats compact.Stats , _ error ) {
3227
+ ) (ve * manifest.VersionEdit , stats compact.Stats , blobs []compact. OutputBlob , _ error ) {
3206
3228
iter := c .startLevel .files .Iter ()
3207
3229
meta := iter .First ()
3208
3230
if iter .Next () != nil {
3209
- return nil , stats , base .AssertionFailedf ("got more than one file for a move compaction" )
3231
+ return nil , stats , blobs , base .AssertionFailedf ("got more than one file for a move compaction" )
3210
3232
}
3211
3233
if c .cancel .Load () {
3212
- return ve , stats , ErrCancelledCompaction
3234
+ return ve , stats , blobs , ErrCancelledCompaction
3213
3235
}
3214
3236
outputMetrics := c .metrics .perLevel .level (c .outputLevel .level )
3215
3237
outputMetrics .TableBytesMoved = meta .Size
@@ -3223,7 +3245,7 @@ func (d *DB) runMoveCompaction(
3223
3245
},
3224
3246
}
3225
3247
3226
- return ve , stats , nil
3248
+ return ve , stats , blobs , nil
3227
3249
}
3228
3250
3229
3251
// runCompaction runs a compaction that produces new on-disk tables from
@@ -3235,9 +3257,14 @@ func (d *DB) runMoveCompaction(
3235
3257
// re-acquired during the course of this method.
3236
3258
func (d * DB ) runCompaction (
3237
3259
jobID JobID , c * tableCompaction ,
3238
- ) (ve * manifest.VersionEdit , stats compact.Stats , retErr error ) {
3260
+ ) (
3261
+ ve * manifest.VersionEdit ,
3262
+ stats compact.Stats ,
3263
+ outputBlobs []compact.OutputBlob ,
3264
+ retErr error ,
3265
+ ) {
3239
3266
if c .cancel .Load () {
3240
- return ve , stats , ErrCancelledCompaction
3267
+ return ve , stats , outputBlobs , ErrCancelledCompaction
3241
3268
}
3242
3269
switch c .kind {
3243
3270
case compactionKindDeleteOnly :
@@ -3300,7 +3327,7 @@ func (d *DB) runCompaction(
3300
3327
// Refresh the disk available statistic whenever a compaction/flush
3301
3328
// completes, before re-acquiring the mutex.
3302
3329
d .calculateDiskAvailableBytes ()
3303
- return ve , result .Stats , result .Err
3330
+ return ve , result .Stats , result .Blobs , result . Err
3304
3331
}
3305
3332
3306
3333
// compactAndWrite runs the data part of a compaction, where we set up a
0 commit comments