Skip to content

[PHP] Resume file-backed db-pull from flushed cursor boundaries - #591

Draft
adamziel wants to merge 1 commit into
codex/direct-db-pull-process-boundariesfrom
codex/file-db-pull-durable-resume
Draft

[PHP] Resume file-backed db-pull from flushed cursor boundaries#591
adamziel wants to merge 1 commit into
codex/direct-db-pull-process-boundariesfrom
codex/file-db-pull-durable-resume

Conversation

@adamziel

@adamziel adamziel commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

A new db-pull process now continues file output from the last flushed byte and source cursor boundary instead of silently starting the lifecycle over.

Background

Exit code 2 leaves completion_state=partial. Direct db-pull previously recognized only in_progress, so a later process replaced the partial lifecycle. A hard stop could also leave db.sql ahead of or behind the saved source cursor without a reliable way to classify those bytes.

This change

File pulls write database-dump.intent before starting and save the source cursor only after the matching db.sql bytes have been flushed. Resume truncates an unconfirmed tail, rejects a missing or shorter file, and refuses an output-mode change. Every file request asks for replacement-table SQL. A completed SHA-256 record confirms the resulting dump only after the source reports completion.

db-apply refuses an intent-marked prefix; safe replay of a completed replacement dump is added by #595.

This is PR 2 of 5 in the database restart stack: #590#591#595#582#607.

Testing

Focused tests cover exit-code-2 continuation through the database-index stage, two process deaths around the first SQL checkpoint, missing and shortened local artifacts, output-mode drift, and rejection of an unfinished dump by db-apply.

  • DatabaseCommandRestartTest
  • import-54-db-pull-index-interruption
  • import-59

@github-actions

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.36 s 9.56 s ⚪ -199 ms (-2.1%) 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.63 s 3.57 s ⚪ +56 ms (+1.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 12.98 s 13.13 s ⚪ -143 ms (-1.1%)

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

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

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