Deployed front-end doesn't reload to include latest data #10
Comments
From @tsibley:
|
Reproducing locally might also be easier by running Datasette single-threaded so that test requests are sure to hit the same process/thread. In this code: We're not updating the SQLite file in place, but replacing it with a different file. That was intentional to avoid a bad update leaving an existing but broken database file, but it may not place nice with Datasette. Casual testing during dev seemed to show that Datasette/SQLite copes just fine, but more rigorous testing may show otherwise. |
Fortuitously, this just happened again in production. I grabbed an The current SQLite file is inode 2560088, and as suspected, the Datasette threads are still holding open file descriptors for the deleted files. I think in-place updates will work if we stop re-creating/overwriting the database file everytime but instead only update it in-place via SQL commands. But we should robustly test this locally, and to do so consistently will need to make sure Datasette is running single-threaded. (Not sure if that's possible, though?) |
Can we just update in-place via
|
Working on this now, but wanted to say that reverting commit de07e5c4 produces the same error (of datasette pointing to a deleted sqlite file).
|
Never mind, further testing seems to show it does fine.
|
Ah, my original testing process was flawed. It appears both @joverlee521's solution,
, and updating in place (my code in the previous comment) avoid Datasette threads' holding open file descriptors of deleted files. |
Description of my local testing:
|
Testing with Datasette using multiple threads is likely to give misleading results, as your different requests may hit different threads which only open the SQLite file as necessary. This is why different threads in the Using One option might be to leave the SQLite file itself alone and instead do the replacement atomically within SQL. That is, within a single transaction, |
The
then overwrite the file in-place with
|
Hey Tom, where do you see this error? I invoked ./bin/serve with the |
It's in the terminal output when I run
|
…file This moves the update from the filesystem layer into the SQL layer, thus allowing multiple processes to coordinate. Datasette holds open SQLite connections and was keeping references to the deleted files. Since the Makefile recipe got more complicated, move it to a shell script. Resolves #10.
…file This moves the update from the filesystem layer into the SQL layer, thus allowing multiple processes to coordinate. Datasette holds open SQLite connections and was keeping references to the deleted files. The new --truncate option to `sqlite-utils insert` is added in a PR I submitted <simonw/sqlite-utils#118>. For now, sqlite-utils is installed from our fork. When/if --truncate is released officially, we can switch back to installing from PyPI. Resolves #10.
It's unclear at this point whether this is a deployment configuration issue (and thus should be filed at seattleflu/backoffice) or something that can be fixed in this repo.
In the past couple of days, the deployed app at backoffice.seattleflu.org/switchboard has failed to update the front-end with the latest data in the sqlite database.
See this Slack thread for the steps I took to debug, as I'm unsure how much barcode/REDCap link sharing I should be doing in a public setting.
The text was updated successfully, but these errors were encountered: