RESP3: ZMPOP closes the connection when a popped score is infinite
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in libs/server/Resp/Objects/SortedSetCommands.cs at SortedSetMPop, around line 511, and compare its RESP3 score handling with the working BZMPOP or ZPOPMIN paths. Reproduce with the supplied RESP3 commands and confirm ZMPOP returns infinite scores as RESP3 doubles instead of closing the connection.
Written by the indexing model from the issue text.
Description
Describe the bug
On RESP3, ZMPOP closes the connection when any popped member has an infinite score. The server logs:
crit: Session[0] [...] ProcessMessages threw an exception: System.FormatException: The input string '-inf' was not in a correct format.
at System.Double.Parse(ReadOnlySpan`1 utf8Text, NumberStyles style, IFormatProvider provider)
at Garnet.server.RespServerSession.SortedSetMPop[TGarnetApi](TGarnetApi& storageApi) in /src/libs/server/Resp/Objects/SortedSetCommands.cs:line 511
The cause is in SortedSetMPop, libs/server/Resp/Objects/SortedSetCommands.cs:511:
if (respProtocolVersion >= 3)
{
WriteDoubleNumeric(double.Parse(score.ReadOnlySpan));
}
Scores are stored as Redis text (inf, -inf), and .NET's double.Parse does not accept that text. RESP2 is not affected, because it writes the stored text unchanged. The other pop and range paths already write RESP3 doubles correctly (,inf): ZRANGE ... WITHSCORES, ZPOPMIN, BZPOPMAX and BZMPOP all work.
Steps to reproduce the bug
HELLO 3
ZADD inf -inf 7 +inf 9 => :2
ZRANGE inf 0 -1 WITHSCORES => [[7, ,-inf], [9, ,inf]] (works)
ZMPOP 2 missing inf MIN COUNT 2 => connection closed
Expected behavior
ZMPOP replies [inf, [[7, -inf], [9, inf]]], with the scores as RESP3 doubles ,-inf and ,inf, as Redis does and as BZMPOP already does in Garnet.
Release version
v2.2.5 (ghcr.io/microsoft/garnet:2.2.5, default options). Also reproduced on v2.1.8, on main at 8d00713, and on the head of #2289.
IDE
Not applicable. Commands sent over a raw TCP connection.
OS version
Docker on Windows 11 (Linux container).
Additional context
Found while running the integration suite of Respire, a .NET Redis client, against Garnet. I could not find an existing issue or pull request for this. The other RESP3 paths may have a shared helper that formats the stored score text without double.Parse, which this path could reuse.
- Dominant language
- C#
- Stars
- 12.1k
- Forks
- 716
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 62
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/garnet
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days
-
GEOADD updating a member's position keeps the member's old TTL, so the new position is silently deletedMay be free again @Saad-elnagar claimed this 9 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
microsoft/garnet#2265 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 2 days
All issues in microsoft/garnet
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
possible bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Include host.wslc.internal in the HTTPS development certificatePossibly taken @afscrome claimed this today. Openarea-commandlinetools
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dotnet/aspnetcore#70122 · 1 comment ·
Maintainers usually reply within 1 day
-
:1st_place_medal: good first issue :cowboy_hat_face: refactor :roller_coaster: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ApplETS/Backend-Hello#78 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 2 days