Commit 216bc9d
authored
sync: a pass that changed nothing must not rewrite state (#65)
Measured on the live fleet on 2026-08-25. Over one minute on Silber, with
nothing changing: full_scans +7, inbound_noop_transactions +3,
inbound_guarded_transactions +0, present +0, tombstones +0. In that same
minute fabric rewrote a 45 MB state.json and a 25 MB manifest.json three
times each: 213 MB a minute, 307 GB a day, on one idle machine. Across four
machines it is about 2 TB a day. All of it rewriting what was already there.
`sync_once` called `persist_entry` unguarded, once per pass.
THIS FIX INVENTS NOTHING. The rule already existed on the other path.
`prepare_inbound_entry` guards the identical call with a four-part condition
and states the reason in its own comment: "an already durable no-op scan needs
no rewrite". A test beside it asserts `persist_calls == 0` with "an already
durable no-op generation must not rewrite state".
So skipping the write on a no-op is not a change of contract. It is the
contract, implemented on one of two paths.
AND THE GUARD VALUE WAS ALREADY BEING COMPUTED AND DISCARDED. `scan_entry`
returns `Result<bool>` saying whether the scan changed the node. This call site
threw it away on the line above the write it should have gated.
Each term of the guard earns its place:
- `scan_changed`, which the scan already returned.
- `observed != protected`, because materialization can move the disk receipt
when the scan found nothing, for instance restoring a file deleted under
catalog policy. Without this term such a restore would go unrecorded.
- `durable_generation != generation`, for a watcher event not yet made durable.
- `!state_path.exists()`, because a legacy entry has no state.json and its
first pass must write even having changed nothing. Taken from the sibling.
TESTS, AND I WATCHED THE FIRST ONE FAIL. Against the unguarded code, three
no-op passes performed three persists; the test reports "left: 3, right: 0".
The second test pins the property that makes this safe rather than the counter:
after a real change followed by several no-op passes, the manifest ON DISK must
still equal the one in memory. The dangerous version of this fix stops writing
AND still marks the generation durable, so a crash loses what the skip declined
to record. That test passes before the fix too, which is what makes it a
control rather than a mirror.
A RULE IMPLEMENTED IN ONE OF TWO PLACES IS WORTH LOOKING FOR ELSEWHERE IN THIS
ENGINE.
Agent: Silber.fabric1 parent 007f891 commit 216bc9d
1 file changed
Lines changed: 124 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
790 | | - | |
| 790 | + | |
791 | 791 | | |
792 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
793 | 813 | | |
794 | 814 | | |
795 | 815 | | |
| |||
3550 | 3570 | | |
3551 | 3571 | | |
3552 | 3572 | | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
3553 | 3675 | | |
3554 | 3676 | | |
3555 | 3677 | | |
| |||
0 commit comments