Commit b5c4af4
committed
fix(logstream): checkpoint the starting position once, whatever produced it
Fifth Codex round, one new P2 on dd9b123, and the sixth instance of one bug:
a starting cursor that never reaches disk, so the next launch calls itself a
first run and jumps to the tip.
This time --since-event-id with no state file skipped the immediate
checkpoint entirely, because that write lived inside the "resolve the tip"
branch and an explicit cursor never enters it. Nothing was persisted until
watch_events yielded, which by default is up to five minutes later; an
interrupt inside that window leaves no file at all.
Rather than add a third call site I hoisted it: one place resolves the
starting position, one place records it. The position can arrive three ways
— an explicit --since-event-id, the tip, or None from an empty log or
--from-start — and all three now take the same required write whenever no
state file exists yet. That removes the shape the last four rounds kept
finding new instances of, instead of removing one more instance.
Two test-quality notes, both the same lesson:
The first version of this test passed against the unfixed code. The helper
uses a 60ms poll timeout, so watch_events yielded immediately and the loop's
own checkpoint wrote the file — the startup window the bug lives in never
opened. It now stubs watch_events to interrupt before yielding, which is what
actually pins the startup write, and covers all three entry paths.
The hoist also broke test_match_does_not_checkpoint_if_output_fails, which
asserted that no state file existed after a failed match write. That was
pinning the symptom: a startup checkpoint now legitimately exists. The
invariant is that its cursor must still be the pre-match position so the
undelivered event replays, so it asserts the cursor value instead.
4407 passed, 31 skipped.1 parent dd9b123 commit b5c4af4
2 files changed
Lines changed: 81 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1612 | 1612 | | |
1613 | 1613 | | |
1614 | 1614 | | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
1625 | | - | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
1630 | 1635 | | |
1631 | 1636 | | |
1632 | 1637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
524 | | - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
525 | 532 | | |
526 | | - | |
| 533 | + | |
527 | 534 | | |
528 | 535 | | |
529 | 536 | | |
530 | 537 | | |
531 | 538 | | |
532 | 539 | | |
533 | | - | |
534 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
535 | 546 | | |
536 | 547 | | |
537 | 548 | | |
| |||
705 | 716 | | |
706 | 717 | | |
707 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
0 commit comments