string: avoid storing already-expired MSETEX values#3534
Open
charsyam wants to merge 1 commit intovalkey-io:unstablefrom
Open
string: avoid storing already-expired MSETEX values#3534charsyam wants to merge 1 commit intovalkey-io:unstablefrom
charsyam wants to merge 1 commit intovalkey-io:unstablefrom
Conversation
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3534 +/- ##
============================================
+ Coverage 76.40% 76.41% +0.01%
============================================
Files 159 159
Lines 79851 79873 +22
============================================
+ Hits 61008 61035 +27
+ Misses 18843 18838 -5
🚀 New features to boost your workflow:
|
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.
This changes
MSETEXto avoid materializing values whose expiration time is already in the past.The existing
msetexCommandcode already acknowledged this as a TODO:This PR takes the "more complicated" path and mirrors
setGenericCommand'sexisting fast-path (t_string.c:130). For a large multi-key
MSETEXwith apast
PXAT, this avoids N × setKey + setExpire allocations, two keyspacenotifications per key (
set+expire), and the subsequent active/lazyexpire work.
What changed
MSETEXinmsetexCommand.NX/XXsemantics by evaluating them before the fast path.single consolidated
DEL/UNLINK k1 k2 ... kN(not per-key).preventCommandPropagation()instead of relying ondirty == 0, so thesuppression intent survives future changes to
call()'s propagation logic.stat_expiredkeysis incremented once per key that was actually deleted,matching how SET's fast-path treats the same counter.
Tests
Under
tests/unit/type/string.tcl:MSETEX with past EXAT/PXAT - key stored but logically expiredtest, which locked in the pre-fix behavior, with... - keys are not stored.MSETEX lazy/active expire with all expiration optionstests: key3/key4 (past
EXAT/PXAT) now hit the fast path and nevermaterialize, so the expected UNLINK /
expired_keyscounts drop from 4to 2.
MSETEX with past PXAT deletes existing keys and propagates as a single UNLINK— verifies the consolidated multi-key DEL/UNLINK path.MSETEX with past PXAT and no existing keys does not propagate—uses a sentinel
SETto verify the no-op path doesn't leak toreplicas or the AOF.
lazyfree-lazy-expireto its defaultso later tests aren't sensitive to ordering.