Skip to content

msgpack_factory: fix events corrupted by a previous record that failed to be packed - #5646

Merged
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:reset-thread-local-packer
Nov 16, 2026
Merged

kenhys merged 1 commit into
fluent:masterfrom
Watson1978:reset-thread-local-packer

Conversation

@Watson1978

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:
When packing a record raises an error, such as RangeError for an Integer larger than 64 bits, the partially written bytes stay in the thread local packer and corrupt the next event stream packed on the same thread. For example, after in_http receives such a record, out_forward sends the next event from another client as {"big":[<time>,{"user":"other client"}]}.

This PR clears the thread local packer every time it is taken, as #4178 did for the thread local unpacker. It uses Packer#clear because Packer#reset needs msgpack 1.4.5 or later.

Docs Changes:
N/A

Release Note:
msgpack_factory: fix events corrupted by a previous record that failed to be packed

🤖 Generated with Claude Code

…d to be packed

When packing a record raises an error, the partially written bytes
stay in the thread local packer. The next event stream packed on the
same thread is appended to them and gets corrupted.

Clear the thread local packer every time it is taken, as fluent#4178 did
for the thread local unpacker. Use Packer#clear because Packer#reset
needs msgpack 1.4.5 or later.

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Watson1978 Watson1978 added bug Something isn't working backport to v1.19 We will backport this fix to the LTS branch labels Nov 16, 2026
@Watson1978 Watson1978 added this to the v1.21.0 milestone Nov 16, 2026
@Watson1978
Watson1978 requested a review from kenhys November 16, 2026 05:59
@kenhys
kenhys merged commit 7bdf768 into fluent:master Nov 16, 2026
20 checks passed
@Watson1978
Watson1978 deleted the reset-thread-local-packer branch November 16, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants