Fix JSON.MSET duplicate-key crash#112
Merged
roshkhatri merged 1 commit intoJun 11, 2026
Merged
Conversation
Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
zackcam
approved these changes
Jun 10, 2026
zackcam
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me, should we put a note in the docs that the behaviour now will silently fail on a bad duplicate key but still return ok?
This was referenced Jun 11, 2026
Closed
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.
Fix for: #106
A
JSON.MSETthat references the same key more than once could crash the server(SIGABRT). Triples are validated up front and then applied in place under
ValkeyModule_Assert(rc == JSONUTIL_SUCCESS). For a duplicated key, an earlier op changesthe document's shape, so a later op (validated against the original shape) fails at apply
time and the assertion aborts the process.
This removes the apply-phase assertions and applies ops on a best-effort basis. Each key
is opened fresh at apply time, so every op sees the current value, including the effect of
an earlier op on the same key. An op that cannot apply against the current document is
skipped and the remaining ops are still applied; the command returns OK. Up-front
validation is unchanged, so malformed commands are still rejected atomically with an error
before any write.
This also makes JSON.MSET behavior compatible with RedisJSON.
Tests: added cases for a duplicated key whose later op conflicts with the first (returns
OK, server alive, first op committed), a three-op case where a middle op is skipped and
the others applied, and a case where the later op is valid against the first op's result
so both apply. Existing MSET and validation tests pass unchanged; the full integration
suite passes across all server versions including the ASAN build.