Recently I’ve been trying to scale my app to two regions, but am having trouble with writing data to the volume of the new region.
I added a volume with matching name to the lax region
Ran fly scale count 2
Saw in flyctl logs that my app is unable to create/read a Sqlite database on the volume upon launching.
The weird bit is it works absolutely fine in the original region I deployed to (ams), and has done so for the last four months. My app uses the heroku/buildpacks:20 builder, could anything have changed under my feet?
Unfortunately better-sqlite3 doesn’t give me much more information than SqliteError: unable to open database file.
Would you mind sharing the script that does the DB file init?
Only possible solution that I can think of right now is that the second volume isn’t automatically replicated, so you might have to create the DB file again there (if you haven’t done so already).
This is probably a permissions error. If you ssh to your instance and run ls -la /data you can see who owns it. If that path, or any file within that path, is owned by root, that’s a problem. You can likely fix it by running chown -R heroku:heroku /data.
We try and set ownership when we first mount a volume but this is a relatively complex problem and we haven’t figured out the perfect UX yet.