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

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

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/876
Author: @ItalyPaleAle
Created: 8/24/2025
Status: Merged
Merged: 8/24/2025
Merged by: @stonith404

Base: mainHead: fix-866-2


📝 Commits (5)

  • 6b11a53 fix: ensure SQLite has a writable temporary directory
  • 4fa72c6 fix: actually read random bytes
  • c492b62 Tweak
  • 11d2012 Merge branch 'main' into fix-866-2
  • 0402af4 Merge branch 'main' into fix-866-2

📊 Changes

2 files changed (+109 additions, -5 deletions)

View changed files

📝 backend/internal/bootstrap/db_bootstrap.go (+68 -5)
📝 backend/internal/utils/file_util.go (+41 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/876 **Author:** [@ItalyPaleAle](https://github.com/ItalyPaleAle) **Created:** 8/24/2025 **Status:** ✅ Merged **Merged:** 8/24/2025 **Merged by:** [@stonith404](https://github.com/stonith404) **Base:** `main` ← **Head:** `fix-866-2` --- ### 📝 Commits (5) - [`6b11a53`](https://github.com/pocket-id/pocket-id/commit/6b11a53aa4dd7afd61fecedb6f2573ecfc623dfd) fix: ensure SQLite has a writable temporary directory - [`4fa72c6`](https://github.com/pocket-id/pocket-id/commit/4fa72c66d0f016cd0ce3f25b65391b9d028481ea) fix: actually read random bytes - [`c492b62`](https://github.com/pocket-id/pocket-id/commit/c492b62b91da783b13df5681a69b7d5d391131da) Tweak - [`11d2012`](https://github.com/pocket-id/pocket-id/commit/11d20127abea771d64676c20a699dfc092bbb3ea) Merge branch 'main' into fix-866-2 - [`0402af4`](https://github.com/pocket-id/pocket-id/commit/0402af414a4093dccf6939e51c7b46b1a9a80d0e) Merge branch 'main' into fix-866-2 ### 📊 Changes **2 files changed** (+109 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `backend/internal/bootstrap/db_bootstrap.go` (+68 -5) 📝 `backend/internal/utils/file_util.go` (+41 -0) </details> ### 📄 Description 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` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-08 00:13:16 +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#578