Repository navigation
fix(writer): spill large INSERT chunks to disk instead of rendering them in memory (Spec 03.06 section 3.4) - #1536
Merged
Conversation
…hem in memory (Spec 03.06 section 3.4) A chunk whose rendered size bound reaches insert.spill.threshold.bytes (default 32 MiB) is written row by row to a spill file and sent as INSERT ... FORMAT Values through the driver's own client; values of 64 KiB or more are streamed from the row itself. The driver still encodes every small value and its own row template is used, so the text sent is byte-identical to the in-memory path (pinned by SpillingInsertStatementTest against the driver's addBatch output). A 256 MiB row that exhausted a 4 GiB heap and crash-looped now replicates value-exact up to 512 MiB at 4 GiB (bytes mode); new e2e harness tests/e2e/large_row_spill.sh. Jinja-Render-Check: rendered=2; formats=shell,yaml; result=pass Destructive-Op-Check: sites=3; result=pass Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
The V2 JDBC driver renders every INSERT chunk as SQL text in memory: each value is encoded into a String, each row substituted into a StringBuilder, the chunk concatenated, turned into a String and then a UTF-8 byte[] body. One value of V bytes costs 5-6 live copies of its text, and a binary value's hex text is 2V. JFR on 2.11.0 (one 64 MiB and one 256 MiB LONGBLOB row, each inserted and updated in one transaction): 17.5 of 22.4 GiB allocated were these copies. With a 4 GiB heap the 256 MiB row exited on OutOfMemoryError and crash-looped on every restart (edge E5 failed 2 of 3 runs on 32b43c2).
Change (spec first: 03.06 section 3.4, FM-03.06-5/6/7; FM-01.08-5, FM-04.02-3, FM-07.04-3, FM-07.05-1 updated)
Verification
Residual (declared)
The decoded row images still have to fit the heap while Debezium holds them (FM-01.08-5). MySQL's applier is the same: one event in memory, bounded by max_allowed_packet.
🤖 Generated with Claude Code