Repository navigation
fix(syncer): report a failed blob check and subscribe to local changes again - #221
Conversation
…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
|
Cross-review: Ready, blocking: none. Reviewer |
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 reachedlog.missing, its content never went up, and the push came back refusedmissingon every retry. Now a failed check ends the session with the error (check blob <hash>: …).loop.runlogs the end of the session ("sync session ended") and retries after its backoff. A blob that is simply absent is skipped as before.watchLocalreturned for good whenevents.Broker.Subscribefailed, 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 toConfig.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.jsonmatches (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 checkgreen (host)make sync-simgreen, for a change to sync, as a shorter seeded run:SIM_SEEDS=3 SIM_STEPS=2000 make sync-sim(stepwise and concurrent;TestISimulationandTestRegressionspass). The default 10 seeds of 10,000 steps were not run.go test -race ./internal/syncer/ -count=1greengit checkout HEAD~1 -- internal/syncer/loop.go, thengo test ./internal/syncer/ -count=1 -run 'TestUpload|TestWatchLocal':TestUploadReportsABlobCheckError:upload returned nil for a blob whose check failed; the hash was droppedTestWatchLocalResubscribes:watchLocal returned after a failed SubscribeNew tests (
internal/syncer/droppederrors_internal_test.go):TestUploadReportsABlobCheckError: the blob's shard directory is replaced by a file, soHasfails withENOTDIR;uploadmust return an error that wraps it.TestUploadSkipsAnAbsentBlob: an absent blob is still skipped without an error.TestWatchLocalResubscribes: anevents.Logwhose firstLatestSeqfails;watchLocalmust log the failure, subscribe again, and mark a laternote.changedpath dirty.