Skip to content

Commit 5920074

Browse files
authored
fix(pds): prevent relay desync after failed write (#162)
`applyWrites` was assigning the new `Repo` to in-memory state before sequencing the firehose event. If anything threw between then and `sequenceCommit` succeeding (e.g. mid-flight failure on an image post), Cloudflare rolled back the SQLite writes but the in-memory `Repo` stayed advanced. The next successful write then emitted a firehose commit whose `since` rev the relay had never seen, and the relay marked the repo desynced — requiring a manual `requestCrawl` to recover. `this.repo` is now only assigned after the sequence + broadcast succeed in all four write paths (`rpcCreateRecord`, `rpcDeleteRecord`, `rpcPutRecord`, `rpcApplyWrites`), and any failure in that window invalidates the in-memory cache so the next access reloads from storage.
1 parent a492bf7 commit 5920074

2 files changed

Lines changed: 228 additions & 196 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@getcirrus/pds": patch
3+
---
4+
5+
Fix relay desync after a failed write (e.g. an image post that errors mid-flight).
6+
7+
`applyWrites` was assigning the new `Repo` to in-memory state before sequencing the firehose event. If anything threw between then and `sequenceCommit` succeeding, Cloudflare rolled back the SQLite writes but the in-memory `Repo` stayed advanced. The next successful write then emitted a firehose commit whose `since` rev the relay had never seen, and the relay marked the repo desynced — requiring a manual `requestCrawl` to recover.
8+
9+
`this.repo` is now only assigned after the sequence + broadcast succeed, and any failure in that window invalidates the in-memory cache so the next access reloads from storage.

0 commit comments

Comments
 (0)