Add regression test for string_fastpath/compression flag collision#1098
Closed
mhenrixon wants to merge 1 commit into
Closed
Add regression test for string_fastpath/compression flag collision#1098mhenrixon wants to merge 1 commit into
mhenrixon wants to merge 1 commit into
Conversation
3 tasks
Owner
|
Thanks for clarifying the issue and providing a test. Test included in #1099. |
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.
Adds an integration test covering the collision between
ValueSerializer::FLAG_UTF8andValueCompressor::FLAG_COMPRESSED. Both constants are0x2, so any value written withstring_fastpath: trueas a per-request option produces ambiguous flags on read.The bug is fixed by #1086, but no test was added there that fails on
mainand passes on the fix — so the regression could re-emerge if the flag handling is refactored again. This PR fills that gap.What the test covers
string_fastpath: trueper-request +compress: trueclient-level. Below the compression threshold, but the fastpath still sets bit0x2, which the reader's compressor interprets asFLAG_COMPRESSEDand tries toZlib.inflateon raw UTF-8 bytes.compression_min_size).0x2clear, compressor sets it; without the fix the reader returns the decompressed bytes with the wrong encoding.string_fastpathreading every key — covers a rolling-deploy or worker-pool mismatch where only some processes use the per-request option (mirrors howActiveSupport::Cache::MemCacheStore#write_serialized_entryforwards per-call options to Dalli).Why the existing fastpath test didn't catch it
test/integration/test_serializer.rb#L17coversstring_fastpathas a client-level option without compression. The new test covers the production-relevant path:string_fastpath: trueas a per-request option on#set, withcompress: trueon the client. That's the combination Rails callers naturally produce — Rails strips:compressfrom per-call options (seeactive_support/cache/mem_cache_store.rb#L215) but forwards everything else.Verification
On
main(1bc7403, "Prepare 5.0.3 release"):With #1086 applied (cherry-picked locally):
Production symptom this corresponds to
When the UTF-8 branch fires inside Rails,
Dalli::UnmarshalErroris caught byMemCacheStore#rescue_error_withand returned as a silent cache miss. The application re-runs whatever produced the value and re-writes it; the next read trips the same error. The Memcachier dashboard for an app that hit this shows roughly equal gets, misses, and sets at very high volume with hit rate hovering near 80% — looks healthy at a glance, but every cacheable computation is running twice or more. See #1086 (comment) for the full standalone repro and version matrix.Notes
tests.yml).mainuntil Fix thestring_fastpathoption to not comflict with compression #1086 (or an equivalent fix) is merged. That's the intended signal.