github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/testdata/manual_compaction (about)

     1  batch
     2  set a 1
     3  set b 2
     4  ----
     5  
     6  compact a-b
     7  ----
     8  6:
     9    000005:[a#10,SET-b#11,SET]
    10  
    11  batch
    12  set c 3
    13  set d 4
    14  ----
    15  
    16  compact c-d
    17  ----
    18  6:
    19    000005:[a#10,SET-b#11,SET]
    20    000007:[c#12,SET-d#13,SET]
    21  
    22  batch
    23  set b 5
    24  set c 6
    25  ----
    26  
    27  compact a-d
    28  ----
    29  6:
    30    000010:[a#0,SET-d#0,SET]
    31  
    32  # This also tests flushing a memtable that only contains range
    33  # deletions.
    34  
    35  batch
    36  del-range a e
    37  ----
    38  
    39  compact a-d
    40  ----
    41  
    42  # Test that a multi-output-file compaction generates non-overlapping files.
    43  
    44  define target-file-sizes=(100, 1)
    45  L0
    46    b.SET.1:v
    47  L0
    48    a.SET.2:v
    49  ----
    50  0.0:
    51    000005:[a#2,SET-a#2,SET]
    52    000004:[b#1,SET-b#1,SET]
    53  
    54  compact a-b
    55  ----
    56  1:
    57    000006:[a#0,SET-a#0,SET]
    58    000007:[b#0,SET-b#0,SET]
    59  
    60  # A range tombstone extends past the grandparent file boundary used to limit the
    61  # size of future compactions. Verify the range tombstone is split at that file
    62  # boundary.
    63  
    64  define target-file-sizes=(1, 1, 1, 1)
    65  L1
    66    a.SET.3:v
    67  L2
    68    a.RANGEDEL.2:e
    69  L3
    70    a.SET.0:v
    71    b.SET.0:v
    72  L3
    73    c.SET.0:v
    74    d.SET.0:v
    75  ----
    76  1:
    77    000004:[a#3,SET-a#3,SET]
    78  2:
    79    000005:[a#2,RANGEDEL-e#inf,RANGEDEL]
    80  3:
    81    000006:[a#0,SET-b#0,SET]
    82    000007:[c#0,SET-d#0,SET]
    83  
    84  wait-pending-table-stats
    85  000005
    86  ----
    87  num-entries: 1
    88  num-deletions: 1
    89  num-range-key-sets: 0
    90  point-deletions-bytes-estimate: 0
    91  range-deletions-bytes-estimate: 1552
    92  
    93  compact a-e L1
    94  ----
    95  2:
    96    000008:[a#3,SET-c#inf,RANGEDEL]
    97    000009:[c#2,RANGEDEL-e#inf,RANGEDEL]
    98  3:
    99    000006:[a#0,SET-b#0,SET]
   100    000007:[c#0,SET-d#0,SET]
   101  
   102  wait-pending-table-stats
   103  000008
   104  ----
   105  num-entries: 2
   106  num-deletions: 1
   107  num-range-key-sets: 0
   108  point-deletions-bytes-estimate: 0
   109  range-deletions-bytes-estimate: 776
   110  
   111  # Same as above, except range tombstone covers multiple grandparent file boundaries.
   112  
   113  define target-file-sizes=(1, 1, 1, 1) format-major-version=1
   114  L1
   115    a.SET.3:v
   116  L2
   117    a.RANGEDEL.2:g
   118  L3
   119    a.SET.0:v
   120    b.SET.0:v
   121  L3
   122    c.SET.0:v
   123    d.SET.0:v
   124  L3
   125    e.SET.0:v
   126    f.SET.1:v
   127  L3
   128    f.SET.0:v
   129    g.SET.0:v
   130  ----
   131  1:
   132    000004:[a#3,SET-a#3,SET]
   133  2:
   134    000005:[a#2,RANGEDEL-g#inf,RANGEDEL]
   135  3:
   136    000006:[a#0,SET-b#0,SET]
   137    000007:[c#0,SET-d#0,SET]
   138    000008:[e#0,SET-f#1,SET]
   139    000009:[f#0,SET-g#0,SET]
   140  
   141  compact a-e L1
   142  ----
   143  2:
   144    000010:[a#3,SET-c#inf,RANGEDEL]
   145    000011:[c#2,RANGEDEL-e#inf,RANGEDEL]
   146    000012:[e#2,RANGEDEL-f#inf,RANGEDEL]
   147    000013:[f#2,RANGEDEL-g#inf,RANGEDEL]
   148  3:
   149    000006:[a#0,SET-b#0,SET]
   150    000007:[c#0,SET-d#0,SET]
   151    000008:[e#0,SET-f#1,SET]
   152    000009:[f#0,SET-g#0,SET]
   153  
   154  # A range tombstone covers multiple grandparent file boundaries between point keys,
   155  # rather than after all point keys.
   156  
   157  define target-file-sizes=(1, 1, 1, 1)
   158  L1
   159    a.SET.3:v
   160    h.SET.3:v
   161  L2
   162    a.RANGEDEL.2:g
   163  L3
   164    a.SET.0:v
   165    b.SET.0:v
   166  L3
   167    c.SET.0:v
   168    d.SET.0:v
   169  L3
   170    e.SET.0:v
   171    f.SET.1:v
   172  ----
   173  1:
   174    000004:[a#3,SET-h#3,SET]
   175  2:
   176    000005:[a#2,RANGEDEL-g#inf,RANGEDEL]
   177  3:
   178    000006:[a#0,SET-b#0,SET]
   179    000007:[c#0,SET-d#0,SET]
   180    000008:[e#0,SET-f#1,SET]
   181  
   182  compact a-e L1
   183  ----
   184  2:
   185    000009:[a#3,SET-c#inf,RANGEDEL]
   186    000010:[c#2,RANGEDEL-h#3,SET]
   187  3:
   188    000006:[a#0,SET-b#0,SET]
   189    000007:[c#0,SET-d#0,SET]
   190    000008:[e#0,SET-f#1,SET]
   191  
   192  # A range tombstone is the first and only item output by a compaction, and it
   193  # extends past the grandparent file boundary used to limit the size of future
   194  # compactions. Verify the range tombstone is split at that file boundary.
   195  
   196  define target-file-sizes=(1, 1, 1, 1)
   197  L1
   198    a.RANGEDEL.3:e
   199  L2
   200    a.SET.2:v
   201  L3
   202    a.SET.0:v
   203    b.SET.0:v
   204  L3
   205    c.SET.0:v
   206    d.SET.0:v
   207  ----
   208  1:
   209    000004:[a#3,RANGEDEL-e#inf,RANGEDEL]
   210  2:
   211    000005:[a#2,SET-a#2,SET]
   212  3:
   213    000006:[a#0,SET-b#0,SET]
   214    000007:[c#0,SET-d#0,SET]
   215  
   216  compact a-e L1
   217  ----
   218  2:
   219    000008:[a#3,RANGEDEL-c#inf,RANGEDEL]
   220    000009:[c#3,RANGEDEL-e#inf,RANGEDEL]
   221  3:
   222    000006:[a#0,SET-b#0,SET]
   223    000007:[c#0,SET-d#0,SET]
   224  
   225  # An elided range tombstone is the first item encountered by a compaction,
   226  # and the grandparent limit set by it extends to the next item, also a range
   227  # tombstone. The first item should be elided, and the second item should
   228  # reset the grandparent limit.
   229  
   230  define target-file-sizes=(100, 100, 100, 100)
   231  L1
   232    a.RANGEDEL.4:d
   233  L1
   234    grandparent.RANGEDEL.2:z
   235    h.SET.3:v
   236  L2
   237    grandparent.SET.1:v
   238  L3
   239    grandparent.SET.0:v
   240  L3
   241    m.SET.0:v
   242  ----
   243  1:
   244    000004:[a#4,RANGEDEL-d#inf,RANGEDEL]
   245    000005:[grandparent#2,RANGEDEL-z#inf,RANGEDEL]
   246  2:
   247    000006:[grandparent#1,SET-grandparent#1,SET]
   248  3:
   249    000007:[grandparent#0,SET-grandparent#0,SET]
   250    000008:[m#0,SET-m#0,SET]
   251  
   252  compact a-h L1
   253  ----
   254  2:
   255    000009:[grandparent#2,RANGEDEL-m#inf,RANGEDEL]
   256    000010:[m#2,RANGEDEL-z#inf,RANGEDEL]
   257  3:
   258    000007:[grandparent#0,SET-grandparent#0,SET]
   259    000008:[m#0,SET-m#0,SET]
   260  
   261  # Setup such that grandparent overlap limit is exceeded multiple times at the same user key ("b").
   262  # Ensures the compaction output files are non-overlapping.
   263  
   264  define target-file-sizes=(1, 1, 1, 1)
   265  L1
   266    a.SET.2:v
   267    c.SET.2:v
   268  L2
   269    a.RANGEDEL.3:c
   270  L3
   271    b.SET.2:v
   272  L3
   273    b.SET.1:v
   274  L3
   275    b.SET.0:v
   276  ----
   277  1:
   278    000004:[a#2,SET-c#2,SET]
   279  2:
   280    000005:[a#3,RANGEDEL-c#inf,RANGEDEL]
   281  3:
   282    000006:[b#2,SET-b#2,SET]
   283    000007:[b#1,SET-b#1,SET]
   284    000008:[b#0,SET-b#0,SET]
   285  
   286  compact a-c L1
   287  ----
   288  2:
   289    000009:[a#3,RANGEDEL-b#inf,RANGEDEL]
   290    000010:[b#3,RANGEDEL-c#2,SET]
   291  3:
   292    000006:[b#2,SET-b#2,SET]
   293    000007:[b#1,SET-b#1,SET]
   294    000008:[b#0,SET-b#0,SET]
   295  
   296  # Regression test for a bug where compaction would stop process range
   297  # tombstones for an input level upon finding an sstable in the input
   298  # level with no range tombstones. In the scenario below, sstable 6
   299  # does not contain any range tombstones while sstable 7 does. Both are
   300  # compacted together with sstable 5.
   301  
   302  reset
   303  ----
   304  
   305  batch
   306  set a 1
   307  set b 1
   308  set c 1
   309  set d 1
   310  set z 1
   311  ----
   312  
   313  compact a-z
   314  ----
   315  6:
   316    000005:[a#10,SET-z#14,SET]
   317  
   318  build ext1
   319  set a 2
   320  ----
   321  
   322  build ext2
   323  set b 2
   324  del-range c z
   325  ----
   326  
   327  ingest ext1 ext2
   328  ----
   329  0.0:
   330    000006:[a#15,SET-a#15,SET]
   331    000007:[b#16,SET-z#inf,RANGEDEL]
   332  6:
   333    000005:[a#10,SET-z#14,SET]
   334  
   335  iter
   336  first
   337  next
   338  next
   339  next
   340  ----
   341  a: (2, .)
   342  b: (2, .)
   343  z: (1, .)
   344  .
   345  
   346  compact a-z
   347  ----
   348  6:
   349    000008:[a#0,SET-z#0,SET]
   350  
   351  iter
   352  first
   353  next
   354  next
   355  next
   356  ----
   357  a: (2, .)
   358  b: (2, .)
   359  z: (1, .)
   360  .
   361  
   362  # Regresion test for a bug in sstable smallest boundary generation
   363  # where the smallest key for an sstable was set to a key "larger" than
   364  # the start key of the first range tombstone. This in turn fouled up
   365  # the processing logic of range tombstones used by mergingIter which
   366  # allowed stepping out of an sstable even though it contained a range
   367  # tombstone that covered keys in lower levels.
   368  
   369  define target-file-sizes=(1, 1, 1, 1)
   370  L0
   371    c.SET.4:4
   372  L1
   373    a.SET.3:3
   374  L2
   375    a.RANGEDEL.2:e
   376  L3
   377    b.SET.1:1
   378  ----
   379  0.0:
   380    000004:[c#4,SET-c#4,SET]
   381  1:
   382    000005:[a#3,SET-a#3,SET]
   383  2:
   384    000006:[a#2,RANGEDEL-e#inf,RANGEDEL]
   385  3:
   386    000007:[b#1,SET-b#1,SET]
   387  
   388  compact a-e L1
   389  ----
   390  0.0:
   391    000004:[c#4,SET-c#4,SET]
   392  2:
   393    000008:[a#3,SET-b#inf,RANGEDEL]
   394    000009:[b#2,RANGEDEL-e#inf,RANGEDEL]
   395  3:
   396    000007:[b#1,SET-b#1,SET]
   397  
   398  # We should only see a:3 and c:4 at this point.
   399  
   400  iter
   401  first
   402  next
   403  next
   404  ----
   405  a: (3, .)
   406  c: (4, .)
   407  .
   408  
   409  # The bug allowed seeing b:1 during reverse iteration.
   410  
   411  iter
   412  last
   413  prev
   414  prev
   415  ----
   416  c: (4, .)
   417  a: (3, .)
   418  .
   419  
   420  # This is a similar scenario to the one above. In older versions of Pebble this
   421  # case necessitated adjusting the seqnum of the range tombstone to
   422  # prev.LargestKey.SeqNum-1. We no longer allow user keys to be split across
   423  # sstables, and the seqnum adjustment is no longer necessary.
   424  #
   425  # Note the target-file-size of 26 is specially tailored to get the
   426  # desired compaction output.
   427  
   428  define target-file-sizes=(26, 26, 26, 26) snapshots=(1, 2, 3)
   429  L1
   430    a.SET.4:4
   431  L1
   432    b.SET.2:2
   433    b.RANGEDEL.3:e
   434  L3
   435    b.SET.1:1
   436  ----
   437  1:
   438    000004:[a#4,SET-a#4,SET]
   439    000005:[b#3,RANGEDEL-e#inf,RANGEDEL]
   440  3:
   441    000006:[b#1,SET-b#1,SET]
   442  
   443  compact a-e L1
   444  ----
   445  2:
   446    000007:[a#4,SET-a#4,SET]
   447    000008:[b#3,RANGEDEL-e#inf,RANGEDEL]
   448  3:
   449    000006:[b#1,SET-b#1,SET]
   450  
   451  iter
   452  first
   453  next
   454  last
   455  prev
   456  ----
   457  a: (4, .)
   458  .
   459  a: (4, .)
   460  .
   461  
   462  # Similar to the preceding scenario, except the range tombstone has
   463  # the same seqnum as the largest key in the preceding file.
   464  
   465  define target-file-sizes=(26, 26, 26, 26) snapshots=(1, 2, 3)
   466  L1
   467    a.SET.4:4
   468  L1
   469    b.SET.3:3
   470    b.RANGEDEL.3:e
   471  L3
   472    b.SET.1:1
   473  ----
   474  1:
   475    000004:[a#4,SET-a#4,SET]
   476    000005:[b#3,RANGEDEL-e#inf,RANGEDEL]
   477  3:
   478    000006:[b#1,SET-b#1,SET]
   479  
   480  compact a-e L1
   481  ----
   482  2:
   483    000007:[a#4,SET-a#4,SET]
   484    000008:[b#3,RANGEDEL-e#inf,RANGEDEL]
   485  3:
   486    000006:[b#1,SET-b#1,SET]
   487  
   488  iter
   489  first
   490  next
   491  next
   492  last
   493  prev
   494  prev
   495  ----
   496  a: (4, .)
   497  b: (3, .)
   498  .
   499  b: (3, .)
   500  a: (4, .)
   501  .
   502  
   503  # Similar to the preceding scenario, except the range tombstone has
   504  # a smaller seqnum than the largest key in the preceding file.
   505  
   506  define target-file-sizes=(26, 26, 26, 26) snapshots=(1, 2, 3)
   507  L1
   508    a.SET.4:4
   509  L1
   510    b.SET.4:4
   511    b.RANGEDEL.2:e
   512  L3
   513    b.SET.1:1
   514  ----
   515  1:
   516    000004:[a#4,SET-a#4,SET]
   517    000005:[b#4,SET-e#inf,RANGEDEL]
   518  3:
   519    000006:[b#1,SET-b#1,SET]
   520  
   521  compact a-e L1
   522  ----
   523  2:
   524    000007:[a#4,SET-a#4,SET]
   525    000008:[b#4,SET-e#inf,RANGEDEL]
   526  3:
   527    000006:[b#1,SET-b#1,SET]
   528  
   529  iter
   530  first
   531  next
   532  next
   533  last
   534  prev
   535  prev
   536  ----
   537  a: (4, .)
   538  b: (4, .)
   539  .
   540  b: (4, .)
   541  a: (4, .)
   542  .
   543  
   544  # Test a scenario where the last point key in an sstable has a seqnum
   545  # of 0.
   546  
   547  define target-file-sizes=(1, 1, 26) snapshots=(2)
   548  L1
   549    a.SET.3:3
   550    b.RANGEDEL.3:e
   551    b.SET.0:0
   552  L3
   553    a.RANGEDEL.2:b
   554  L3
   555    c.SET.0:0
   556    d.SET.0:0
   557  ----
   558  1:
   559    000004:[a#3,SET-e#inf,RANGEDEL]
   560  3:
   561    000005:[a#2,RANGEDEL-b#inf,RANGEDEL]
   562    000006:[c#0,SET-d#0,SET]
   563  
   564  iter
   565  last
   566  prev
   567  ----
   568  a: (3, .)
   569  .
   570  
   571  compact a-e L1
   572  ----
   573  2:
   574    000007:[a#3,SET-c#inf,RANGEDEL]
   575    000008:[c#3,RANGEDEL-e#inf,RANGEDEL]
   576  3:
   577    000005:[a#2,RANGEDEL-b#inf,RANGEDEL]
   578    000006:[c#0,SET-d#0,SET]
   579  
   580  iter
   581  last
   582  prev
   583  ----
   584  a: (3, .)
   585  .
   586  
   587  # Test a scenario where the last point key in an sstable before the
   588  # grandparent limit is reached has a seqnum of 0. We want to cut the
   589  # sstable after the next point key is added, rather than continuing to
   590  # add keys indefinitely (or till the size limit is reached).
   591  
   592  define target-file-sizes=(100, 1, 52) snapshots=(2)
   593  L1
   594    a.SET.3:3
   595    b.RANGEDEL.3:e
   596    b.SET.0:0
   597    c.SET.3:1
   598    d.SET.1:1
   599  L3
   600    c.RANGEDEL.2:d
   601  ----
   602  1:
   603    000004:[a#3,SET-e#inf,RANGEDEL]
   604  3:
   605    000005:[c#2,RANGEDEL-d#inf,RANGEDEL]
   606  
   607  compact a-f L1
   608  ----
   609  2:
   610    000006:[a#3,SET-c#inf,RANGEDEL]
   611    000007:[c#3,RANGEDEL-e#inf,RANGEDEL]
   612  3:
   613    000005:[c#2,RANGEDEL-d#inf,RANGEDEL]
   614  
   615  # Test a scenario where we the last point key in an sstable has a
   616  # seqnum of 0, but there is another range tombstone later in the
   617  # compaction. This scenario was previously triggering an assertion due
   618  # to the rangedel.Fragmenter being finished prematurely.
   619  
   620  define target-file-sizes=(1, 1, 1)
   621  L1
   622    a.SET.0:0
   623    c.RANGEDEL.1:d
   624  L3
   625    b.SET.0:0
   626  ----
   627  1:
   628    000004:[a#0,SET-d#inf,RANGEDEL]
   629  3:
   630    000005:[b#0,SET-b#0,SET]
   631  
   632  compact a-e L1
   633  ----
   634  2:
   635    000006:[a#0,SET-a#0,SET]
   636  3:
   637    000005:[b#0,SET-b#0,SET]
   638  
   639  define target-file-sizes=(1, 1, 1, 1)
   640  L0
   641    b.SET.1:v
   642  L0
   643    a.SET.2:v
   644  ----
   645  0.0:
   646    000005:[a#2,SET-a#2,SET]
   647    000004:[b#1,SET-b#1,SET]
   648  
   649  add-ongoing-compaction startLevel=0 outputLevel=1 start=a end=b
   650  ----
   651  
   652  async-compact a-b L0
   653  ----
   654  manual compaction blocked until ongoing finished
   655  1:
   656    000006:[a#0,SET-a#0,SET]
   657    000007:[b#0,SET-b#0,SET]
   658  
   659  compact a-b L1
   660  ----
   661  2:
   662    000008:[a#0,SET-a#0,SET]
   663    000009:[b#0,SET-b#0,SET]
   664  
   665  add-ongoing-compaction startLevel=0 outputLevel=1 start=a end=b
   666  ----
   667  
   668  async-compact a-b L2
   669  ----
   670  manual compaction blocked until ongoing finished
   671  3:
   672    000010:[a#0,SET-a#0,SET]
   673    000011:[b#0,SET-b#0,SET]
   674  
   675  add-ongoing-compaction startLevel=0 outputLevel=1 start=a end=b
   676  ----
   677  
   678  set-concurrent-compactions num=2
   679  ----
   680  
   681  async-compact a-b L3
   682  ----
   683  manual compaction did not block for ongoing
   684  4:
   685    000012:[a#0,SET-a#0,SET]
   686    000013:[b#0,SET-b#0,SET]
   687  
   688  remove-ongoing-compaction
   689  ----
   690  
   691  add-ongoing-compaction startLevel=4 outputLevel=5 start=a end=b
   692  ----
   693  
   694  async-compact a-b L4
   695  ----
   696  manual compaction blocked until ongoing finished
   697  5:
   698    000014:[a#0,SET-a#0,SET]
   699    000015:[b#0,SET-b#0,SET]
   700  
   701  # Test of a scenario where consecutive elided range tombstones and grandparent
   702  # boundaries could result in an invariant violation in the rangedel fragmenter.
   703  
   704  define target-file-sizes=(1, 1, 1, 1)
   705  L1
   706    a.RANGEDEL.4:b
   707    c.RANGEDEL.4:d
   708    e.RANGEDEL.4:f
   709  L1
   710    g.RANGEDEL.6:h
   711    i.RANGEDEL.4:j
   712  L1
   713    k.RANGEDEL.5:q
   714    m.RANGEDEL.4:q
   715  L2
   716    a.SET.2:foo
   717  L3
   718    a.SET.1:foo
   719    c.SET.1:foo
   720  L3
   721    ff.SET.1:v
   722  L3
   723    k.SET.1:foo
   724  ----
   725  1:
   726    000004:[a#4,RANGEDEL-f#inf,RANGEDEL]
   727    000005:[g#6,RANGEDEL-j#inf,RANGEDEL]
   728    000006:[k#5,RANGEDEL-q#inf,RANGEDEL]
   729  2:
   730    000007:[a#2,SET-a#2,SET]
   731  3:
   732    000008:[a#1,SET-c#1,SET]
   733    000009:[ff#1,SET-ff#1,SET]
   734    000010:[k#1,SET-k#1,SET]
   735  
   736  compact a-q L1
   737  ----
   738  2:
   739    000011:[a#4,RANGEDEL-d#inf,RANGEDEL]
   740    000012:[k#5,RANGEDEL-m#inf,RANGEDEL]
   741  3:
   742    000008:[a#1,SET-c#1,SET]
   743    000009:[ff#1,SET-ff#1,SET]
   744    000010:[k#1,SET-k#1,SET]
   745  
   746  # Test a case where a new output file is started, there are no previous output
   747  # files, there are no additional keys (key = nil) and the rangedel fragmenter
   748  # is non-empty.
   749  define target-file-sizes=(1, 1, 1)
   750  L1
   751    a.RANGEDEL.10:b
   752    d.RANGEDEL.9:e
   753    q.RANGEDEL.8:r
   754  L2
   755    g.RANGEDEL.7:h
   756  L3
   757    q.SET.6:6
   758  ----
   759  1:
   760    000004:[a#10,RANGEDEL-r#inf,RANGEDEL]
   761  2:
   762    000005:[g#7,RANGEDEL-h#inf,RANGEDEL]
   763  3:
   764    000006:[q#6,SET-q#6,SET]
   765  
   766  compact a-r L1
   767  ----
   768  2:
   769    000007:[q#8,RANGEDEL-r#inf,RANGEDEL]
   770  3:
   771    000006:[q#6,SET-q#6,SET]
   772  
   773  define target-file-sizes=(100, 100, 100)
   774  L1
   775    a.RANGEDEL.10:b
   776    b.SET.0:foo
   777    d.RANGEDEL.0:e
   778    j.SET.10:foo
   779  L2
   780    f.RANGEDEL.7:g
   781  L3
   782    c.SET.6:6
   783  L3
   784    c.SET.5:5
   785  L3
   786    c.SET.4:4
   787  L4
   788    a.SET.0:0
   789    f.SET.0:0
   790  ----
   791  1:
   792    000004:[a#10,RANGEDEL-j#10,SET]
   793  2:
   794    000005:[f#7,RANGEDEL-g#inf,RANGEDEL]
   795  3:
   796    000006:[c#6,SET-c#6,SET]
   797    000007:[c#5,SET-c#5,SET]
   798    000008:[c#4,SET-c#4,SET]
   799  4:
   800    000009:[a#0,SET-f#0,SET]
   801  
   802  compact a-r L1
   803  ----
   804  2:
   805    000010:[a#10,RANGEDEL-b#0,SET]
   806    000011:[d#0,RANGEDEL-j#10,SET]
   807  3:
   808    000006:[c#6,SET-c#6,SET]
   809    000007:[c#5,SET-c#5,SET]
   810    000008:[c#4,SET-c#4,SET]
   811  4:
   812    000009:[a#0,SET-f#0,SET]
   813  
   814  # Test a snapshot that separates a range deletion from all the data that it
   815  # deletes. Ensure that we respect the target-file-size and split into multiple
   816  # outputs.
   817  
   818  define target-file-sizes=(1, 1, 1) snapshots=(14)
   819  L1
   820    a.RANGEDEL.15:z
   821    b.SET.11:foo
   822    c.SET.11:foo
   823  L2
   824    c.SET.0:foo
   825    d.SET.0:foo
   826  ----
   827  1:
   828    000004:[a#15,RANGEDEL-z#inf,RANGEDEL]
   829  2:
   830    000005:[c#0,SET-d#0,SET]
   831  
   832  sstable-properties file=000004
   833  snapshot-pinned-keys
   834  ----
   835  snapshot-pinned-keys:
   836    pebble.num.snapshot-pinned-keys: 2
   837    pebble.raw.snapshot-pinned-keys.size: 18
   838  
   839  compact a-z L1
   840  ----
   841  2:
   842    000006:[a#15,RANGEDEL-c#inf,RANGEDEL]
   843    000007:[c#15,RANGEDEL-d#inf,RANGEDEL]
   844    000008:[d#15,RANGEDEL-z#inf,RANGEDEL]
   845  
   846  sstable-properties file=000006
   847  snapshot-pinned-keys
   848  ----
   849  snapshot-pinned-keys:
   850    pebble.num.snapshot-pinned-keys: 1
   851    pebble.raw.snapshot-pinned-keys.size: 9
   852  
   853  sstable-properties file=000007
   854  snapshot-pinned-keys
   855  ----
   856  snapshot-pinned-keys:
   857    pebble.num.snapshot-pinned-keys: 1
   858    pebble.raw.snapshot-pinned-keys.size: 9
   859  
   860  sstable-properties file=000008
   861  snapshot-pinned-keys
   862  ----
   863  snapshot-pinned-keys:
   864    pebble.num.snapshot-pinned-keys: 1
   865    pebble.raw.snapshot-pinned-keys.size: 9
   866  
   867  # Test an interaction between a range deletion that will be elided with
   868  # output splitting. Ensure that the output is still split (previous versions
   869  # of the code did not, because of intricacies around preventing a zero
   870  # sequence number in an output's largest key).
   871  
   872  define target-file-sizes=(1, 1, 1)
   873  L1
   874    a.RANGEDEL.10:z
   875    b.SET.11:foo
   876    c.SET.11:foo
   877  L2
   878    c.SET.0:foo
   879    d.SET.0:foo
   880  ----
   881  1:
   882    000004:[a#10,RANGEDEL-z#inf,RANGEDEL]
   883  2:
   884    000005:[c#0,SET-d#0,SET]
   885  
   886  compact a-z L1
   887  ----
   888  2:
   889    000006:[b#0,SET-b#0,SET]
   890    000007:[c#0,SET-c#0,SET]
   891  
   892  define target-file-sizes=(1, 1, 1, 1)
   893  L0
   894    a.SET.3:v
   895    b.SET.2:v
   896  L2
   897    a.SET.1:v
   898  L3
   899    a.SET.0:v
   900    b.SET.0:v
   901  L3
   902    c.SET.0:v
   903  ----
   904  0.0:
   905    000004:[a#3,SET-b#2,SET]
   906  2:
   907    000005:[a#1,SET-a#1,SET]
   908  3:
   909    000006:[a#0,SET-b#0,SET]
   910    000007:[c#0,SET-c#0,SET]
   911  
   912  set-concurrent-compactions num=3
   913  ----
   914  
   915  compact a-c parallel hide-file-num
   916  ----
   917  4:
   918    [a#0,SET-a#0,SET]
   919    [b#0,SET-b#0,SET]
   920    [c#0,SET-c#0,SET]
   921  
   922  define target-file-sizes=(1, 1, 1, 1)
   923  L0
   924    a.SET.3:v
   925    b.SET.2:v
   926  L0
   927    a.SET.2:v
   928    c.SET.2:v
   929  L2
   930    a.SET.1:v
   931    b.SET.1:v
   932  L2
   933    c.SET.1:v
   934  L2
   935    d.SET.0:v
   936  L3
   937    a.SET.0:v
   938    b.SET.0:v
   939  L3
   940    c.SET.0:v
   941  ----
   942  0.1:
   943    000004:[a#3,SET-b#2,SET]
   944  0.0:
   945    000005:[a#2,SET-c#2,SET]
   946  2:
   947    000006:[a#1,SET-b#1,SET]
   948    000007:[c#1,SET-c#1,SET]
   949    000008:[d#0,SET-d#0,SET]
   950  3:
   951    000009:[a#0,SET-b#0,SET]
   952    000010:[c#0,SET-c#0,SET]
   953  
   954  set-concurrent-compactions num=2
   955  ----
   956  
   957  compact a-c L0 parallel
   958  ----
   959  1:
   960    000011:[a#3,SET-a#3,SET]
   961    000012:[b#2,SET-b#2,SET]
   962    000013:[c#2,SET-c#2,SET]
   963  2:
   964    000006:[a#1,SET-b#1,SET]
   965    000007:[c#1,SET-c#1,SET]
   966    000008:[d#0,SET-d#0,SET]
   967  3:
   968    000009:[a#0,SET-b#0,SET]
   969    000010:[c#0,SET-c#0,SET]
   970  
   971  add-ongoing-compaction startLevel=3 outputLevel=4 start=a end=d
   972  ----
   973  
   974  # We allow 2 maximum concurrent compactions. The operation below generates
   975  # 2 concurrent compactions (a-b, c) from L1 to L2. With 1 ongoing compaction with
   976  # output level L4, there is no conflict and thus the concurrent compactions should
   977  # be queued up and executed sequentially. We ensure that the compactions finish and
   978  # that the final result of the compactions is correct.
   979  
   980  async-compact a-d L1 parallel
   981  ----
   982  manual compaction did not block for ongoing
   983  2:
   984    000014:[a#3,SET-a#3,SET]
   985    000015:[b#2,SET-b#2,SET]
   986    000016:[c#2,SET-c#2,SET]
   987    000008:[d#0,SET-d#0,SET]
   988  3:
   989    000009:[a#0,SET-b#0,SET]
   990    000010:[c#0,SET-c#0,SET]
   991  
   992  remove-ongoing-compaction
   993  ----
   994  
   995  set-concurrent-compactions num=3
   996  ----
   997  
   998  compact a-d parallel hide-file-num
   999  ----
  1000  4:
  1001    [a#0,SET-a#0,SET]
  1002    [b#0,SET-b#0,SET]
  1003    [c#0,SET-c#0,SET]
  1004    [d#0,SET-d#0,SET]
  1005  
  1006  # Create a contrived compaction that forces point key and rangedel iterators
  1007  # to stay in sync to emit a correct view of visible and deleted keys. Note that
  1008  # Pebble no longer produces range tombstones that go outside a file's bounds,
  1009  # but past versions of pebble did, and we should still be able to handle those
  1010  # well.
  1011  
  1012  define target-file-sizes=(1, 1, 1, 1, 1, 1) snapshots=(390)
  1013  L3  start=tmgc.MERGE.391 end=tmgc.MERGE.391
  1014    tmgc.MERGE.391:foo
  1015  	tmgc.RANGEDEL.331:udkatvs
  1016  L3 start=tmgc.MERGE.384 end=tmgc.MERGE.384
  1017    tmgc.MERGE.384:bar
  1018    tmgc.RANGEDEL.383:tvsalezade
  1019    tmgc.RANGEDEL.331:tvsalezade
  1020  L3 start=tmgc.RANGEDEL.383 end=tvsalezade.RANGEDEL.72057594037927935
  1021    tmgc.RANGEDEL.383:tvsalezade
  1022    tmgc.SET.375:baz
  1023    tmgc.RANGEDEL.356:tvsalezade
  1024  ----
  1025  3:
  1026    000004:[tmgc#391,MERGE-tmgc#391,MERGE]
  1027    000005:[tmgc#384,MERGE-tmgc#384,MERGE]
  1028    000006:[tmgc#383,RANGEDEL-tvsalezade#inf,RANGEDEL]
  1029  
  1030  compact a-z L3
  1031  ----
  1032  4:
  1033    000007:[tmgc#391,MERGE-tmgc#384,MERGE]
  1034  
  1035  # baz should NOT be visible in the value.
  1036  
  1037  iter
  1038  first
  1039  next
  1040  next
  1041  ----
  1042  tmgc: (barfoo, .)
  1043  .
  1044  .
  1045  
  1046  # Test split user keys containing RANGEDELs.
  1047  # Note that this manual compaction is multilevel!
  1048  
  1049  define
  1050  L4
  1051    b.SET.10:b10
  1052  L5 start=b.SET.9 end=b.SET.8
  1053    b.SET.9:b9
  1054    b.SET.8:b8
  1055    b.RANGEDEL.1:z
  1056  L5 start=b.SET.7 end=b.SET.6
  1057    b.SET.7:b7
  1058    b.SET.6:b6
  1059    b.RANGEDEL.1:z
  1060  L5 start=b.SET.5 end=z.RANGEDEL.72057594037927935
  1061    b.SET.5:b5
  1062    b.SET.4:b4
  1063    b.RANGEDEL.1:z
  1064  L6
  1065    b.SET.0:b0
  1066    bat.SET.0:bat
  1067    cat.SET.0:cat
  1068  ----
  1069  4:
  1070    000004:[b#10,SET-b#10,SET]
  1071  5:
  1072    000005:[b#9,SET-b#8,SET]
  1073    000006:[b#7,SET-b#6,SET]
  1074    000007:[b#5,SET-z#inf,RANGEDEL]
  1075  6:
  1076    000008:[b#0,SET-cat#0,SET]
  1077  
  1078  compact a-z
  1079  ----
  1080  6:
  1081    000009:[b#0,SET-b#0,SET]
  1082  
  1083  iter
  1084  first
  1085  next
  1086  ----
  1087  b: (b10, .)
  1088  .
  1089  
  1090  # Ensure an untruncated range tombstone (eg, written by an earlier version of
  1091  # Pebble, Cockroach v21.2 or earlier) cannot delete newer keys outside the
  1092  # containing file's bounds.
  1093  #
  1094  # Regression test for cockroachdb/cockroach#89777.
  1095  
  1096  define target-file-sizes=(1)
  1097  L5 start=g.RANGEDEL.1 end=z.RANGEDEL.72057594037927935
  1098    a.RANGEDEL.1:z
  1099    m.SET.1:bar
  1100  L6
  1101    m.SET.0:bax
  1102  L6 start=a.SET.1 end=g.RANGEDEL.72057594037927935
  1103    a.SET.1:foo
  1104    a.RANGEDEL.1:z
  1105  ----
  1106  5:
  1107    000004:[g#1,RANGEDEL-z#inf,RANGEDEL]
  1108  6:
  1109    000006:[a#1,SET-g#inf,RANGEDEL]
  1110    000005:[m#0,SET-m#0,SET]
  1111  
  1112  # Compacting g-z should result in the elision of the range tombstone in the g-z
  1113  # span.
  1114  
  1115  compact g-z
  1116  ----
  1117  6:
  1118    000006:[a#1,SET-g#inf,RANGEDEL]
  1119    000007:[m#0,SET-m#0,SET]
  1120  
  1121  # Write a bunch of keys within the keyspace [g,z), and flush them.
  1122  
  1123  batch
  1124  set b b
  1125  set h h
  1126  set i i
  1127  set j j
  1128  set k k
  1129  set m m
  1130  set q q
  1131  set y y
  1132  ----
  1133  
  1134  flush
  1135  ----
  1136  0.0:
  1137    000009:[b#10,SET-b#10,SET]
  1138    000010:[h#11,SET-h#11,SET]
  1139    000011:[i#12,SET-i#12,SET]
  1140    000012:[j#13,SET-j#13,SET]
  1141    000013:[k#14,SET-k#14,SET]
  1142    000014:[m#15,SET-m#15,SET]
  1143    000015:[q#16,SET-q#16,SET]
  1144    000016:[y#17,SET-y#17,SET]
  1145  6:
  1146    000006:[a#1,SET-g#inf,RANGEDEL]
  1147    000007:[m#0,SET-m#0,SET]
  1148  
  1149  # Compact g-z to zero the sequence numbers of the newer keys.
  1150  
  1151  compact g-z
  1152  ----
  1153  0.0:
  1154    000009:[b#10,SET-b#10,SET]
  1155  6:
  1156    000006:[a#1,SET-g#inf,RANGEDEL]
  1157    000048:[h#0,SET-k#0,SET]
  1158    000049:[m#0,SET-y#0,SET]
  1159  
  1160  batch
  1161  set t t
  1162  ----
  1163  
  1164  flush
  1165  ----
  1166  0.0:
  1167    000009:[b#10,SET-b#10,SET]
  1168    000051:[t#18,SET-t#18,SET]
  1169  6:
  1170    000006:[a#1,SET-g#inf,RANGEDEL]
  1171    000048:[h#0,SET-k#0,SET]
  1172    000049:[m#0,SET-y#0,SET]
  1173  
  1174  # Compact everything. The batch-committed keys with zeroed sequence numbers (eg,
  1175  # h, i, j, k, m, q, y) should all still exist because the a-z tombstone in
  1176  # 000006 should be limited in how far it expands.
  1177  
  1178  compact a-z
  1179  ----
  1180  6:
  1181    000062:[a#0,SET-i#0,SET]
  1182    000063:[j#0,SET-q#0,SET]
  1183    000064:[t#0,SET-y#0,SET]
  1184  
  1185  iter
  1186  first
  1187  next
  1188  next
  1189  next
  1190  next
  1191  next
  1192  next
  1193  next
  1194  next
  1195  next
  1196  ----
  1197  a: (foo, .)
  1198  b: (b, .)
  1199  h: (h, .)
  1200  i: (i, .)
  1201  j: (j, .)
  1202  k: (k, .)
  1203  m: (m, .)
  1204  q: (q, .)
  1205  t: (t, .)
  1206  y: (y, .)
  1207  
  1208  # Ensure an untruncated range tombstone (eg, written by an earlier version of
  1209  # Pebble, Cockroach v21.2 or earlier) cannot expand beyond its previous
  1210  # truncated bounds.
  1211  #
  1212  # Regression test for cockroachdb/cockroach#89777.
  1213  
  1214  define snapshots=(2)
  1215  L5 start=g.RANGEDEL.3 end=n.RANGEDEL.72057594037927935
  1216    a.RANGEDEL.3:z
  1217    m.SET.1:bar
  1218  L5
  1219    s.SET.0:bax
  1220  L6
  1221    q.SET.0:foo
  1222  ----
  1223  5:
  1224    000004:[g#3,RANGEDEL-n#inf,RANGEDEL]
  1225    000005:[s#0,SET-s#0,SET]
  1226  6:
  1227    000006:[q#0,SET-q#0,SET]
  1228  
  1229  # Compacting all the files in a single expansion should not expand the
  1230  # untruncated range tombstone to the larger untruncated bounds. The rangedel
  1231  # should remain bounded as [a,n).
  1232  
  1233  compact a-z
  1234  ----
  1235  6:
  1236    000007:[g#3,RANGEDEL-s#0,SET]