Commit 4d30835
committed
iterv2: fix invalid TrySeekUsingNext in mergingIterV2 batch-refresh path
`mergingIterV2.seekGEAfterBatchRefresh` handles the
`SeekGE(TrySeekUsingNext|BatchJustRefreshed)` case by pre-seeking the
batch level to decide whether the merging iterator must move back.
Previously, when the pre-seek showed that the iterator did not need to
move back, the code fell through to a full slab rebuild
(`m.seekGE(key, flags)`) with `TrySeekUsingNext` still enabled.
That is unsound when `seekKey < prevTopKey`: lower levels may have been
advanced past `seekKey` across one or more slab boundaries (see the
analogous case in `SeekGE` at the non-`BatchJustRefreshed` fast path),
so re-seeking them at `seekKey` with TSUN is illegal and can return
incorrect results.
This commit handles the `seekKey < prevTopKey` case directly: if the
batch level's span keys are unchanged (so the existing slab state —
per-level `minSeqNum`/`maxSeqNum`/`parked` — remains valid) the heap
is simply rebuilt in place and the iterator returns its current top.
Otherwise we fall through with TSUN disabled. The early exit at the
`SeekGE` call site is routed through `findNextEntry` so any
`SpanBoundary` or visibility-filtered KV at the new heap top is
handled correctly. A small additional fast path skips the pre-seek
entirely when the batch level is already at or past `seekKey`.
`TestSetOptionsBatchRefreshRand` is extended to exercise the affected
paths: RANGEDELs are added to the flushed sstables and to the batch
(the batch gets an inert RANGEDEL up front so `SetOptions` doesn't
tear down `pointIter`), RANGEDEL bounds may be either bare prefixes or
suffixed keys so boundary user keys can collide with point keys, and
the iteration count is raised.1 parent 29f2090 commit 4d30835
2 files changed
Lines changed: 93 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1302 | 1302 | | |
1303 | 1303 | | |
1304 | 1304 | | |
1305 | | - | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1306 | 1310 | | |
1307 | 1311 | | |
1308 | 1312 | | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1313 | 1319 | | |
1314 | 1320 | | |
1315 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
1316 | 1352 | | |
1317 | 1353 | | |
1318 | | - | |
| 1354 | + | |
| 1355 | + | |
1319 | 1356 | | |
1320 | 1357 | | |
1321 | 1358 | | |
1322 | 1359 | | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
1323 | 1363 | | |
1324 | 1364 | | |
1325 | 1365 | | |
1326 | 1366 | | |
1327 | 1367 | | |
| 1368 | + | |
1328 | 1369 | | |
1329 | 1370 | | |
1330 | 1371 | | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1331 | 1378 | | |
1332 | 1379 | | |
1333 | 1380 | | |
| |||
1376 | 1423 | | |
1377 | 1424 | | |
1378 | 1425 | | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
| 1426 | + | |
1390 | 1427 | | |
1391 | 1428 | | |
1392 | 1429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
441 | 444 | | |
442 | 445 | | |
443 | 446 | | |
| |||
509 | 512 | | |
510 | 513 | | |
511 | 514 | | |
512 | | - | |
| 515 | + | |
513 | 516 | | |
514 | | - | |
515 | 517 | | |
516 | 518 | | |
517 | 519 | | |
518 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
519 | 528 | | |
520 | 529 | | |
521 | 530 | | |
| |||
530 | 539 | | |
531 | 540 | | |
532 | 541 | | |
| 542 | + | |
533 | 543 | | |
534 | | - | |
| 544 | + | |
| 545 | + | |
535 | 546 | | |
536 | 547 | | |
537 | 548 | | |
538 | 549 | | |
539 | 550 | | |
540 | | - | |
| 551 | + | |
541 | 552 | | |
542 | | - | |
543 | 553 | | |
544 | 554 | | |
545 | 555 | | |
546 | 556 | | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
551 | 580 | | |
552 | 581 | | |
553 | 582 | | |
| |||
0 commit comments