Cap the typed-structure dictionary in RecordEncoder (v5.0, maxOwnStructures) - #1146
Merged
Conversation
The per-encoder typedStructs dictionary (msgpackr's random-access typed structs) is append-only and pinned on the long-lived primary store. A wide/sparse schema whose records vary by per-field value width mints a distinct structure per shape×width combination and grows the dictionary unbounded, exhausting memory (observed on a bulk-loaded table under replication catch-up). Default maxOwnStructures to 256 (caller-overridable), bounding each dictionary. Bumps msgpackr to 1.11.13, which adds the typed-struct cap (uncapped by default; classic shared-record cap unchanged). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Summary
v5.0 backport: defaults
maxOwnStructuresto 256 inRecordEncoderand bumpsmsgpackrto1.11.13(which adds the typed-struct cap). This is the deployed-line fix for the unbounded typed-structure dictionary that OOM-crash-looped a production cluster.Purpose
msgpackr's random-access typed-struct dictionary (
typedStructs+ transition trie) is append-only and pinned on the long-lived primary-store encoder/decoder, and branches per field on the value's numeric width / string kind — so a wide/sparse schema explodes into tens of thousands of structures and grows unbounded (per-table-per-peer dictionaries × worker isolates), OOM-ing under replication catch-up of a bulk-loaded table.msgpackr@1.11.13adds an opt-inmaxOwnStructurescap to the typed-struct path (uncapped by default; the classic shared-record cap is unchanged — see kriszyp/msgpackr#185). This wires it on at 256 (caller-overridable). Once hit, novel shapes fall back to plain msgpack; the read path is untouched so existing/persisted structs stay decodable. Mirrors the main-branch change (#1145, which uses structon for the v5.1 line).Where to look
resources/RecordEncoder.ts(options.maxOwnStructures ??= 256beforesuper(options)) + themsgpackrpatch bump.Validation
new Packr({ randomAccessStructure: true, maxOwnStructures: N }).🤖 Generated by Claude (Opus 4.7).