[PHP] Restart interrupted db-apply from the beginning - #595
Closed
adamziel wants to merge 1 commit into
Closed
Conversation
Contributor
Pull pipeline performance —
|
| Stage | PR | trunk | Δ | Status | Details |
|---|---|---|---|---|---|
playground-sqlite-db-pull |
9.68 s | 9.61 s | ⚪ +78 ms (+0.8%) | ✓ | condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected trunk: condition=db-pull in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=lexer native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=selected |
playground-sqlite-db-apply |
3.72 s | 3.73 s | ⚪ -18 ms (-0.5%) | ✓ | condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified trunk: condition=db-apply to SQLite in PHP.wasm runtime=php.wasm 8.3 wp_mysql_parser=enabled mode=parser native_lexer=verified native_token_stream=WP_MySQL_Native_Token_Stream native_token_count=18 native_parser=verified native_ast=WP_MySQL_Native_Parser_Node sqlite_driver_parser=verified |
| Total | 13.40 s | 13.34 s | ⚪ +59 ms (+0.4%) |
Numbers carry runner noise; treat single-run deltas as directional, not authoritative.
📈 Trunk performance history — commit-by-commit timeline.
adamziel
force-pushed
the
codex/db-apply-confirmed-replay
branch
2 times, most recently
from
August 14, 2026 02:10
b80107d to
0973ff7
Compare
This was referenced Aug 14, 2026
adamziel
force-pushed
the
codex/file-db-pull-durable-resume
branch
3 times, most recently
from
August 14, 2026 12:45
c9e724a to
710ae4e
Compare
adamziel
force-pushed
the
codex/db-apply-confirmed-replay
branch
from
August 14, 2026 12:48
0973ff7 to
e562106
Compare
adamziel
force-pushed
the
codex/file-db-pull-durable-resume
branch
from
August 14, 2026 12:52
710ae4e to
64c7cde
Compare
adamziel
force-pushed
the
codex/db-apply-confirmed-replay
branch
from
August 14, 2026 12:53
e562106 to
2b6e97c
Compare
adamziel
force-pushed
the
codex/file-db-pull-durable-resume
branch
from
August 14, 2026 12:58
64c7cde to
a73c0b4
Compare
adamziel
force-pushed
the
codex/db-apply-confirmed-replay
branch
from
August 14, 2026 12:58
2b6e97c to
696367f
Compare
Collaborator
Author
|
Closing this draft. It is being replaced by a smaller target-database checkpoint stack. |
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.
A stopped
db-applynow starts an unchanged, completedb.sqlfrom the beginning on a new target connection.Background
The old code continued after its saved statement number. That statement number did not say which MySQL changes were committed. The new connection also skipped the dump header which sets SQL mode, foreign-key checks, unique checks, and autocommit.
This change
Before the first target query,
database-apply.jsonstores the SHA-256 ofdb.sql, the target database, URL replacements, table prefix, and host-specific plugin removals. A later process starts again only when those values still match. If they do not, the error explains that the target may have changed and tells the user to restore or reset it before aborting the apply.Every restart opens a new connection and reads
db.sqlfrom the beginning, so the header runs again. MySQL applies also hold a lock in the target database. A new process waits if the old target session is still running a query.Completion is saved before normal command state. If the process stops between those two writes, the next process repairs the command state without applying SQL again.
This is PR 3 of 5: #590 → #591 → #595 → #582 → #607.
Testing
The focused tests cover orderly stops, process death, changed SQL, changed targets and options, connection failure, the final state-write failure, and a target session which remains alive after the PHP process dies. The MySQL E2E also checks that SQL mode and foreign-key settings run on the new connection.