Skip to content

fix(syncer): report a failed blob check and subscribe to local changes again - #221

Merged
bketelsen merged 1 commit into
mainfrom
fix/211-sync-dropped-errors
Nov 12, 2026
Merged

bketelsen merged 1 commit into
mainfrom
fix/211-sync-dropped-errors

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #211. Two errors in a device's sync loop were dropped with no log line and no retry.

  • upload (internal/syncer/loop.go) skipped a change whose blob check (blobs.Store.Has) failed, as if the device did not hold its content. The hash never reached log.missing, its content never went up, and the push came back refused missing on every retry. Now a failed check ends the session with the error (check blob <hash>: …). loop.run logs the end of the session ("sync session ended") and retries after its backoff. A blob that is simply absent is skipped as before.
  • watchLocal returned for good when events.Broker.Subscribe failed, so no local change marked a path dirty until notesd restarted: local edits went up only at the next idle pull. Now it logs the error ("subscribe to local changes"), waits a backoff (Config.Backoff, doubling to Config.MaxBackoff, reset after a subscription stands) and subscribes again while its context is live. Once a subscription stands again after a failure, it kicks the loop once, because events may have been missed.

The sync protocol and the stored data are unchanged: no RPC, schema or migration changes. docs/design/sync.md (Device loop, steps 1 and 2) now says what the loop does in both cases.

Risk tier

No path in .github/risk-paths.json matches (internal/syncer/loop.go, a new test file, docs/design/sync.md).

Risk tier: 2 — a behaviour change in the sync loop's error handling.

Verification

  • make check green (host)
  • make sync-sim green, for a change to sync, as a shorter seeded run: SIM_SEEDS=3 SIM_STEPS=2000 make sync-sim (stepwise and concurrent; TestISimulation and TestRegressions pass). The default 10 seeds of 10,000 steps were not run.
  • go test -race ./internal/syncer/ -count=1 green
  • Revert test for a fix: in a scratch worktree at the PR head, git checkout HEAD~1 -- internal/syncer/loop.go, then go test ./internal/syncer/ -count=1 -run 'TestUpload|TestWatchLocal':
    • TestUploadReportsABlobCheckError: upload returned nil for a blob whose check failed; the hash was dropped
    • TestWatchLocalResubscribes: watchLocal returned after a failed Subscribe

New tests (internal/syncer/droppederrors_internal_test.go):

  • TestUploadReportsABlobCheckError: the blob's shard directory is replaced by a file, so Has fails with ENOTDIR; upload must return an error that wraps it.
  • TestUploadSkipsAnAbsentBlob: an absent blob is still skipped without an error.
  • TestWatchLocalResubscribes: an events.Log whose first LatestSeq fails; watchLocal must log the failure, subscribe again, and mark a later note.changed path dirty.

…s again

upload skipped a change whose blob check failed as if the device did not
hold its content: the hash never reached log.missing and the push came
back refused missing on every retry, with no log line. It now ends the
session with the error, which the loop logs and retries after its
backoff.

watchLocal returned for good when Broker.Subscribe failed, so no local
change marked a path dirty until notesd restarted. It now logs the error,
subscribes again after a backoff, and looks at everything once the new
subscription stands.

Fixes #211
@github-actions github-actions Bot added the level:L3 Skim label Nov 12, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review: Ready, blocking: none. Reviewer openai/gpt-6.1-sol, coder deepseek/deepseek-flash, base 5fbd9194b6993ed2d7f736119452883742ae4e67, head f6cf4ff86fa537625128448ac925207e4a4dcf03, all 3 changed files. 2 low, non-blocking findings in TestWatchLocalResubscribes: its first wait has no failure timer, and its event can provide the wake that the recovered subscription's kick gives, so the kick itself is not asserted. Both are left as is: the fix's behaviour (no return after a failed Subscribe, a resubscription, a marked path) is asserted, and the test fails without the fix. The reviewer also notes that a persistent blob-check error now ends each session before its pull; that follows from ending the session on the error, which logs it and retries.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 12, 2026
@bketelsen
bketelsen merged commit 39936d0 into main Nov 12, 2026
12 checks passed
@bketelsen
bketelsen deleted the fix/211-sync-dropped-errors branch November 12, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L3 Skim ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync: a failed blob check or event subscription is dropped without a log line

2 participants