Skip to content

[PHP] Stop pull-db cleanly during database apply - #582

Closed
adamziel wants to merge 1 commit into
codex/db-apply-confirmed-replayfrom
codex/resume-database-pull-apply
Closed

[PHP] Stop pull-db cleanly during database apply#582
adamziel wants to merge 1 commit into
codex/db-apply-confirmed-replayfrom
codex/resume-database-pull-apply

Conversation

@adamziel

@adamziel adamziel commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

pull-db now handles SIGINT and SIGTERM while it is applying the database, exits with code 2, and leaves the database-apply stage unfinished for the next process.

Background

The wrapper kept its normal signal handler while db-apply was running. A signal could therefore kill the process during an active PDO query. If db-apply returned partial, the wrapper also called it again immediately in the same process.

This change

The wrapper uses the database-apply signal policy only for that stage and restores its normal policy afterward. Pending signals are handled between SQL chunks, not during a target query.

db-apply runs once per wrapper process. A partial result sets exit code 2 and returns without marking the stage or the whole pull complete. The next process uses #595 to start db.sql again from the beginning.

This is PR 4 of 5: #590#591#595#582#607.

Testing

The focused PHP tests cover the partial result, next-process completion, restoration after an exception, and the actual PCNTL handlers and signal mask. The MySQL E2E blocks a target query, sends SIGTERM, checks exit code 2 and the unchanged stage, then completes the pull in a new process.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Pull pipeline performance — large-directory

Site: large-directory · 2,000+ plus targeted file-transfer scenarios files · 10,000 posts · 25,000 postmeta · PHP 8.5.9

Stage PR trunk Δ Status Details
playground-sqlite-db-pull 9.91 s 9.70 s ⚪ +212 ms (+2.2%) 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.77 s 3.75 s ⚪ +21 ms (+0.6%) 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.69 s 13.46 s ⚪ +232 ms (+1.7%)

Numbers carry runner noise; treat single-run deltas as directional, not authoritative.

📈 Trunk performance history — commit-by-commit timeline.

@adamziel
adamziel force-pushed the codex/resume-database-pull-apply branch from 1f9c724 to d21fd7d Compare August 13, 2026 23:04
@adamziel adamziel changed the title [PHP] Retain SQL cursor parts and replay interrupted database applies [PHP] Require durable boundaries for database pull and apply restarts Aug 13, 2026
@adamziel
adamziel force-pushed the codex/resume-database-pull-apply branch from 461d802 to 44f6d47 Compare August 14, 2026 02:14
@adamziel adamziel changed the title [PHP] Require durable boundaries for database pull and apply restarts [PHP] Stop pull-db cleanly during database apply Aug 14, 2026
@adamziel
adamziel changed the base branch from trunk to codex/db-apply-confirmed-replay August 14, 2026 02:14
@adamziel
adamziel force-pushed the codex/db-apply-confirmed-replay branch from 0973ff7 to e562106 Compare August 14, 2026 12:48
@adamziel
adamziel force-pushed the codex/resume-database-pull-apply branch from 44f6d47 to c77fa57 Compare August 14, 2026 12:49
@adamziel
adamziel force-pushed the codex/db-apply-confirmed-replay branch from e562106 to 2b6e97c Compare August 14, 2026 12:53
@adamziel
adamziel force-pushed the codex/resume-database-pull-apply branch from c77fa57 to 12d65b5 Compare August 14, 2026 12:53
@adamziel
adamziel force-pushed the codex/db-apply-confirmed-replay branch from 2b6e97c to 696367f Compare August 14, 2026 12:58
@adamziel

Copy link
Copy Markdown
Collaborator Author

Closing this draft. It is being replaced by a smaller target-database checkpoint stack.

@adamziel adamziel closed this Aug 14, 2026
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