Skip to content

[PHP] Default Playground SQLite journal mode to DELETE - #3909

Merged
adamziel merged 1 commit into
trunkfrom
adamziel/disable-sqlite-wal
Jul 4, 2026
Merged

[PHP] Default Playground SQLite journal mode to DELETE#3909
adamziel merged 1 commit into
trunkfrom
adamziel/disable-sqlite-wal

Conversation

@adamziel

@adamziel adamziel commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

What it does

Defaults SQLITE_JOURNAL_MODE to DELETE before PHP instances run auto-prepended Playground code.

Explicit callers can still opt into WAL with:

constants: {
	SQLITE_JOURNAL_MODE: 'WAL',
}

Rationale

Blueprint-defined constants are too late for this setting: the SQLite integration may already be loaded by the time Blueprint steps run. Defining SQLITE_JOURNAL_MODE through bootRequestHandler() feeds the PHP auto-prepend path early enough.

Implementation

Adds a request-handler boot default that only runs when the caller has not already provided SQLITE_JOURNAL_MODE.

Testing instructions

Run:

npm exec nx lint playground-wordpress
npm exec nx test playground-wordpress --testFile=database.spec.ts

Note: the database test requires the refreshed SQLite integration bundle that includes WordPress/sqlite-database-integration#447. Against the current pre-refresh bundle, the new DELETE-mode assertion still reports wal.

@adamziel
adamziel force-pushed the adamziel/disable-sqlite-wal branch from c6b325c to 6b03217 Compare July 4, 2026 00:53
@adamziel
adamziel marked this pull request as ready for review July 4, 2026 01:14
@adamziel
adamziel requested review from a team, ashfame and Copilot July 4, 2026 01:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Defaults Playground’s SQLite journal mode to DELETE early in the request-handler boot path, and adds tests to verify the default and that explicit WAL is still honored.

Changes:

  • Set a default SQLITE_JOURNAL_MODE=DELETE in bootRequestHandler() unless the caller already provided it.
  • Update/add database tests to assert default DELETE and explicit WAL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/playground/wordpress/src/test/database.spec.ts Adds assertions for default DELETE mode and explicit WAL override.
packages/playground/wordpress/src/boot.ts Introduces early defaulting of SQLITE_JOURNAL_MODE during request-handler boot.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playground/wordpress/src/test/database.spec.ts
Comment thread packages/playground/wordpress/src/test/database.spec.ts
Comment thread packages/playground/wordpress/src/boot.ts
@adamziel
adamziel merged commit 45fee0e into trunk Jul 4, 2026
55 checks passed
@adamziel
adamziel deleted the adamziel/disable-sqlite-wal branch July 4, 2026 01:15
adamziel added a commit that referenced this pull request Jul 7, 2026
## What it does

Adds a CLI regression test for the SQLite failure mode reported in
#3914. The test boots `@wp-playground/cli` with six workers, creates 11
custom tables through `dbDelta()`, then repeatedly sends publish-like,
meta-box-loader-like, and post-list-like requests in parallel.

The test fails if the flow returns WordPress database failure pages or
if the final `PRAGMA integrity_check` does not return `ok`.

## Rationale

The reported failure only appears under realistic concurrent editor
load. A single CLI worker serializes requests too much, so this test
intentionally uses multiple workers to exercise concurrent SQLite
connections.

This covers the corruption class from #3883/#3914 and protects the
DELETE-journal-mode fix from #3909 plus the SQLite integration
propagation fix in WordPress/sqlite-database-integration#447.

## Implementation

The test writes a small set of PHP fixtures into the booted WordPress
site:

- setup: creates 11 custom tables with 11 `COMMENT`-bearing columns each
- publish: inserts a post and rows into every custom table
- meta-box-loader: reads counts and runs a wide joined custom-table
query
- post-list: runs a normal published-post `WP_Query`
- integrity: checks `PRAGMA integrity_check`

The stress test is skipped on Windows. The regression was reported on
Linux CI and reproduced with non-Windows CLI workers; running the same
multi-worker stress workload in the Windows CLI matrix hangs the
affected target until the workflow timeout rather than producing useful
signal.

I confirmed the negative control locally: the same workload fails
quickly when the CLI is booted with `SQLITE_JOURNAL_MODE=WAL`, producing
`database disk image is malformed` / `Error establishing a database
connection`. With the current DELETE default, it passes.

## Testing instructions

```bash
npm exec nx run playground-cli:typecheck
npm exec nx lint playground-cli
npm exec nx run playground-cli:test-playground-cli -- --testFile=sqlite-concurrent-publish.spec.ts
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment