Skip to content

fix(ios): configure SQLite thread safety - #325

Merged
chrispader merged 2 commits into
mainfrom
codex/configurable-sqlite-threading
Sep 10, 2026
Merged

fix(ios): configure SQLite thread safety#325
chrispader merged 2 commits into
mainfrom
codex/configurable-sqlite-threading

Conversation

@chrispader

@chrispader chrispader commented Sep 10, 2026

Copy link
Copy Markdown
Member

iOS builds currently compile bundled SQLite with SQLITE_THREADSAFE=0, which removes its mutex code even though Nitro runs asynchronous operations on multiple native threads. This makes concurrent SQLite access unsafe, as reported in #312. This PR restores serialized mode by default and lets applications configure it in their package.json.

The nitroSQLite.threadSafe setting accepts true or false and defaults to true. NITRO_SQLITE_THREADSAFE can override it for a Pod installation using true, false, 1, or 0, which is useful in CI. The podspec retains the existing SQLite performance flags, while the documentation explains that this setting has no compile-time effect when NITRO_SQLITE_USE_PHONE_VERSION=1 selects Apple's system SQLite library.

Samuel Scheit introduced the configurable pod setting in PR #298. This PR extracts that work, defaults to 1, and credits him as co-author. It does not include the macOS or CI-platform changes from that PR.

The podspec regression evaluates the package setting, environment override, defaults, invalid values, and system-library configuration. It also compiles bundled SQLite in both supported modes and checks sqlite3_threadsafe().

This fixes the compile-time default. Native connection lifetime and transaction scheduling need separate fixes; SQLite's mutexes do not provide those guarantees.

@chrispader
chrispader added this pull request to stack #327 September 10, 2026 13:41
@chrispader
chrispader force-pushed the codex/configurable-sqlite-threading branch from 9f6cbcf to 796eff4 Compare September 10, 2026 14:01
@chrispader
chrispader removed this pull request from stack #327 September 10, 2026 14:09
@chrispader
chrispader added this pull request to stack #329 September 10, 2026 14:10
chrispader and others added 2 commits September 10, 2026 17:04
Default bundled SQLite builds to serialized mode while allowing explicit 0 or 1 selection through NITRO_SQLITE_THREADSAFE. Preserve the existing performance flags and document the system SQLite exception.

Co-authored-by: samuelscheit <github@samuelscheit.com>
@chrispader
chrispader force-pushed the codex/configurable-sqlite-threading branch from 796eff4 to 6a75512 Compare September 10, 2026 16:04
@chrispader
chrispader merged commit 5eb4211 into main Sep 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant