Commit cb232a7
committed
db_stress: Rebuild expected state from DB when trace is truncated in blackbox crash tests
Summary:
In blackbox crash tests, db_stress can be killed at any point — including
while it is actively appending records to the trace file. This leaves the
recovered DB in a consistent state (thanks to WAL recovery), but the trace
file shorter than expected: fewer operations were recorded than the DB's
recovered sequence number implies.
Previously, when FinishInitDb detected this situation it called
FileExpectedStateManager::Restore() which ended up returning
Status::Corruption("Trace ended before replaying all expected write ops").
db_stress treated that as a hard failure and called exit(1), causing spurious
test failures that had nothing to do with actual data corruption.
This PR fixes the two-part problem:
1. expected_state.cc – FileExpectedStateManager::Restore():
When the trace replay finishes (either because Prepare() signals the trace
is already at EOF, or because Next() exhausts all records) but the handler
has not replayed all expected write operations, return Status::Incomplete()
instead of Status::Corruption(). Incomplete means "the trace ran out early,
which is expected in a blackbox crash"; Corruption is reserved for actual
data integrity problems.
2. db_stress_test_base.cc – StressTest::FinishInitDb() + new
RebuildExpectedStateFromDb():
When Restore() returns Incomplete, fall back to scanning the recovered DB
directly and rebuilding the expected state from its actual contents (the
same approach used when there is no history at all). If the rebuild scan
fails, or if Restore() returns any other non-OK status, still exit(1).
The new RebuildExpectedStateFromDb() method iterates every column family,
calls ClearColumnFamily() + SyncPut() for each key found, and validates wide
column consistency and key-range sanity along the way.
Test Plan:
Covered by existing blackbox crash test modes (blackbox, cf_consistency, etc.)
which can now survive a truncated trace without false failures.
Reviewers:
Subscribers:
Tasks:
Tags:1 parent 3efe946 commit cb232a7
3 files changed
Lines changed: 85 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | | - | |
477 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
478 | 487 | | |
479 | 488 | | |
480 | 489 | | |
| |||
499 | 508 | | |
500 | 509 | | |
501 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
502 | 565 | | |
503 | 566 | | |
504 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
149 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| 773 | + | |
773 | 774 | | |
774 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
775 | 780 | | |
776 | | - | |
| 781 | + | |
777 | 782 | | |
778 | 783 | | |
779 | 784 | | |
| |||
789 | 794 | | |
790 | 795 | | |
791 | 796 | | |
| 797 | + | |
792 | 798 | | |
793 | 799 | | |
794 | 800 | | |
795 | 801 | | |
796 | 802 | | |
797 | 803 | | |
798 | | - | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
799 | 809 | | |
800 | 810 | | |
801 | 811 | | |
| |||
0 commit comments