github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/testdata/singledel_manual_compaction_set_with_del (about) 1 # This is not actually a manual compaction test, and simply uses manual 2 # compaction to demonstrate single delete semantics when used with 3 # set-with-delete. 4 5 # Define a sequence of SET=>SET=>DEL=>SET=>SINGLEDEL. 6 define target-file-sizes=(1, 1, 1, 1, 1) 7 L1 8 a.SINGLEDEL.10: 9 L2 10 a.SET.9:v3 11 L3 12 a.DEL.8: 13 L4 14 a.SET.7:v2 15 L5 16 a.SET.6:v1 17 ---- 18 1: 19 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 20 2: 21 000005:[a#9,SET-a#9,SET] 22 3: 23 000006:[a#8,DEL-a#8,DEL] 24 4: 25 000007:[a#7,SET-a#7,SET] 26 5: 27 000008:[a#6,SET-a#6,SET] 28 29 # No data. 30 iter 31 first 32 ---- 33 . 34 35 # Compact away the DEL. 36 compact a-b L2 37 ---- 38 1: 39 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 40 3: 41 000009:[a#9,SETWITHDEL-a#9,SETWITHDEL] 42 4: 43 000007:[a#7,SET-a#7,SET] 44 5: 45 000008:[a#6,SET-a#6,SET] 46 47 # No data. 48 iter 49 first 50 ---- 51 . 52 53 # Do two compactions to compact away the SINGLEDEL and 1 SET. 54 compact a-b L1 55 ---- 56 2: 57 000010:[a#10,SINGLEDEL-a#10,SINGLEDEL] 58 3: 59 000009:[a#9,SETWITHDEL-a#9,SETWITHDEL] 60 4: 61 000007:[a#7,SET-a#7,SET] 62 5: 63 000008:[a#6,SET-a#6,SET] 64 65 compact a-b L2 66 ---- 67 3: 68 000011:[a#10,DEL-a#10,DEL] 69 4: 70 000007:[a#7,SET-a#7,SET] 71 5: 72 000008:[a#6,SET-a#6,SET] 73 74 # Deleted data is not resurrected. 75 iter 76 first 77 ---- 78 . 79 80 # Define a sequence of SET=>SINGLEDEL=>SET=>SINGLEDEL. 81 define target-file-sizes=(1, 1, 1, 1, 1) 82 L1 83 a.SINGLEDEL.10: 84 L2 85 a.SET.9:v3 86 L3 87 a.SINGLEDEL.8: 88 L4 89 a.SET.7:v2 90 ---- 91 1: 92 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 93 2: 94 000005:[a#9,SET-a#9,SET] 95 3: 96 000006:[a#8,SINGLEDEL-a#8,SINGLEDEL] 97 4: 98 000007:[a#7,SET-a#7,SET] 99 100 # No data. 101 iter 102 first 103 ---- 104 . 105 106 # Compact away the older SINGLEDEL. 107 compact a-b L2 108 ---- 109 1: 110 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 111 3: 112 000008:[a#9,SETWITHDEL-a#9,SETWITHDEL] 113 4: 114 000007:[a#7,SET-a#7,SET] 115 116 # No data. 117 iter 118 first 119 ---- 120 . 121 122 # Do two compactions to compact away the newer SINGLEDEL and 1 SET. 123 compact a-b L1 124 ---- 125 2: 126 000009:[a#10,SINGLEDEL-a#10,SINGLEDEL] 127 3: 128 000008:[a#9,SETWITHDEL-a#9,SETWITHDEL] 129 4: 130 000007:[a#7,SET-a#7,SET] 131 132 compact a-b L2 133 ---- 134 3: 135 000010:[a#10,DEL-a#10,DEL] 136 4: 137 000007:[a#7,SET-a#7,SET] 138 139 # Deleted data is not resurrected. 140 iter 141 first 142 ---- 143 . 144 145 # Define a sequence of SET=>DEL=>SET=>SINGLEDEL, such that the DEL and 146 # SINGLEDEL meet in a compaction. Disable multilevel compaction to exercise the proper test case. 147 define snapshots=(9) disable-multi-level 148 L1 149 a.SINGLEDEL.10: 150 L2 151 a.SET.9:v3 152 L3 153 a.DEL.8: 154 L4 155 a.SET.7:v2 156 ---- 157 1: 158 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 159 2: 160 000005:[a#9,SET-a#9,SET] 161 3: 162 000006:[a#8,DEL-a#8,DEL] 163 4: 164 000007:[a#7,SET-a#7,SET] 165 166 # No data. 167 iter 168 first 169 ---- 170 . 171 172 # Compact L2 and L3. The snapshot prevents the DEL=>SET from being collapsed. 173 compact a-b L2 174 ---- 175 1: 176 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 177 3: 178 000008:[a#9,SET-a#8,DEL] 179 4: 180 000007:[a#7,SET-a#7,SET] 181 182 # No data. 183 iter 184 first 185 ---- 186 . 187 188 close-snapshots 189 ---- 190 191 compact a-b L1 192 ---- 193 2: 194 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 195 3: 196 000008:[a#9,SET-a#8,DEL] 197 4: 198 000007:[a#7,SET-a#7,SET] 199 200 # The DEL survives. 201 compact a-b L2 202 ---- 203 3: 204 000009:[a#8,DEL-a#8,DEL] 205 4: 206 000007:[a#7,SET-a#7,SET] 207 208 # No data 209 iter 210 first 211 ---- 212 . 213 214 # Define a sequence of SET=>SINGLEDEL=>SET=>SINGLEDEL, such that the two 215 # SINGLEDELs meet in a compaction. 216 # To test surface the right test case, disable multi level compaction. 217 define snapshots=(9) disable-multi-level 218 L1 219 a.SINGLEDEL.10: 220 L2 221 a.SET.9:v3 222 L3 223 a.SINGLEDEL.8: 224 L4 225 a.SET.7:v2 226 ---- 227 1: 228 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 229 2: 230 000005:[a#9,SET-a#9,SET] 231 3: 232 000006:[a#8,SINGLEDEL-a#8,SINGLEDEL] 233 4: 234 000007:[a#7,SET-a#7,SET] 235 236 # No data. 237 iter 238 first 239 ---- 240 . 241 242 # Compact L2 and L3. The snapshot prevents the SINGLEDEL=>SET from being collapsed. 243 compact a-b L2 244 ---- 245 1: 246 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 247 3: 248 000008:[a#9,SET-a#8,SINGLEDEL] 249 4: 250 000007:[a#7,SET-a#7,SET] 251 252 # No data. 253 iter 254 first 255 ---- 256 . 257 258 close-snapshots 259 ---- 260 261 compact a-b L1 262 ---- 263 2: 264 000004:[a#10,SINGLEDEL-a#10,SINGLEDEL] 265 3: 266 000008:[a#9,SET-a#8,SINGLEDEL] 267 4: 268 000007:[a#7,SET-a#7,SET] 269 270 # The SINGLEDEL survives. 271 compact a-b L2 272 ---- 273 3: 274 000009:[a#8,SINGLEDEL-a#8,SINGLEDEL] 275 4: 276 000007:[a#7,SET-a#7,SET] 277 278 # No data 279 iter 280 first 281 ---- 282 .