[PR #876] fix: ensure SQLite has a writable temporary directory #582

Closed
opened 2025-10-08 00:13:20 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/pocket-id/pocket-id/pull/876

State: closed
Merged: Yes


The issue is that when performing some large queries (that use a lot of temporary directories, for example), SQLite sometimes needs to write to a temporary file. The file is usually placed in folders like /var/tmp, /usr/tmp, or /tmp. This is explained in the docs: https://www.sqlite.org/tempfiles.html#temporary_file_storage_locations

However, in a container running with a read-only root file system, those folders do not exist or are not writable.

This PR should fix #866, although I haven't had a chance to reproduce the exact behavior.

How this was tested:

  • Confirm that if there's no writable folder among /var/tmp, /usr/tmp and /tmp, the app sets SQLITE_TMPDIR in the environment
  • Confirm that, in a container with a read-only root FS, queries that would cause the use of temporary files (I tested with running a "CREATE TEMP TABLE" query and inserting a large amount of data) did not work without this fix (disk I/O error (6410)), and work after

To run a container with a read-only FS, I used Podman with the flags --read-only --read-only-tmpfs=false

**Original Pull Request:** https://github.com/pocket-id/pocket-id/pull/876 **State:** closed **Merged:** Yes --- The issue is that when performing some large queries (that use a lot of temporary directories, for example), SQLite sometimes needs to write to a temporary file. The file is usually placed in folders like /var/tmp, /usr/tmp, or /tmp. This is explained in the docs: https://www.sqlite.org/tempfiles.html#temporary_file_storage_locations However, in a container running with a read-only root file system, those folders do not exist or are not writable. This PR should fix #866, although I haven't had a chance to reproduce the exact behavior. How this was tested: - Confirm that if there's no writable folder among /var/tmp, /usr/tmp and /tmp, the app sets SQLITE_TMPDIR in the environment - Confirm that, in a container with a read-only root FS, queries that would cause the use of temporary files (I tested with running a "CREATE TEMP TABLE" query and inserting a large amount of data) did not work without this fix (`disk I/O error (6410)`), and work after > To run a container with a read-only FS, I used Podman with the flags `--read-only --read-only-tmpfs=false`
OVERLORD added the pull-request label 2025-10-08 00:13:20 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#582