Commit 32c48bb
The homepage's cache has no writer, so give it one
Following on from 054efbe, which was correct and not sufficient. Widening
INDEX_MAX_STALE_MS stopped readers blocking on an entry that existed; it did
nothing about there being no way to create one.
`remember` fills itself from readers: past the TTL a reader starts a background
`refresh()`. That only works when the computation fits in the timeout the page
is willing to wait, and this one never does -- `countFeedsByKind` is a `group by`
over 476,000 rows with no covering index, so every refresh is abandoned at 20s
and the entry is never renewed. It could only ever age out.
Which is what happened in production within minutes of 054efbe deploying. Redis
no longer had the key, so the homepage fell to the branch below the widened
ceiling: waited its 20 seconds for a computation that was always going to fail,
then rendered the empty-directory branch. A directory of 476,000 feeds reporting
that it has none -- worse than the slow page it replaced, and my fault for
changing when the entry is served without checking what writes it.
So the writer moves to the poller, where `warmStatsCache` already does exactly
this for `categoryStats` on a connection with a 150-second deadline. Same shape:
its own patient connection, never throws, logs `directory-warmed` /
`directory-warm-skipped`. It runs after the category warm rather than beside it
so the two whole-table scans queue instead of competing, and it is not gated on
the category warm succeeding -- the keys fail independently.
The web side is untouched. `remember` finds a warm entry and serves it, and its
own doomed refreshes become harmless rather than load-bearing.
Verified: suite green (11 packages, fail 0), `pnpm build` compiles, and
`warmDirectoryCache` resolves through the package entry point. The key name and
the `{rows, total, byKind}` shape are a contract with
apps/web/src/lib/directory.js that no test covers -- a drift there is a silently
empty homepage -- so it is checked against the live poller log and the page
after deploy rather than only in CI.
Still does not restore the crawler: the write path stays wedged until the Turso
quota is raised or resets on 1 Sep.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 054efbe commit 32c48bb
3 files changed
Lines changed: 88 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
872 | 873 | | |
873 | 874 | | |
874 | 875 | | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
875 | 891 | | |
876 | 892 | | |
877 | 893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
0 commit comments