mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(db): keep SQLite temp files in memory so trips can be deleted (#2518)
Deleting a trip failed with SQLITE_IOERR_GETTEMPPATH when the container runs with a read-only root filesystem and no tmpfs on /tmp. The cascade behind DELETE FROM trips keeps a statement journal, SQLite moves it to a temp file once it passes 64 KiB, and it looks for a directory for that file in SQLITE_TMPDIR, TMPDIR, /var/tmp, /usr/tmp, /tmp and the working directory. None of them is writable there. Installs on the shipped compose file have a tmpfs on /tmp and never hit it. Every connection the server opens now comes from openDatabase() in src/db/connection.ts, which sets temp_store = MEMORY: the main database (also when it is reopened after a restore), each plugin's own database and the uploaded backup checked before a restore. reset-admin.js and the key rotation script cannot import src/ in the image, so they set the pragma themselves. A test pins that nothing else in src/ constructs a handle, and one deletes a full trip on the real schema and watches for temp files.
This commit is contained in:
@@ -50,6 +50,10 @@ const db = new Database(dbPath);
|
||||
// journal mode below waits for a busy server instead of failing on the spot.
|
||||
// Five seconds, same as src/db/database.ts.
|
||||
db.exec('PRAGMA busy_timeout = 5000');
|
||||
// Temp files in memory, like every connection src/db/connection.ts opens: a
|
||||
// container with a read-only root and no tmpfs on /tmp has nowhere to put them
|
||||
// (#2518).
|
||||
db.exec('PRAGMA temp_store = MEMORY');
|
||||
db.exec(`PRAGMA journal_mode = ${journalMode}`);
|
||||
db.exec(`PRAGMA synchronous = ${synchronous}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user