github.com/zuoyebang/bitalostable@v1.0.1-0.20240229032404-e3b99a834294/testdata/compaction_tombstones (about)

     1  # Test an L6 file that contains range tombstones, but whose keys are not in
     2  # the last snapshot stripe. The tombstones wouldn't be elided, so no
     3  # compaction is pursued.
     4  define snapshots=(70, 100, 180, 210)
     5  L6
     6  b.RANGEDEL.230:h h.RANGEDEL.200:r
     7  ----
     8  6:
     9    000004:[b#230,RANGEDEL-r#72057594037927935,RANGEDEL]
    10  
    11  wait-pending-table-stats
    12  000004
    13  ----
    14  num-entries: 2
    15  num-deletions: 2
    16  num-range-key-sets: 0
    17  point-deletions-bytes-estimate: 0
    18  range-deletions-bytes-estimate: 0
    19  
    20  maybe-compact
    21  ----
    22  (none)
    23  
    24  # Test the same scenario, but the file is in the last stripe. Since the file
    25  # only contains deletes, no new sstable is written.
    26  define snapshots=(270, 300, 380, 410)
    27  L6
    28  b.RANGEDEL.230:h h.RANGEDEL.200:r
    29  ----
    30  6:
    31    000004:[b#230,RANGEDEL-r#72057594037927935,RANGEDEL]
    32  
    33  wait-pending-table-stats
    34  000004
    35  ----
    36  num-entries: 2
    37  num-deletions: 2
    38  num-range-key-sets: 0
    39  point-deletions-bytes-estimate: 0
    40  range-deletions-bytes-estimate: 0
    41  
    42  maybe-compact
    43  ----
    44  [JOB 100] compacted(elision-only) L6 [000004] (853 B) + L6 [] (0 B) -> L6 [] (0 B), in 1.0s (2.0s total), output rate 0 B/s
    45  
    46  # Test a table that straddles a snapshot. It should not be compacted.
    47  define snapshots=(50)
    48  L6
    49  a.SET.55:a b.RANGEDEL.5:h
    50  ----
    51  6:
    52    000004:[a#55,SET-h#72057594037927935,RANGEDEL]
    53  
    54  wait-pending-table-stats
    55  000004
    56  ----
    57  num-entries: 2
    58  num-deletions: 1
    59  num-range-key-sets: 0
    60  point-deletions-bytes-estimate: 0
    61  range-deletions-bytes-estimate: 26
    62  
    63  maybe-compact
    64  ----
    65  (none)
    66  
    67  # Test a table with a point deletion and a non-deletion entry. The table
    68  # should be compacted, and a new table with the point tombstone should be
    69  # written.
    70  define
    71  L6
    72  a.SET.55:a b.DEL.5:
    73  ----
    74  6:
    75    000004:[a#55,SET-b#5,DEL]
    76  
    77  wait-pending-table-stats
    78  000004
    79  ----
    80  num-entries: 2
    81  num-deletions: 1
    82  num-range-key-sets: 0
    83  point-deletions-bytes-estimate: 0
    84  range-deletions-bytes-estimate: 0
    85  
    86  maybe-compact
    87  ----
    88  [JOB 100] compacted(elision-only) L6 [000004] (783 B) + L6 [] (0 B) -> L6 [000005] (771 B), in 1.0s (2.0s total), output rate 771 B/s
    89  
    90  version
    91  ----
    92  6:
    93    000005:[a#0,SET-a#0,SET]
    94  
    95  # Checking for a compaction again should not trigger a compaction, because
    96  # 000005 does not contain deletions.
    97  
    98  maybe-compact
    99  ----
   100  (none)
   101  
   102  maybe-compact
   103  ----
   104  (none)
   105  
   106  # Test a table that contains both deletions and non-deletions, but whose
   107  # deletions remove the non-deletions. The compaction should not create a new
   108  # table, but shouldn't happen until the snapshots are removed.
   109  define snapshots=(59, 103)
   110  L6
   111  a.DEL.60: a.SET.55:a b.SET.100:b c.SET.101:c d.SET.102:d b.RANGEDEL.103:z
   112  ----
   113  6:
   114    000004:[a#60,DEL-z#72057594037927935,RANGEDEL]
   115  
   116  wait-pending-table-stats
   117  000004
   118  ----
   119  num-entries: 6
   120  num-deletions: 2
   121  num-range-key-sets: 0
   122  point-deletions-bytes-estimate: 0
   123  range-deletions-bytes-estimate: 76
   124  
   125  maybe-compact
   126  ----
   127  (none)
   128  
   129  close-snapshot
   130  59
   131  ----
   132  (none)
   133  
   134  close-snapshot
   135  103
   136  ----
   137  [JOB 100] compacted(elision-only) L6 [000004] (901 B) + L6 [] (0 B) -> L6 [] (0 B), in 1.0s (2.0s total), output rate 0 B/s
   138  
   139  # Test a table that contains both deletions and non-deletions, but whose
   140  # non-deletions well outnumber its deletions. The table should not be
   141  # compacted because it falls beneath the threshold.
   142  define snapshots=(15)
   143  L6
   144  a.DEL.20: a.SET.1:a b.SET.2:b c.SET.3:c d.SET.4:d e.SET.5:e f.SET.6:f g.SET.7:g h.SET.8:h i.SET.9:i j.SET.10:j
   145  ----
   146  6:
   147    000004:[a#20,DEL-j#10,SET]
   148  
   149  wait-pending-table-stats
   150  000004
   151  ----
   152  num-entries: 11
   153  num-deletions: 1
   154  num-range-key-sets: 0
   155  point-deletions-bytes-estimate: 149
   156  range-deletions-bytes-estimate: 0
   157  
   158  close-snapshot
   159  15
   160  ----
   161  (none)
   162  
   163  # Test a table that contains both deletions and non-deletions, but whose
   164  # deletions remove the non-deletions. Set L5's max bytes low so that an
   165  # automatic compaction will be pursued when we call maybe-compact.
   166  # Automatic compactions need to be disabled to prevent a race where an
   167  # automatic compaction compacts before we've closen the snapshot.
   168  define snapshots=(103) level-max-bytes=(L5 : 1000) auto-compactions=off
   169  L5
   170  b.SET.200:<largeval> bb.SET.203:<largeval> cc.SET.204:<largeval>
   171  L5
   172  d.SET.302:<largeval> dd.SET.303:<largeval> de.SET.303:<largeval>
   173  L5
   174  m.SET.320:<largeval> n.SET.330:<largeval> o.SET.340:<largeval>
   175  L6
   176  a.SET.55:<largeval> b.SET.100:<largeval> c.SET.101:<largeval> d.SET.102:<largeval> a.RANGEDEL.103:e
   177  L6
   178  f.SET.30:<largeval> z.SET.31:<largeval>
   179  ----
   180  5:
   181    000004:[b#200,SET-cc#204,SET]
   182    000005:[d#302,SET-de#303,SET]
   183    000006:[m#320,SET-o#340,SET]
   184  6:
   185    000007:[a#103,RANGEDEL-e#72057594037927935,RANGEDEL]
   186    000008:[f#30,SET-z#31,SET]
   187  
   188  close-snapshot
   189  103
   190  ----
   191  (none)
   192  
   193  wait-pending-table-stats
   194  000007
   195  ----
   196  num-entries: 5
   197  num-deletions: 1
   198  num-range-key-sets: 0
   199  point-deletions-bytes-estimate: 0
   200  range-deletions-bytes-estimate: 16488
   201  
   202  # Because we set max bytes low, maybe-compact will trigger an automatic
   203  # compaction in preference over an elision-only compaction.
   204  # By plain file size, 000006 should be picked because it overlaps
   205  # significantly less data in L6. However, 000007 has significant obsolete
   206  # data. The compaction picker should recognize that it's more efficient to
   207  # compact (000004 + 000005) into 000007.
   208  
   209  maybe-compact
   210  ----
   211  [JOB 100] compacted(default) L5 [000004 000005] (26 K) + L6 [000007] (17 K) -> L6 [000009] (25 K), in 1.0s (2.0s total), output rate 25 K/s
   212  
   213  define level-max-bytes=(L5 : 1000) auto-compactions=off
   214  L5
   215  a.DEL.101: b.DEL.102: c.DEL.103:
   216  L5
   217  m.SET.107:<largeval>
   218  L6
   219  a.SET.001:<largeval> b.SET.002:<largeval> c.SET.003:<largeval>
   220  L6
   221  f.SET.007:<largeval> x.SET.008:<largeval> z.SET.009:<largeval>
   222  ----
   223  5:
   224    000004:[a#101,DEL-c#103,DEL]
   225    000005:[m#107,SET-m#107,SET]
   226  6:
   227    000006:[a#1,SET-c#3,SET]
   228    000007:[f#7,SET-z#9,SET]
   229  
   230  wait-pending-table-stats
   231  000004
   232  ----
   233  num-entries: 3
   234  num-deletions: 3
   235  num-range-key-sets: 0
   236  point-deletions-bytes-estimate: 13167
   237  range-deletions-bytes-estimate: 0
   238  
   239  # By plain file size, 000005 should be picked because it is larger and
   240  # overlaps the same amount of data in L6. However, 000004 has a high
   241  # point-deletions-bytes-estimate, and the compaction picker should pick 000004
   242  # instead.
   243  
   244  maybe-compact
   245  ----
   246  [JOB 100] compacted(default) L5 [000004] (794 B) + L6 [000006] (13 K) -> L6 [] (0 B), in 1.0s (2.0s total), output rate 0 B/s
   247  
   248  # A table containing only range keys is not eligible for elision.
   249  # RANGEKEYDEL or RANGEKEYUNSET.
   250  
   251  define
   252  L6
   253    rangekey:a-b:{(#1,RANGEKEYDEL)}
   254  L6
   255    rangekey:b-c:{(#2,RANGEKEYUNSET,@1)}
   256  L6
   257    rangekey:c-d:{(#3,RANGEKEYSET,@1)}
   258  ----
   259  6:
   260    000004:[a#1,RANGEKEYDEL-b#72057594037927935,RANGEKEYDEL]
   261    000005:[b#2,RANGEKEYUNSET-c#72057594037927935,RANGEKEYUNSET]
   262    000006:[c#3,RANGEKEYSET-d#72057594037927935,RANGEKEYSET]
   263  
   264  wait-pending-table-stats
   265  000004
   266  ----
   267  num-entries: 0
   268  num-deletions: 0
   269  num-range-key-sets: 0
   270  point-deletions-bytes-estimate: 0
   271  range-deletions-bytes-estimate: 0
   272  
   273  wait-pending-table-stats
   274  000005
   275  ----
   276  num-entries: 0
   277  num-deletions: 0
   278  num-range-key-sets: 0
   279  point-deletions-bytes-estimate: 0
   280  range-deletions-bytes-estimate: 0
   281  
   282  wait-pending-table-stats
   283  000006
   284  ----
   285  num-entries: 0
   286  num-deletions: 0
   287  num-range-key-sets: 1
   288  point-deletions-bytes-estimate: 0
   289  range-deletions-bytes-estimate: 0
   290  
   291  maybe-compact
   292  ----
   293  (none)