fix: L1 crash when serialize: false with L2 cache#113
Open
thisisnkc wants to merge 2 commits intoJulien-R44:mainfrom
Open
fix: L1 crash when serialize: false with L2 cache#113thisisnkc wants to merge 2 commits intoJulien-R44:mainfrom
thisisnkc wants to merge 2 commits intoJulien-R44:mainfrom
Conversation
🦋 Changeset detectedLatest commit: e499df6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
When using a two-tier cache with
serialize: falseon the L1 memory driver, reading a value that exists only in L2 causes a crash on subsequent L1 reads:Root cause: During L2-to-L1 refill, the code unconditionally called
entry.serialize(), storing a serialized string into L1. Since L1 has no deserializer whenserialize: false, the next read from L1 crashes inCacheEntry.fromDriver().This affected three code paths:
cache.get()- L2 hit refill to L1cache.get()- graced L2 value refill to L1cache.getOrSet()viaTwoTierHandler.#returnRemoteCacheValue()Fix
toRaw()method fromCacheEntry.serialize()to return the plain object without serializationprepareForL1(entry)helper onCacheStackthat returnsentry.serialize()orentry.toRaw()based on theserializeL1optionprepareForL1()instead of unconditionalserialize()Tests added
L2 hit should correctly refill L1 when serialize is false—cache.get()path: L2 hit refills L1, subsequent L1 read works and stores an object (not a string)getOrSet L2 hit should correctly refill L1 when serialize is false—cache.getOrSet()path: L2 hit refills L1, subsequent call reads from L1 without errorCloses #111