Conversation
52b2201 to
e5f3c64
Compare
Configure new SQLite connections to use WAL by default and apply synchronous=NORMAL when WAL is the effective journal mode. Keep the explicit SQLITE_JOURNAL_MODE override available for WordPress plugin connections, including initial installation.
WAL can fail to engage in some environments, e.g., on network filesystems or when the WAL sidecar files cannot be created. In that case, setting the journal mode throws, which would newly fail connections that worked before WAL became the default. Keep the database's current journal mode when the WAL default fails, but let explicitly configured modes surface the error. Also include the SQLite connection setup in the installation error handling, so a connection failure dies gracefully during WordPress installation instead of causing a fatal error.
PRAGMA synchronous accepts integers from 0 to 3 as equivalents of the keyword values, and constants like SQLITE_SYNCHRONOUS are likely to be defined as integers. Map integer values to the corresponding keywords instead of silently ignoring them.
The WAL default applies to all WP_SQLite_Connection consumers, but only the WordPress plugin paths supported overriding it. Accept journal_mode and synchronous in the WP_PDO_MySQL_On_SQLite driver options so the PDO API consumers can configure them as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Journal mode:
journal_mode = WAL.Synchronous flag:
synchronous = NORMALwhen WAL is used.Other changes:
SQLITE_JOURNAL_MODEoverride through the WordPress plugin connection paths.journal_modeandsynchronousin theWP_PDO_MySQL_On_SQLitedriver options.Why
WALimproves read/write concurrency for SQLite-backed WordPress installs, andsynchronous = NORMALavoids frequent sync to the main database. In WAL mode,NORMALis safe. From the SQLite docs:Benchmark
A local benchmark ran a WordPress-like 90% read / 10% write workload against the same database file with 4, 8, and 16 concurrent workers, comparing the trunk defaults with WAL + NORMAL (median of 3 runs, PHP 8.5.5, SQLite 3.53.0).
This was run on an M4 MacBook Pro Max.