Repository navigation
Handle overflows in RespMemoryWriter - #1987
Merged
Merged
Conversation
…thub.com/microsoft/garnet into users/kmontrose/respMemoryWriterOverflow
Badrish Chandramouli (badrishc)
approved these changes
Jul 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
test/standalone/Garnet.test/RespMemoryWriterOverflowTests.cs:115
- In
SetAsync/SortedSetAsync, buildingmemberNamevia string interpolation copies the 40k-characterlongValueinto a new string for every member. With 60,000 members this is several GB of managed allocations on the test client alone and is very likely to OOM the test runner before the server behavior is exercised.
var longValue = new string('s', MemberLength);
for (var i = 0; i < NumMembers; i += BatchSize)
{
var writeTasks = new Task<bool>[BatchSize];
writeTasks.AsSpan().Fill(Task.FromResult(true));
for (var j = 0; j < writeTasks.Length; j++)
{
var memberName = $"{(i + j)}_{longValue}";
writeTasks[j] = db.SetAddAsync(Key, memberName);
}
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #1616
Supercedes #1945
Simplest possible fix (just changes the exception type and adds a message).
Includes tests for the
RespMemoryWriter-using types (Hash, List, Set, and SortedSet) to prevent regressions.