Replication streaming compression (per-replica) - review vs #3531 base - #21
Open
roshkhatri wants to merge 9 commits into
Open
Replication streaming compression (per-replica) - review vs #3531 base#21roshkhatri wants to merge 9 commits into
roshkhatri wants to merge 9 commits into
Conversation
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
4 times, most recently
from
July 29, 2026 23:07
2f851c3 to
3688b40
Compare
roshkhatri
commented
Jul 30, 2026
Comment on lines
+201
to
+216
| # Re-runs the replication suite with repl-compression=lz4-stream applied | ||
| # globally via --config. Test files opt in by carrying the top-level "repl-compression" | ||
| # tag (see tests/support/server.tcl), so this job selects them with | ||
| # --tags repl-compression instead of a hardcoded filename list that would | ||
| # silently drift if a file is renamed. Exercises the streaming-compression | ||
| # transport across the replication surface (full sync, dual-channel, buffer | ||
| # management, AOF-sync, etc.) to catch regressions that only surface under | ||
| # compressed replication. | ||
| # Note: a few tests are intentionally NOT tagged for this job: | ||
| # - integration/replication-psync: its start_server lives inside a reusable | ||
| # proc, incompatible with a top-level-only tag. | ||
| # - integration/replication-buffer.tcl and the buffer-memory tests in | ||
| # integration/dual-channel-replication.tcl: they assert exact replication | ||
| # buffer/backlog memory and byte volumes, which compression legitimately | ||
| # changes (per-replica codec buffers, fewer wire bytes). They run in the | ||
| # regular (uncompressed) job. |
| return 0; | ||
| } | ||
|
|
||
| /* Sink path: compress directly into the caller's sds tail, no scratch/emit. */ |
Owner
Author
There was a problem hiding this comment.
remove , no scratch/emit.
|
|
||
| /* Set by the repl-compression apply callback when the setting changes. Switching | ||
| * a live link between plaintext and compressed requires a reconnect, which is | ||
| * irreversible, so the reconcile is deferred until after the whole CONFIG SET |
| /* Switching existing replicas between plaintext and compressed requires a | ||
| * reconnect, which is irreversible. Only record intent here; configSetCommand | ||
| * runs the reconcile after the command commits, so a rolled-back CONFIG SET | ||
| * disconnects nothing. */ |
| /* Primary client with a live replication decoder (probing or compressed) | ||
| * must be decoded on the main thread; the IO-thread read path does not | ||
| * invoke replDecompressQueryBuf. Once the probe resolves to plaintext the | ||
| * decoder is destroyed and reads return here. */ |
| /* Check for unsent compressed data in the compressed output buffer. | ||
| * Skip while CLIENT_PENDING_IO: the IO thread owns out_buf and may | ||
| * realloc it, so the main thread must not read it here | ||
| * (postWriteToReplica re-checks once the write job completes). */ |
| * malicious or buggy primary; disconnect rather than allocate unbounded. */ | ||
| #define REPL_STREAM_DECODER_OUTPUT_MAX (256 * 1024 * 1024) | ||
|
|
||
| int replDecompressQueryBuf(client *c, size_t new_data_start) { |
Owner
Author
There was a problem hiding this comment.
Does this belong to some replication file?
Comment on lines
+89
to
+99
|
|
||
| /* Reconcile each replica's transport with the current repl-compression setting | ||
| * after a runtime change. A live link cannot switch between plaintext and a | ||
| * compressed VCS/LZ4 frame mid-stream, so a mismatched replica is dropped and | ||
| * reconnects to renegotiate: | ||
| * - compression disabled: drop replicas still on a compressed stream; | ||
| * - compression enabled: drop online replicas that advertised the capability | ||
| * but are still plaintext, so they come back compressed. | ||
| * Disconnect is async because we run inside the main event loop; the iteration | ||
| * is safe since freeClientAsync does not remove from server.replicas | ||
| * synchronously. Replicas still syncing are left alone: they pick up the current |
Comment on lines
+131
to
+134
| /* If we are ourselves a replica, the compression capability was negotiated | ||
| * with our primary at handshake time. A config change must renegotiate, so | ||
| * drop the upstream link; the replication cron reconnects and re-advertises | ||
| * capa with the new setting. */ |
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
3 times, most recently
from
July 30, 2026 08:24
5d2009b to
5442bed
Compare
roshkhatri
force-pushed
the
streaming-compression-rio-pr
branch
from
August 3, 2026 16:06
3975e1a to
dfcc37a
Compare
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
6 times, most recently
from
August 4, 2026 02:13
88ad2f0 to
caf1b3d
Compare
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
2 times, most recently
from
August 5, 2026 07:58
70ab3ba to
8ac3117
Compare
Vendor lz4, lz4hc, lz4frame and xxhash from https://github.com/lz4/lz4 (v1.10.0) under deps/lz4 with build wiring for make and cmake. Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Add Valkey Compressed Stream (VCS) support for RDB persistence with lz4 as the first whole-stream codec. The RDB is wrapped in a VCS envelope and compressed as a single stream at the rio layer. On load, the RDB path probes for the envelope and transparently decompresses when present, falling back to the plain RDB path otherwise. Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Apply the outstanding review changes and retain the null-safe RDB stream-writer check required by encoded-length calculation. Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
roshkhatri
force-pushed
the
streaming-compression-rio-pr
branch
from
August 11, 2026 23:12
dfcc37a to
62a5899
Compare
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
from
August 13, 2026 18:27
8ac3117 to
2886b6f
Compare
roshkhatri
force-pushed
the
streaming-compression-rio-pr
branch
from
August 13, 2026 18:28
62a5899 to
26d48a4
Compare
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
from
August 13, 2026 19:21
2886b6f to
d8c14e4
Compare
Signed-off-by: Roshan Khatri <roshanvkhatri@gmail.com>
roshkhatri
force-pushed
the
replication-streaming-compression-v2
branch
from
August 13, 2026 20:21
d8c14e4 to
a41c3e7
Compare
roshkhatri
force-pushed
the
streaming-compression-rio-pr
branch
from
August 14, 2026 19:43
26d48a4 to
e45f2d6
Compare
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.
Review-only PR: isolates the per-replica replication-stream compression work, squashed to one commit on sarthak's latest valkey-io#3531 base (dfcc37a, final).
Supersedes #19 (old base lineage). Does not update the upstream PR.