fix(dev-env): recompute mydumper section sizes after search-replace#2872
Open
WRasada wants to merge 1 commit into
Open
fix(dev-env): recompute mydumper section sizes after search-replace#2872WRasada wants to merge 1 commit into
WRasada wants to merge 1 commit into
Conversation
This was referenced Jun 5, 2026
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
The transform rewrote section header sizes to -1, which myloader >= 0.20 parses as ULLONG_MAX and then swallows every subsequent header as file content, importing nothing. Emit fixed-width placeholders while counting each section's post-replacement bytes, then patch the real sizes into the output file. Also fixes header detection across chunk boundaries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cf6ef16 to
9183d6d
Compare
|
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.



Problem
vip dev-env import sql --search-replace=...on a MyDumper-format dump imports nothing. myloader floods the output with:and exits "successfully" with zero tables restored.
vip dev-env sync sqlis equally affected for multisite environments (it always search-replaces site URLs through the same code path).Root cause
A MyDumper stream is a sequence of
-- <filename> <size>section headers, each followed by that file's content. Search-replace changes content lengths, sofixMyDumperTransform()rewrote every header size to-1(old implementation on trunk).
myloader parses the size with
g_ascii_strtoull()—-1wraps toULLONG_MAX— and uses it to distinguish a real header from header-looking content: while fewer bytes than the declared size have been written, a header line is treated as content (myloader_stream.c#L291-L309). AgainstULLONG_MAXthat condition is always true, so every header after the first is swallowed intometadata.headerand no sections are ever processed.This is the same failure that previously forced a mydumper downgrade in vip-container-images#1116 (refs PLTFRM-22, closed without a durable fix); the 0.21.3 upgrade re-exposed it.
The old transform also processed raw chunks rather than lines, so headers straddling a chunk boundary were silently missed — fixed here as well.
Fix
MyDumperSectionSizeTransform(src/lib/database.ts) replaces the-1hack:patchMyDumperSectionSizes()overwrites the placeholders in place (same byte length → offsets stay valid)Size convention verified against real mydumper output: a section's size counts its content bytes including the content's own trailing newline, excluding the single separator newline before the next header; the final section runs to end of stream.
Wired into both consumers:
searchAndReplace()(src/lib/search-and-replace.ts) andDevEnvSyncSQLCommand.runSearchReplace()(src/commands/dev-env-sync-sql.ts).Also adds a guard rejecting compressed (
.gz) input tosearchAndReplace(): the replacementoperates on raw bytes, so a compressed file previously passed through with no replacements
applied and no indication of failure. It now errors with instructions to decompress first.
(The dev-env import path is unaffected — it already decompresses before search-replace.)
Testing
__tests__/lib/database.js): stale-size recomputation, byte-exact content preservation, chunk-boundary splits at widths 1/3/7/64, header-lookalike content lines, final section without trailing newline__tests__/lib/search-and-replace.js): fullsearchAndReplace()over a MyDumper fixture with a length-changing replacement; asserts every header size matches the content that follows__fixtures__/dev-env-e2e/mydumper-detection.expected.sql— the old fixture asserted the-1output as expected behavior; new sizes were derived with an independent script and match the transform's output--search-replaceagainst a 201k-table dump completes and restores all tables (previously: zero)Compatibility
--search-replace: unaffected — the transform never runsChangelog Description
Fixed
--search-replaceproducing an import that silently restores no tables for MyDumper-format SQL backups (affectsvip dev-env import sqlandvip dev-env sync sql)vip search-replacewriting MyDumper files that could not be imported with myloader (section sizes are now recomputed when output goes to a file).gz) file; it now errors and asks for the file to be decompressed firstRelated
.gzinput support is feasible (the gunzip stream helper already exists) but needs design decisions — the size-patch step requires uncompressed output, and--in-placesemantics on a compressed file are ambiguous — so it is deliberately out of scope here-ofix), fix(validations): avoid ENGINE != InnoDB false positives on row data #2873 (ENGINE validation), perf(dev-env): tune local database performance defaults #2874 (DB tuning)🤖 Generated with Claude Code