When using the SQLitecache
, must I ensure the machine is a primary?
#1038
Answered
by
kentcdodds
warronbebster
asked this question in
Q&A
-
I've followed the caching docs and when I run it in production, I get Disk I/O SQLite errors: 2025-09-04T19:33:55Z app[784049ef491948] iad [info]level=INFO msg="fuse: write(): wal error: read only replica"
error setting cache: challenge:mallorca-championships-presented-by-ecotrans-group-2025-served-2025 Error: disk I/O error
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at Object.set (file:///myapp/app/utils/cache.server.ts:154:16)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at getFreshValue (file:///myapp/node_modules/@epic-web/cachified/src/getFreshValue.ts:65:19)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at cachified (file:///myapp/node_modules/@epic-web/cachified/src/cachified.ts:94:17)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at getChallenge (file:///myapp/app/utils/challenge.server.ts:32:18)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at getTournamentContextMain (file:///myapp/app/utils/tournament-context.server.ts:60:18)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at loader$9 (file:///myapp/app/routes/tournaments+/$slug+/$tour+/index.tsx:38:9)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at callRouteHandler (file:///myapp/node_modules/react-router/dist/development/chunk-5UALIXAM.mjs:509:16)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at commonRoute.loader (file:///myapp/node_modules/react-router/dist/development/chunk-5UALIXAM.mjs:658:19)
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at file:///myapp/node_modules/react-router/dist/development/chunk-PVWAREVJ.mjs:4259:19
2025-09-04T19:33:55Z app[784049ef491948] iad [info] at callLoaderOrAction (file:///myapp/node_modules/react-router/dist/development/chunk-PVWAREVJ.mjs:4311:16) {
2025-09-04T19:33:55Z app[784049ef491948] iad [info] code: 'ERR_SQLITE_ERROR',
2025-09-04T19:33:55Z app[784049ef491948] iad [info] errcode: 778,
2025-09-04T19:33:55Z app[784049ef491948] iad [info] errstr: 'disk I/O error'
2025-09-04T19:33:55Z app[784049ef491948] iad [info]} To use the SQLite cache, do we have to first use |
Beta Was this translation helpful? Give feedback.
Answered by
kentcdodds
Sep 4, 2025
Replies: 1 comment 3 replies
-
How are you using it? Are you trying to write to it directly? It's intended to be used with cachified (in the cache.server.ts file). That handles updating the cache for you in an efficient way. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whoops! I made a mistake by removing the utility that made the cache multi-region safe. I've just pushed this commit to fix it: a1b3aa4
My apologies! Thank you for bringing it up.
As a note, you wouldn't want to use
ensurePrimary
for this because so many requests result in a cache update that you'd pretty much never benefit from having multiple regions. So instead we trigger a request to the primary when the cache needs to be updated.