Repository navigation
MOD-21460: Add JSON.COPY for single-location JSON paths - #1731
Open
TalBarYakar wants to merge 6 commits into
Open
TalBarYakar wants to merge 6 commits into
TalBarYakar wants to merge 6 commits into
Conversation
Replace the temporary json.set event with json.copy. Verify that successful copies notify only the destination once, while skipped and failed copies emit no event. Search recognition of json.copy is a separate follow-up; older Search versions will not reindex from this event.
Cover cross-key copies, overlapping paths, NX/XX, expiration deadlines and source deletion. Verify replica state after each step and AOF recovery before and after rewrite, including that only successful writes enter the incremental stream. Add JSON.COPY to the existing per-write-command replication coverage table.
Verify same-slot copies and server-side CROSSSLOT rejection across both same-node and different-node slots. Check independent source-read and destination-write grants, same-key permissions, and command-level denial without mutating data. Include JSON.COPY in the JSON and write ACL category tests.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1731 +/- ##
==========================================
+ Coverage 88.24% 88.34% +0.10%
==========================================
Files 18 18
Lines 6871 6975 +104
==========================================
+ Hits 6063 6162 +99
- Misses 808 813 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Adds JSON.COPY to copy a stored JSON value within one document or between keys:
JSON.COPY source_key source_path destination_key destination_path [NX | XX]
Both paths must identify a single explicit location. The copied value replaces
the destination rather than merging with it. NX writes only to a missing
destination; XX writes only to an existing destination. Missing source keys
or paths return errors.
The source value is cloned before writing, so overlapping paths within the
same document use the original source value. Existing destination TTLs are
preserved; newly created keys have no TTL. Destination creation follows
JSON.SET rules, including json-auto-create-deep-paths.
The command uses the existing write and replication mechanisms and emits a
json.copy keyspace event. Key specifications enforce source read permission,
destination write permission, and same-slot routing in Cluster.
Includes command metadata with since: 99.99.99, a commands.json entry,
user documentation, and command-docs tests.
Validation
replication, and AOF replay/rewrite.
same-slot copies and server-side CROSSSLOT rejection.
plus the documentation test in each configuration.
Integration requirements and existing limitations
Until that support is available, copying into an indexed document can
leave its search index stale. Search changes are handled separately
by the Search team.
JSON.COPY replicates verbatim, so different settings can produce different
results when intermediate paths are missing. JSON.SET has the same limitation.
including its failure-handling limitations. This change does not add
rollback guarantees for that shared path.
no-op cases. No dedicated WATCH regression tests were added.
The full project test suite, load tests, and Search integration tests were
not run as part of this validation.
Note
Medium Risk
New write command touches key handling, persistence/replication, and ACL key specs; behavior reuses JSON.SET paths but adds cross-key mutation edge cases (overlap, depth, cluster slots).
Overview
Adds
JSON.COPY, a write command that copies one JSON value from a static source path to a static destination path (same key or different keys), with optionalNX/XXand the same destination-creation behavior asJSON.SET. Paths must resolve to a single location (wildcards, filters, and projections are rejected); the source is cloned before writing so overlapping paths keep the pre-copy value. The command registers with separate read/write key specs, emitsjson.copykeyspace events, and is wired throughcommands.json, user docs, and module registration.Coverage includes ACL/key-permission and Cluster same-slot rules, replication and AOF replay/rewrite, command metadata tests, and a small CI fix that **
chmod**s root-owned testlogsdirs on failure so artifacts upload.Reviewed by Cursor Bugbot for commit 00ed81a. Bugbot is set up for automated code reviews on this repo. Configure here.