Repository navigation
[Objects] ZADD: Reply nil to XX INCR on a missing member - #2197
Merged
Badrish Chandramouli (badrishc) merged 2 commits intoOct 2, 2026
Merged
Badrish Chandramouli (badrishc) merged 2 commits into
Badrish Chandramouli (badrishc) merged 2 commits into
Conversation
Copilot started reviewing on behalf of
Federico Laurianti (Laurianti)
October 1, 2026 07:38
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation matches existing abort behavior and is adequately tested.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes ZADD XX INCR to return nil when the member is missing, matching Redis behavior.
Changes:
- Returns null instead of
0for abortedXX INCRoperations. - Adds coverage for existing and missing keys.
| File | Description |
|---|---|
SortedSetObjectImpl.cs |
Writes null when XX INCR targets a missing member. |
RespSortedSetTests.cs |
Tests missing-member and missing-key cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Badrish Chandramouli (badrishc)
approved these changes
Oct 2, 2026
Badrish Chandramouli (badrishc)
merged commit Oct 2, 2026
7b6f3a0
into
microsoft:main
15 checks passed
x@01 (x-at-01)
added a commit
to webc-fork/garnet
that referenced
this pull request
Oct 4, 2026
…n missing key (microsoft#2192), ZADD XX INCR null (microsoft#2197), no empty object from object RMW (microsoft#2194), fresh ObjectOutput per key HCOLLECT/ZCOLLECT (microsoft#2200), CompletionEvent disposal + LogSizeTracker coalesce (microsoft#2198), dynamic test ports (microsoft#2193)
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.
Root Cause
In
SortedSetObjectImpl.SortedSetAdd, a missing member withXXset was skipped withcontinue, so withINCRthe reply fell through toWriteDoubleNumeric(incrResult)withincrResultstill 0. The branch for an existing member aborted byNX,GTorLTalready writes null.Description of Change
libs/server/Objects/SortedSet/SortedSetObjectImpl.cs: withXXandINCRon a missing member, write null and return, as theNX/GT/LTbranch does.ZADD ... XX INCRnow replies nil when the member does not exist, with or without the key, as in Redis.Tests
RespSortedSetTests.AddWithOptions:ZADD XX INCRon a missing member of an existing key replies null and does not add the member; on a missing key it replies null.Garnet.test.collections: 780 passed,Garnet.test: 1286 passed,Garnet.test.scripting: 638 passed, net10.0 Release.Issues Fixed
Fixes #2196