Skip to content

[backport] Backport sweep for 8.0 - #5508

Open
valkeyrie-ops[bot] wants to merge 36 commits into
8.0from
agent/backport/sweep/8.0
Open

valkeyrie-ops[bot] wants to merge 36 commits into
8.0from
agent/backport/sweep/8.0

Conversation

@valkeyrie-ops

@valkeyrie-ops valkeyrie-ops Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Backport sweep for 8.0

Automated cherry-picks from PRs marked "To be backported".

CI fixes for this sweep are in #5699.

Applied

Source PR Title Detail
#5417 Abort dual-channel sync if the primary link breaks while streaming conflicts resolved by Claude Code
#4675 Fix cluster bus self-forget use-after-free conflicts resolved by Claude Code
#5452 Ignore replica claims that would close a replicaof cycle conflicts resolved by Claude Code
#3245 Fix assertion crash in processIOThreadsReadDone when DONT_PARSE client has stale argc conflicts resolved by Claude Code
#5476 Fix RDB checker infinite loop on an RDB truncated inside a module value
#5690 Send tracking invalidation on SWAPDB
#5611 Propagate BITFIELD when OVERFLOW FAIL only creates or grows the key
#2274 Redact user data when hide-user-data-from-log enabled
#2742 Fix XREAD returning error on empty stream with + ID conflicts resolved by Claude Code
#2953 Fix potential memory leaks when a writable replica is promoted to primary after direct writes of keys with expiration conflicts resolved by Claude Code
#2846 Dual-channel-replication announces itself at replica-announce-ip if configured conflicts resolved by Claude Code
#3440 Fix config rewrite producing negative values for unsigned memory configs conflicts resolved by Claude Code
#3583 Fix checkPrefixCollisionsOrReply returning non-zero on self-overlap conflicts resolved by Claude Code
#3448 Fixes server crash when RDMA benchmark clients disconnect conflicts resolved by Claude Code
#4140 Retry PSYNC on -BUSY error instead of downgrading to SYNC conflicts resolved by Claude Code
#4380 Resolve a key's slot from the key, not from the executing command conflicts resolved by Claude Code
#4599 Fix timing issue in WATCHed key in another slot that expired aborts EXEC test
#4877 Block DEBUG RELOAD and DEBUG LOADAOF in loading and async-loading conflicts resolved by Claude Code
#5141 Don't block CLUSTER SETSLOT on replica acks when the client cannot block conflicts resolved by Claude Code
#5176 Quote the replicaof host when rewriting the config file conflicts resolved by Claude Code
#5132 Hash HyperLogLog elements with a size_t length conflicts resolved by Claude Code
#5153 Do not let forked script debug sessions postpone automatic saves conflicts resolved by Claude Code
#5379 Skip the crash memory test under Valgrind and bound its region list
#5526 Fix flaky dual-channel mid-stream abort test under valgrind conflicts resolved by Claude Code
#5556 Refuse to load a replicaof cycle from nodes.conf conflicts resolved by Claude Code
#5644 Prevent size_t underflow in used_memory_dataset calculation conflicts resolved by Claude Code
#2933 Don't require node-id to be null terminated in VM_GetClusterNodeInfo
#5682 Abort dual channel sync cleanly when main link write fails after $ENDOFF conflicts resolved by Claude Code
#5369 Sanitize FUNCTION LIST error replies conflicts resolved by Claude Code
#4973 Fix AOF/slot-migration dropping deleted stream PEL entries conflicts resolved by Claude Code
#5529 Fix killAppendOnlyChild reaping children other than the AOF rewrite child conflicts resolved by Claude Code
#5558 Extend offset-sync wait after mid-stream abort in dual-channel test conflicts resolved by Claude Code

AI resolution details are posted as comments on this PR when available.

Needs attention

These candidates could not be applied automatically and need a maintainer to follow up.

5 candidate(s)
Source PR Title Outcome Reason
#5029 Fix CI failures on clang-format due to OS changes on the runner Image skipped-conflict target branch lacks conflicted file(s): .github/workflows/clang-format.yml
#4954 Match listpack for lex range commands on mixed-score btree zsets skipped-conflict target branch lacks conflicted file(s): src/ordered_index.c
#5584 Fix double free of the key iterator on AOF rewrite write error skipped-validation-failed BACKPORT_UNMAPPED_TEST_PATHS=["src/unit/test_aof.cpp"] changed test path(s) have no explicit validation mapping: src/unit/test_aof.cpp Branch-native test adaptation: test adaptation not applied: invalid generated test path(s): src/unit/test_files.h
#5269 Validate cluster module message lengths before allocation skipped-conflict unresolved - src/unit/test_cluster_module.cpp: allowed cherry-pick file edit failed to read: [Errno 2] No such file or directory: '/home/runner/work/_temp/backport-sweep/backport-8.0-r0shjw3b/src/unit/test_cluster_module.cpp'
#5596 Limit the Lua debugger to the client that runs the session skipped-conflict target branch lacks conflicted file(s): src/modules/lua/debug_lua.c, src/scripting_engine.c, tests/modules/helloscripting.c

Generated by valkey-ci-agent using Claude Code.

@valkeyrie-ops valkeyrie-ops Bot added ai-resolved-conflicts AI is used to resolve conflicts in automated backport PRs. backport Backport PR opened by valkey-ci-agent labels Nov 19, 2026
@valkeyrie-ops

valkeyrie-ops Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5417

Abort dual-channel sync if the primary link breaks while streaming

2 AI-edited files

Claude Summary

Both conflicts are resolved in place, with no markers left and nothing staged or committed. The resolved diff is +171/−1 against upstream's +173/−2, and one line of it goes beyond the PR's own diff — please review that one.

The line outside the PR's diff

In dualChannelSyncSuccess() I changed the abort path from replicationUnsetPrimary() to freeClientAsync(server.primary).

  • Why it's needed: upstream made this change in Streaming Compression support for Replication #3853 (streaming compression), which 8.0 doesn't have, and Abort dual-channel sync if the primary link breaks while streaming #5417 was written on top of it. On 8.0 that branch was effectively dead code; the PR's new C_ERR return makes it reachable.
  • What happens without it: I built that variant and both new tests fail with "Replica didn't resync". The replica log shows it detecting the broken link, then Setting secondary replication ID … New replication ID is … — it promotes itself to a standalone primary and never reconnects.
  • With it: the replica aborts, caches the primary, reconnects, and resyncs, which is the PR's stated intent.

If you'd rather not carry that line in this backport, the PR shouldn't be backported on its own.

src/replication.c

  • primaryConnBrokenWhileStreaming(): kept as upstream, but it logs with plain serverLog because 8.0 has no dualChannelServerLog macro. The message text the tests match on is unchanged.
  • streamReplDataBufToDb(): kept 8.0's loop and dropped the incoming compression/decode path, since none of its symbols exist on 8.0. I added upstream's check, if (!server.pending_repl_data.blocks || primaryConnBrokenWhileStreaming(c)), right after the existing replStreamProgressCallback() call.

tests/integration/dual-channel-replication.tcl

  • Dropped: four tests on the incoming side that exist only upstream and aren't part of this PR (lazyfree, replica-announce-ip, buffer memory fields, hash field expiration).
  • First new test: taken verbatim.
  • Second new test: unwrapped from foreach compression {no lz4} into a sin
    ... summary truncated.

AI-edited files requiring review

  • src/replication.c — view diff
  • tests/integration/dual-channel-replication.tcl — view diff

Full backport commit diff: commit 3e7dd8d60b20.

Please review these AI resolutions for correctness before merging.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 00355f6c-2f1c-4fab-9c65-a76d963e5a22

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4675

Fix cluster bus self-forget use-after-free

2 AI-edited files

Claude Summary

The first real error was cluster_legacy.c:2978:24: error: 'return' with a value, in function returning void, and I've applied a fix for it plus one test adaptation; nothing has been built or run here.

  • Build error (src/cluster_legacy.c): on 8.0 clusterProcessPingExtensions returns void, but the backported fix frees the link and does return 0;. I changed the function to return int (1 if the link is still valid, 0 if it was freed). The single caller in clusterProcessPacket now returns 0 when the link was freed, so the read handler stops touching it.
  • Test helper (tests/unit/cluster/packet.tcl): the new create_cluster_forgotten_node_packet called create_cluster_meet_packet with six arguments, but 8.0's version takes three. This would have failed with a Tcl "wrong # args" error once the build passed. I switched it to the three-argument call and patch the packet in place (type PING, gossip count 0, one extension), the same way the existing create_cluster_ping_packet_with_ext does on this branch.

No files outside the two listed were touched.

AI-edited files requiring review

Full backport commit diff: commit 0abd28dc6ecc.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #3245

Fix assertion crash in processIOThreadsReadDone when DONT_PARSE client has stale argc

3 AI-edited files

Claude Summary

Both conflicts are resolved and no conflict markers remain in any of the three files. The backport builds cleanly with the settings the tree was last built with (-Werror -DLOG_REQ_RES, TLS on), and the new test passes. Nothing is staged or committed, and only the three listed files were edited.

Conflict resolutions

  • src/networking.c: git had placed the incoming hunk after the while loop in processIOThreadsReadDone, where c is out of scope. I applied the new condition and comment to the existing if (c->argc > 0) inside the loop and kept HEAD's trailing processClientsCommandsBatch().
  • src/debug.c help text: kept only the two SET-CLOSE-AFTER-REPLY lines. The BIO-DRAIN lines on the incoming side were upstream context for a subcommand 8.0 doesn't have.

Adaptations in code git merged without markers

  • src/debug.c handler: objectGetVal(c->argv[1]) became c->argv[1]->ptr, since objectGetVal doesn't exist on 8.0.
  • Test config override: io-threads-always-active yes became events-per-io-thread 0. The former doesn't exist on 8.0 and the server refused to start; the latter is what the 8.0 test harness uses.
  • Test tag: added external:skip. On 8.0 io-threads is immutable, so in external-server mode the override aborted the whole unit/protocol run, which would break the External Server Tests workflow.
  • Test comment: one line named consumeCommandQueue, which doesn't exist on 8.0; reworded to "the partial parse".

One discretionary addition

On 8.0 this bug is not a crash. Without the fix, the server executes the half-received command and drops its reply; a probe variant, *4 SET a b <partial>, actually wrote key a. The upstream test therefore passed 5 of 5 times on an unfixed 8.0 build.

To keep it a real regression test here, I added one assertion with a three-line comment: assert_equal [cmdrstat set r] {}. If you want the test strictly identical to upstream, delete those four lines; the fix it
... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit eed8daea7bbe.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5452

Ignore replica claims that would close a replicaof cycle

1 AI-edited file

Claude Summary

The conflict in src/cluster_legacy.c is resolved and no conflict markers remain. The resolved tree builds cleanly on 8.0 and the new test passes. I did not run git add or git commit, so the file still shows as UU and the cherry-pick is still in progress.

What I changed in src/cluster_legacy.c

  • Conflict region (before clusterProcessPacket): kept only the PR's new clusterReplicaChainReaches() helper. I dropped clusterExtractSlotFromWord(), which the incoming side dragged in as surrounding context; it isn't part of this PR and has no callers on 8.0.
  • Auto-merged guard inside clusterProcessPacket: the new log call used humanNodename(), which doesn't exist on 8.0. I replaced it with the ->human_nodename field, as the neighbouring 8.0 log lines do.
  • Log string wrapping: I re-split the new message's string literal so no line exceeds 120 columns. Upstream's two literal lines are 126 and 136 columns wide, which is allowed there (ColumnLimit: 0), but 8.0's src/.clang-format sets 120 and this file had no over-limit lines. The emitted message is byte-identical to upstream's; this costs one extra line.

tests/unit/cluster/replicaof-cycle.tcl is untouched and byte-identical to upstream. Every helper it uses exists on 8.0, and the cluster bus header layout it forges is identical on both branches.

The result is +194/−2 against upstream's +193/−2, and only the two in-scope files differ from 8.0.

Verification

All of this ran in a scratch copy outside the repo, which I have since deleted.

  • Build: compiles with -Werror and zero warnings.
  • New test: both cases pass, and passed 15 of 15 repeated runs.
  • Control without the fix: with 8.0's original cluster_legacy.c, the new test crashes the observer on primary->replicaof == NULL in clusterNodeGetPrimary(), the assertion the PR describes.
  • Related suites: 13 cluster suites (failover, manual failover, replica migration, shard-id propagation, packet, and others
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 7f7311a56ac4.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

Opened #5696 into unstable with a fix for test-almalinux8-jemalloc (run). Backport it to 8.0 once it merges.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

Opened #5699 with a fix for test-ubuntu-latest (run): 868cd01.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

#5526 fixes test-valgrind-test (run). Backport it to 8.0.

It also fixes test-valgrind-no-malloc-usable-size-test.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

#5702, open on unstable, fixes test-sanitizer-address (run). Backport it to 8.0 once it merges.

shohamazon and others added 8 commits December 2, 2026 09:05
…5417)

During dual-channel sync, once the replica's local buffer is full it
stops reading the main channel. If the primary drops that channel, the
replica doesn't notice. It replays the rest of its local buffer, which
can be gigabytes, into a sync that is already dead, reports success, and
sends `REPLCONF ACK` on a broken link.

This change checks the primary connection in `streamReplDataBufToDb()`
before each buffered block is applied, and after each
`replStreamProgressCallback()` call while a compressed block is decoded,
since that callback is the only I/O in the loop. If the connection is
broken, the replica aborts the sync and reconnects.

The buffered writes that haven't been applied yet are discarded rather
than applied. This matches the existing abort when the main channel is
lost while buffering (`readIntoReplDataBlock`): without the link the
replica can't complete or acknowledge the sync, and it resyncs once it
reconnects.

---------

Signed-off-by: Shoham Elias <shohame@amazon.com>
Signed-off-by: Shoham Elias <116083498+shohamazon@users.noreply.github.com>
Co-authored-by: Amit Nagler <58042354+naglera@users.noreply.github.com>
Backport-Source-PR: 5417
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
This PR fixes a use-after-free in the handling of
`CLUSTERMSG_EXT_TYPE_FORGOTTEN_NODE` cluster-bus PING extensions.

A cluster node can use this extension to tell its peers that another
node has been forgotten. However, the receiver did not check whether the
node named in the extension was also the sender of the message currently
being processed.

In that case, `clusterDelNode()` deleted the sender and freed its active
cluster link and receive buffer. The extension handler then continued
processing the same message and later accessed the now-freed sender and
link. This could cause memory corruption and crash the server.

### How is it fixed?

A node should not be able to legitimately announce that it has forgotten
itself. The handler now treats this as an invalid cluster-bus message:
- Logs a warning.
- Closes the malformed connection.
- Returns immediately without deleting the sender or continuing to
process the packet.

This preserves the existing behavior for valid forgotten-node
extensions.

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Backport-Source-PR: 4675
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Fixes #5439 #5458

A node can crash on `debugServerAssert(primary->replicaof == NULL)` in
`clusterNodeGetPrimary()`, reached through `updateShardId()` from
`clusterProcessPacket()`.

A node that resumes after a long pause handles a backlog of old gossip:

1. An old packet from R12 says it replicates R15, so the node sets
`R12->replicaof = R15`. The node never learns that R12 became a primary.
2. A newer packet from R15 says it replicates R12. R15 was last seen as
a replica, so this goes through the unguarded "Primary node changed for
this replica?" block, which sets `R15->replicaof = R12`.
3. Now R12 and R15 replicate each other, and the next `updateShardId()`
asserts.

Skip a replica claim, and log it at NOTICE, when the claimed primary's
`replicaof` chain already reaches the sender. The claimed primary's own
packet then corrects the view.

- No node is promoted on another node's word, which was the objection to
assertion from #651 is unchanged.
- The check walks the whole chain, so it also catches longer loops such
as A → B → C → A. The walk stops after as many steps as there are nodes,
so it ends even if the chain already contains a loop.

New `tests/unit/cluster/replicaof-cycle.tcl` sends forged replica-claim
PINGs, as in `failover-nack.tcl`, to create 2-node and 3-node loops on
an observer node.

This PR stops new replicaof cycles from forming at runtime. It does not
handle a cycle that is already saved in `nodes.conf`. A release build
without debug asserts can save one, because this same bug goes unchecked
there.

The risk if such a file is loaded: `clusterLoadConfig()` restores the
links without checking them. With A ↔ B loaded, a claim from another
node C naming A links C under the cycle. `clusterNodeGetPrimary(C)` then
never returns, and the node hangs at 100% CPU. This behaves the same on
`unstable`, so this PR does not make it worse.

1. **Should it be handled in this PR or in a follow-up?**
2. **Repair or reject at load?**
- **Repair:** unlink one node in each cycle, never `myself`, log a
WARNING and save the config. That node stays a replica with no known
primary until its own packets correct the view. Nodes that saved a cycle
on an older build keep starting. This matches how the loader already
fixes a mismatched replica shard_id instead of aborting.
- **Reject:** fail to start with "corrupted cluster config file". This
is stricter, since the file alone can't tell which link is stale. The
cost is that an affected node needs its `nodes.conf` fixed by hand
before it can restart, including after an upgrade.

Signed-off-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Backport-Source-PR: 5452
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…t has stale argc (#3245)

Found while reading the code — I have not yet been able to confirm
whether this path can materialize in existing real-world scenarios.

When an IO thread reads from a client with READ_FLAGS_DONT_PARSE set
(because canParseCommand returns 0), processIOThreadsReadDone skips
handleParseResults but still checks c->argc > 0 and sets pending_command
= 1. However, argc may be stale from a previous incomplete pipelined
command parse — it was set by consumeCommandQueue when
handleParseResults returned PARSE_NEEDMORE, and was never cleared.

This leads to processCommand being called with parsed_cmd == NULL and
without READ_FLAGS_COMMAND_NOT_FOUND, triggering the assertion:

==> server.c:4177 'c->read_flags & READ_FLAGS_COMMAND_NOT_FOUND' is not
true

1. IO thread parses pipelined commands; the last command is incomplete →
cmd_queue entry has argc > 0, parsed_cmd = NULL
2. Main thread consumeCommandQueue pops the incomplete entry → c->argc >
0, c->parsed_cmd = NULL
3. handleParseResults returns PARSE_NEEDMORE → loop breaks, stale argc
remains on the client
4. An external event makes canParseCommand return 0 for this client
(e.g. close_after_reply, close_asap, or application-specific blocking
flags)
5. New data arrives → trySendReadToIOThreads sets READ_FLAGS_DONT_PARSE
6. IO thread reads data, skips parsing
7. processIOThreadsReadDone: stale argc > 0 → pending_command = 1
8. processCommand: parsed_cmd == NULL, COMMAND_NOT_FOUND not set →
assertion crash

In processIOThreadsReadDone, when DONT_PARSE is set and argc > 0, skip
the client. The argc is stale from a previous incomplete parse — the IO
thread didn't parse anything new, so there is no valid command to
execute.

Added DEBUG SET-CLOSE-AFTER-REPLY <client-id> subcommand and a test that
reproduces the crash deterministically:
1. Client sends a complete PING + incomplete SET (truncated value) in
one pipeline
2. After PING reply confirms the incomplete parse was consumed (stale
argc), DEBUG SET-CLOSE-AFTER-REPLY is called from another connection to
simulate the external event
3. Client sends remaining data → triggers the DONT_PARSE path → crash on
unfixed server

---------

Signed-off-by: Arad Zilberstein <aradz@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Backport-Source-PR: 3245
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…ue (#5476)

In check mode, rdbLoadCheckModuleValue() walks a module value's opcodes until
RDB_MODULE_OPCODE_EOF, but the opcode chain had no final branch. An RDB cut
between two fields inside a module value made rdbLoadLen() return RDB_LENERR
forever, so valkey-check-rdb, and server startup on a truncated RDB, hung at
100% CPU.

Report a short read on RDB_LENERR and corruption on any other unknown opcode,
and stop the loop.

Backport-Source-PR: 5476
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
SWAPDB changes what clients read from both databases, but tracking
clients get no invalidation and keep stale cached values.
Send the same invalidation FLUSHDB does, to all tracking clients, since
the tracking table doesn't store a key's database.

---------

Signed-off-by: Kyuwon Jeong <jkw5033@gmail.com>
Backport-Source-PR: 5690
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…5611)

Fixes #5608.

`lookupStringForBitCommand()` creates or zero-pads the string before the
BITFIELD ops run, but `dirty` was only turned into `changes` inside the
branch that actually writes. If every write fails with `OVERFLOW FAIL`,
`changes` stays 0, so nothing is propagated and the key exists on the
primary but not on the replica or in the AOF.

This counts the creation/growth as one change in that case, the same way
SETBIT treats `dirty`. The command is propagated as is, and the replica
ends up with the same zero-padded string.

Side effects: a fully rejected BITFIELD that creates or grows the key
now behaves like SETBIT does. It fires the `setbit` keyspace event,
invalidates WATCH and client tracking on the key, and bumps `dirty`.

Tests in `tests/unit/bitfield.tcl`: the replication block covers a new
key and a grown key, plus a WATCH test (EXEC used to return PONG there,
now nil), and a new `appendonly yes` block checks the created key
survives `DEBUG LOADAOF`. All three fail without the bitops.c change and
pass with it:

```
./runtest --single unit/bitfield
```

`unit/bitops` and `unit/pubsub` also pass.

---------

Signed-off-by: xhon-pelushi <xhon@pelushi.com>
Backport-Source-PR: 5611
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops
valkeyrie-ops Bot force-pushed the agent/backport/sweep/8.0 branch from ffcc415 to 979c514 Compare December 2, 2026 09:09
YueTang-Vanessa and others added 2 commits December 3, 2026 09:06
### Description
User data logged when crash caused by moduleRDBLoadError.

### Change
Redact user data when hide-user-data-from-log enabled.

Signed-off-by: VanessaTang <yuetan@amazon.com>
Backport-Source-PR: 2274
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
When using XREAD STREAMS <stream> + on an empty stream created with
MKSTREAM, valkey returns an error instead of nil.

This happens because is missing a check on the stream length.

The fix adds the length check on the condition.

Fixes #2728

Signed-off-by: diego-ciciani01 <diego.ciciani@gmail.com>
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Backport-Source-PR: 2742
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #2742

Fix XREAD returning error on empty stream with + ID

1 AI-edited file

Claude Summary

The conflict in src/t_stream.c is resolved and no conflict markers remain. Nothing was staged or committed; the cherry-pick is still in progress for you to continue.

Resolution

There was one conflict, inside xreadCommand() in the branch that handles the + ID. The PR adds a stream-length check there, but it uses objectGetVal(o), which does not exist on 8.0. I kept the PR's check and used 8.0's o-&gt;ptr accessor instead:

-            if (o) {
+            if (o &amp;&amp; ((stream *)o-&gt;ptr)-&gt;length) {
                 stream *s = o-&gt;ptr;

The result is 1 insertion and 1 deletion against 8.0, the same size as the upstream commit. No other files were edited.

Verification

  • Build: the incremental build of valkey-server passes with the tree's existing flags, including -Werror.

  • Before/after: I compared the pre-fix 8.0 binary with the rebuilt one on scratch servers:

    Case Before After
    XREAD STREAMS s + on an empty MKSTREAM stream ERR the stream last element ID is 0-0 nil
    Same stream mixed with a non-empty one (+ +) same error the non-empty stream's last entry
    XREAD BLOCK … + on the empty stream same error blocks, then returns the entry added by a later XADD
    Non-empty stream, emptied stream, missing key unchanged unchanged
    XREADGROUP … + "meaningless" error same error
  • Existing tests: unit/type/stream and unit/type/stream-cgroups pass.

The build and test runs only touched git-ignored artifacts; src/valkey-server is now rebuilt from the resolved source.

AI-edited files requiring review

Full backport commit diff: commit 03e0792fceea.

Please review these AI resolutions for correctness before merging.

li-benson and others added 6 commits December 3, 2026 18:28
…mary after direct writes of keys with expiration (#2953)

The bug mentioned in this
#2952 has been fixed.

---------

Signed-off-by: li-benson <1260437731@qq.com>
Backport-Source-PR: 2953
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…onfigured (#2846)

When dual-channel-replication is enabled, and replica-announce-ip is
set, the RDB/AOF channel does not announce itself at this endpoint. This
defaults to the IP address behind the NAT, or the Kubernetes Pod IP in
our case.

This means that if Sentinel is polling the primary for connected
replicas, it will first see the ephemeral pod IP, then revert to the
announce-ip - leaving behind the pod IP as a down replica.

This PR configures the RDB/AOF channel to also announce itself at the
announce-ip to prevent the stale replica.

I evaluated writing unit tests for this, but I am not sure of a way we
can test an IP address different to localhost (127.0.0.1) that would
fail without the fix. I did test on Kubernetes against 9.0 tag and
verified the fix there too.

On 9.0 image tag:

```
$ kubectl get pods -n valkey-baseline -o custom-columns=NAME:.metadata.name,POD-IP:.status.podIP
NAME                              POD-IP
valkey-primary-5bd78c8566-llb6k   10.244.0.25
valkey-replica-0                  10.244.0.17
valkey-replica-1                  10.244.0.13

$ kubectl get services -n valkey-baseline -o custom-columns=NAME:.metadata.name,CLUSTER-IP:.spec.clusterIP
NAME               CLUSTER-IP
valkey-primary     10.96.147.28
valkey-replica-0   10.96.66.233
valkey-replica-1   10.96.57.230
```

Logs below show that pod IP for valkey-primary-5bd78c8566-llb6k
`10.244.0.25:6379` is being used for dual-channel replication. This
should be its cluster IP `10.96.147.28` as this is what is set in
replica-announce-ip.

```
1:M 14 Nov 2025 17:57:51.750 * Replica 10.96.147.28:6379 asks for synchronization
1:M 14 Nov 2025 17:57:51.751 * Replica 10.244.0.25:6379 asks for synchronization
1:M 14 Nov 2025 17:57:56.135 * Dual channel replication: Sending to replica 10.244.0.25:6379 RDB end offset 1763269 and client-id 35
1:M 14 Nov 2025 17:57:56.140 * Replica 10.96.147.28:6379 asks for synchronization
```

```
$ kubectl get pods -n valkey-test -o custom-columns=NAME:.metadata.name,CLUSTER-IP:.status.podIP
NAME                              POD-IP
valkey-primary-594c9597b5-qqvdk   10.244.0.26
valkey-replica-0                  10.244.0.10
valkey-replica-1                  10.244.0.18

$ kubectl get services -n valkey-test -o custom-columns=NAME:.metadata.name,CLUSTER-IP:.spec.clusterIP
NAME               CLUSTER-IP
valkey-primary     10.96.125.142
valkey-replica     None
valkey-replica-0   10.96.155.74
valkey-replica-1   10.96.64.111
valkey-sentinel    None
```

Logs show that the Cluster IP is now being used for dual-channel
replication.

```
1:M 14 Nov 2025 17:57:49.923 * Replica 10.96.125.142:6379 asks for synchronization
1:M 14 Nov 2025 17:57:49.924 * Replica 10.96.125.142:6379 asks for synchronization
1:M 14 Nov 2025 17:57:54.913 * Dual channel replication: Sending to replica 10.96.125.142:6379 RDB end offset 1771247 and client-id 36
1:M 14 Nov 2025 17:57:54.916 * Replica 10.96.125.142:6379 asks for synchronization
```

Fixes #2338

Signed-off-by: Joseph Heyburn <jdheyburn@gmail.com>
Backport-Source-PR: 2846
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…igs (#3440)

rewriteConfigFormatMemory() and rewriteConfigBytesOption() used long long
parameters to represent memory bytes, but configs like maxmemory are stored
as unsigned long long and allow values up to ULLONG_MAX.

When the value exceeds LLONG_MAX (e.g. 9223372036854775808), it overflows to
negative when passed as long long, causing config rewrite to produce incorrect
output like "maxmemory -8589934592gb".

Change both functions to use unsigned long long, matching the actual semantics
of memory byte values. This is consistent with how numericConfigGet() already
handles MEMORY_CONFIG using ull2string().

There are some MEMORY_CONFIG are signed and can be negative:
1. maxmemory-clients is a PERCENT_CONFIG
2. slot-migration-max-failover-repl-bytes is a SIGNED_MEMORY_CONFIG (after #3443)

None of them were affected:
```
static void numericConfigRewrite(standardConfig *config, const char *name, struct rewriteConfigState *state) {
    ...
    if (config->data.numeric.flags & PERCENT_CONFIG && value < 0) {
        rewriteConfigPercentOption(state, name, -value, config->data.numeric.default_value);
    } else if (config->data.numeric.flags & SIGNED_MEMORY_CONFIG && value < 0) {
        rewriteConfigNumericalOption(state, name, value, config->data.numeric.default_value);
    } else if (config->data.numeric.flags & MEMORY_CONFIG) {
        rewriteConfigBytesOption(state, name, value, config->data.numeric.default_value);
    ...
```

Signed-off-by: Binbin <binloveplay1314@qq.com>
Backport-Source-PR: 3440
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…3583)

Backport-Source-PR: 3583
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Fixes server crash when RDMA benchmark clients disconnect (part of

This PR focuses on the server-side crash fix. The benchmark
client-side fix will be submitted in a separate PR.

​ When interrupting valkey-benchmark with Ctrl+C, the server would crash
with a segmentation fault in handleReadResult, accessing address 0x8
(NULL pointer dereference).

The same RDMA connection could be added to pending_list multiple times,
leading to use-after-free:

1. When a client disconnects, rdmaHandleDisconnect() adds the connection
to pending_list and sets conn->state = CONN_STATE_CLOSED
2. Before rdmaProcessPendingData() processes it, event-driven callbacks
(e.g., connRdmaSetWriteHandler) could add the same connection again to
pending_list
3. In rdmaProcessPendingData(), the first iteration processes and may
free the connection, but the second iteration accesses the already freed
connection → SIGSEGV at address 0x8 (NULL + offset)

The problem was exacerbated because:

  - valkey-benchmark creates multiple concurrent connections
  - On Ctrl+C, these connections disconnect nearly simultaneously
  - Event callbacks can re-add connections before processing completes

 **Stack trace from crash:**

  	handleReadResult+0x100
  	readQueryFromClient+0x63
  	rdmaProcessPendingData (0x1b1eb9)
  	beforeSleep+0x82

 Four targeted fixes in `src/rdma.c`:

1. `rdmaHandleDisconnect (line 535)`: Check if pending_list_node is NULL
before adding to pending_list to prevent duplicates

   ```C
/* we can't close connection now, let's mark this connection as closed
state */
   if (rdma_conn->pending_list_node == NULL) {
       listAddNodeTail(pending_list, conn);
       rdma_conn->pending_list_node = listLast(pending_list);
   }
   ```

2. `connRdmaSetWriteHandler (line 956)`: Add same check before adding to
pending_list to prevent duplicates during write handler updates

   ```C
   /* does this connection has pending write data? */
   if (func) {
       if (rdma_conn->pending_list_node == NULL) {
           listAddNodeTail(pending_list, conn);
           rdma_conn->pending_list_node = listLast(pending_list);
       }
   } else if (rdma_conn->pending_list_node) {
       listDelNode(pending_list, rdma_conn->pending_list_node);
       rdma_conn->pending_list_node = NULL;
   }
   ```

3. `rdmaProcessPendingData (line 1786)`: Use iterator node 'ln' instead
of rdma_conn->pending_list_node when deleting, as the latter may have
been overwritten if the connection was re-added

   ```C
listDelNode(pending_list, ln); // Use ln, not
rdma_conn->pending_list_node
   rdma_conn->pending_list_node = NULL;
   ```

4. `rdmaProcessPendingData (line 1782-1787)`: Reorder operations to call
handlers before deleting from list, ensuring connection structure
remains valid during handler execution

   ```C
if (conn->state == CONN_STATE_ERROR || conn->state == CONN_STATE_CLOSED)
{
       /* Invoke handlers first, then remove from list */
       if (callHandler(conn, conn->read_handler)) {
           callHandler(conn, conn->write_handler);
       }

       listDelNode(pending_list, ln);
       rdma_conn->pending_list_node = NULL;

       ++processed;
       continue;
   }
   ```

The fix uses **pending_list_node** as both a list pointer and a
"**already in list**" flag:

  - NULL = not in list, safe to add
  - non-NULL = already in list, skip adding

This ensures each connection appears in pending_list at most once,
preventing use-after-free crashes.

Signed-off-by: Ada-Church-Closure <nunotabashinobu066@gmail.com>
Backport-Source-PR: 3448
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4140

Retry PSYNC on -BUSY error instead of downgrading to SYNC

4 AI-edited files

Claude Summary

All four conflicts are resolved with no markers left, and the result builds and passes its tests on 8.0. Nothing was staged or committed; the cherry-pick is still in progress for you to continue.

The resolved diff is the same size as upstream, file for file: 95 insertions and 16 deletions across 7 files.

Resolutions

  • src/debug.c (two conflicts in debugCommand()): added the PAUSE-BEFORE-PSYNC help entry and the pause-before-psync handler. The handler uses 8.0's c-&gt;argv[N]-&gt;ptr, since objectGetVal() does not exist on this branch. I left 8.0's existing DELAY-RDB-CLIENT-FREE-SECOND help text alone; the upstream spelling fix belongs to a different commit.
  • src/server.h (in struct valkeyServer): kept 8.0's block and added only debug_pause_before_psync, aligned to the local comment column. The upstream side also carried reformatting and five bio-thread fields that are not part of this PR.
  • src/replication.c: this hunk was mis-anchored. Upstream adds the debug hook to syncWithPrimaryHandleSendPsyncState(), which does not exist on 8.0, so git placed four upstream-only functions into the tail of setupMainConnForPsync(). I kept HEAD there and put the hook in the REPL_STATE_SEND_PSYNC block of 8.0's syncWithPrimary(), immediately before PSYNC is sent. The -BUSY change itself had auto-merged correctly into replicaTryPartialResynchronization().
  • tests/integration/dual-channel-replication.tcl: kept 8.0's get_client_id_by_last_cmd, removed the local idx-based wait_process_paused (the PR moves it to util.tcl taking a pid), and updated the call site to wait_process_paused [srv -1 pid]. I kept 8.0's 100 100 log-wait arguments on the next line.

The three auto-merged files (src/server.c, tests/support/util.tcl, the new test) needed no adaptation.

Verification

  • Build: rebuilt with the tree's existing settings (-Werror, TLS, libc malloc) with zero warnings.
  • Formatting: clang-format reports no ne
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 8b65e4f58874.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4380

Resolve a key's slot from the key, not from the executing command

5 AI-edited files

Claude Summary

All five conflicted files are resolved with no conflict markers left; nothing was staged or committed, and no other files were touched. The result is 101 insertions / 19 deletions against upstream's 87 / 24.

What was resolved

  • src/db.c: kept 8.0's dict-based function bodies and applied only the slot-helper changes.
    • getKVStoreIndexForKey() now hashes the key itself.
    • New getKVStoreIndexUsingCachedSlot() is used by the same functions as upstream: lookupKey, dbAddInternal, dbSetValue, removeExpire, setExpire.
    • getKeySlot() is renamed getCachedKeySlot().
  • src/server.h, src/pubsub.c, src/sort.c: only the rename, in 8.0's -&gt;ptr style.
  • tests/unit/cluster/misc.tcl: the three new WATCH tests now sit in their own start_cluster 1 1 block. Git had dropped them into an unrelated tags {…} block outside any server, because upstream's host block ("Cross-slot transaction") doesn't exist on 8.0.

Where 8.0 differs from upstream

  1. lookupKey() resolves the cached slot once and passes it to dbFindWithDictIndex / expireIfNeededWithDictIndex. On 8.0 it previously went through dbFind() and expireIfNeeded(), which now hash the key; this keeps the hot path on the cached slot as upstream does. It needed one forward declaration.
  2. deleteExpiredKeyAndPropagate() is kept. Upstream deleted it as dead code, but src/expire.c still calls it on 8.0.
  3. The two index helpers stay static in db.c rather than being declared in server.h, matching how 8.0 already treats getKVStoreIndexForKey.
  4. getKVStoreIndexForKey() still backfills c-&gt;slot for the primary client — this is the one addition beyond upstream's diff, so please look at it.
    • On 8.0 a replicated command's slot is only set by that backfill (9.0+ compute it at parse time).
    • Without it, the existing test CLUSTER SLOT-STATS metrics replication for deleting keys fails, because a replicated DEL no longer reaches the backfill.
      ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 665700c9c133.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4877

Block DEBUG RELOAD and DEBUG LOADAOF in loading and async-loading

1 AI-edited file

Claude Summary

The conflicts in src/debug.c are resolved: both DEBUG RELOAD and DEBUG LOADAOF now return the loading error when the server is loading or async-loading, as in the source PR.

Conflicts. Both regions sit inside the else if chain of debugCommand(), at the top of the reload branch (src/debug.c:556) and the loadaof branch (src/debug.c:607). The conflict was only on the condition line: upstream writes objectGetVal(c-&gt;argv[1]), which does not exist on 8.0. I kept 8.0's c-&gt;argv[1]-&gt;ptr line and added the PR's guard beneath it in each branch.

Verification.

  • No conflict markers and no objectGetVal references remain in the file.
  • server.loading, server.async_loading, shared.loadingerr and addReplyErrorObject() all exist on 8.0, and the same guard is already used by DEBUG POPULATE in this file.
  • The diff against HEAD is 10 insertions and 0 deletions, the same size as the upstream commit.
  • A gcc -fsyntax-only pass over src/debug.c with the project's warning flags was clean. That is a syntax check of the libc-malloc variant only; I did not run a full build or the test suite.

No other files were edited, and nothing was staged or committed. The untracked src/commands_with_reply_schema.def was already there and is untouched.

AI-edited files requiring review

Full backport commit diff: commit 68fd7542c72a.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5141

Don't block CLUSTER SETSLOT on replica acks when the client cannot block

1 AI-edited file

Claude Summary

The conflict in tests/unit/cluster/slot-migration.tcl is resolved and no conflict markers remain; I did not run git add or git commit, so the file still shows as unmerged (UU).

Resolution

  • Structure: the conflict sat at the end of the start_cluster 3 3 block that holds the "CLUSTER SETSLOT with invalid timeouts" test.
  • Cause: upstream's side carried a neighbouring test, "CLUSTER SETSLOT MIGRATING/IMPORTING should not be allowed to target self", which comes from a different change. 8.0 has no Target node is myself check in src/, so that test would fail here.
  • What I kept: 8.0's content plus only the PR's new test, "CLUSTER SETSLOT inside MULTI does not block on replicas", placed inside that same block.
  • src/cluster_legacy.c: the auto-merged change needed no adaptation. c-&gt;flag.deny_blocking, forceCommandPropagation and blockClientForReplicaAck all exist on 8.0.
  • Size: the result matches upstream exactly — 6 added / 1 removed in src/cluster_legacy.c, 8 added in the test file.

Verification (done in a scratch copy under /tmp, since removed, so nothing else in the worktree was touched)

  • The fix compiles on 8.0 with no warnings.
  • With the fix, the full unit/cluster/slot-migration file passes, all 18 tests including the new one.
  • Without the C change, the new test crashes the primary with multi.c:233 'c-&gt;flag.blocked == 0' is not true, which is the failure the PR describes.

The untracked src/commands_with_reply_schema.def was already there before I started and I left it alone.

AI-edited files requiring review

  • tests/unit/cluster/slot-migration.tcl — view diff

Full backport commit diff: commit 5ac6672607bd.

Please review these AI resolutions for correctness before merging.

madolson and others added 13 commits December 3, 2026 21:31
CONFIG REWRITE writes the REPLICAOF host into the config file unquoted,
and REPLICAOF accepts any host string. A host containing a newline turns
into several lines in the file, so on the next start the server
replicates from a truncated host and loads whatever followed the newline
as config directives, including file-only settings like
`enable-module-command`. The fix writes the host through `sdscatrepr()`,
as every other string option already does, so it reads back as one
argument.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Backport-Source-PR: 5176
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
`MurmurHash64A()` takes the element length as an `int`, but PFADD passes
a `size_t`. For an element of 2^31 bytes or more, the length goes
negative and the end pointer lands before the start of the element. The
hash loop then reads past the element until the server segfaults. Taking
the length as `size_t` fixes this. The hash is unchanged for every
element shorter than 2^31 bytes, so existing HyperLogLogs keep their
meaning.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Backport-Source-PR: 5132
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
While a forked `SCRIPT DEBUG` session is open, `serverCron()` never
evaluates the `save` points or the automatic AOF rewrite, so a client
that opens a debug session and goes idle stops automatic RDB snapshots
and AOF compaction until it disconnects. The save-point checks sit in
the `else` of the branch that reaps finished children, and that branch
also fires whenever a debugging child is pending. This change still
reaps debugging children, but no longer lets them on their own postpone
the save points.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Backport-Source-PR: 5153
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…5379)

Skip crash memory test under valgrind

Signed-off-by: Jim Brunner <brunnerj@amazon.com>
Backport-Source-PR: 5379
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Fixes #5515 #5516

`Replica aborts streaming when the primary link breaks mid-stream` (both
`repl-compression no` and `lz4`) fails in daily valgrind job

The test holds the replica's RDB load with `key-load-delay 10000`, which
is a fixed ~200 s of wall-clock time. During the hold, the primary
buffers 4000 `SUNIONSTORE`s of a 10k-member set. Under valgrind those
unions took 24-40 min, so:

- the load ended on its own first, and the test failed at `assert_equal
1 [s 0 loading]`, or
- the flood alone ran past the 2400 s test timeout (lz4), which ends the
whole valgrind job.

With lz4 there is a second problem. The replica checks the link once per
1 MB decoded (`REPL_DECODE_EVENT_BUDGET`). With a 4 KB key name, each
round holds ~250 slow unions, so under valgrind the abort is logged
after the 10 s wait has expired.

Scale the flood (set size, command count, and key-name length) to the
build the test runs on, valgrind or native, so it stays short on both.
The assertions are unchanged.

| | Native | Valgrind |
|---|---|---|
| Before | 11-14 s | fails (24-40 min flood on CI) |
| After | ~12.5 s | ~25 s |

Signed-off-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Backport-Source-PR: 5526
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Followup for #5452

An older version could save a replicaof cycle (A -> B -> A) to
nodes.conf from stale gossip. A later replica claim naming a node in the
cycle as its primary then makes clusterNodeGetPrimary() loop forever.

The file alone can't tell which link is stale, so fail to start with a
corrupted config error.

Signed-off-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Backport-Source-PR: 5556
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Clamp used_memory_dataset (used_memory - used_memory_overhead) at 0 instead
of letting the size_t subtraction wrap when the overhead is larger.

Backport-Source-PR: 5644
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…2933)

The node ids returned by `ValkeyModule_GetClusterNodesList` are not null
terminated, but fixed-length buffers. When these are passed to
`ValkeyModule_GetClusterNodeInfo`, which until now required the node id
to be null terminated, the node lookup failed or potentially caused
undefined behavior when `strlen` read outside of allocated memory.

This error can be seen in the example module hellocluster.c included in
this repo.

This commit changes `ValkeyModule_GetClusterNodeInfo` and
`ValkeyModule_GetClusterNodeInfoForClient` to assumes the node id to be
exactly 40 bytes long and does not require it to be null terminated.
It's not a breaking change, since passing a valid null-terminated node
id still works as expected.

---------

Signed-off-by: Deepak Nandihalli <deepakrn@users.noreply.github.com>
Signed-off-by: Deepak Nandihalli <deepak.nandihalli@gmail.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Backport-Source-PR: 2933
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…OFF (#5682)

On $ENDOFF, dualChannelReplHandleEndOffsetResponse() starts the PSYNC
handshake on the main link with dualChannelSetupMainConnForPsync(). If a
write on the main link fails there, that function calls
cancelReplicationHandshake(), which aborts the whole dual channel sync:
the RDB channel is closed, repl_rdb_transfer_s is NULL and
repl_rdb_channel_state is NONE. The caller then set a read handler on
the NULL repl_rdb_transfer_s and the replica crashed with SIGSEGV.

Return C_RETRY when the RDB channel state is NONE after the main channel
setup. C_ERR cannot be used: the error path would abort the sync a
second time and replicationAbortDualChannelSyncTransfer() asserts that a
sync is in progress.

Add an integration test with a fake primary that resets the main link
after +DUALCHANNELSYNC and then sends a valid $ENDOFF on the RDB
channel.

---------

Signed-off-by: Eran Liberty <eran.liberty@gmail.com>
Co-authored-by: valkey-review-bot[bot] <282604435+valkey-review-bot[bot]@users.noreply.github.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Backport-Source-PR: 5682
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Sanitize CR/LF in FUNCTION LIST's error reply for an invalid argument, so it can't break the RESP stream.

Backport-Source-PR: 5369
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Fixes #4935

- AOF rewrite and `CLUSTER MIGRATESLOTS` rebuild consumer-group PELs as
`XCLAIM FORCE JUSTID`. That command skipped IDs whose stream entry was
already `XDEL`'d / trimmed, so pending ownership and delivery counts
diverged from the source.
- Keep the live XCLAIM cleanup (`nack != NULL` still drops a dangling
PEL entry). Only an obeyed `FORCE JUSTID` with an empty PEL (AOF client,
slot import, replica) may recreate the NACK.

Signed-off-by: quanyeyang <quanyemostima@gmail.com>
Backport-Source-PR: 4973
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4973

Fix AOF/slot-migration dropping deleted stream PEL entries

1 AI-edited file

Claude Summary

The conflicts in src/t_stream.c are resolved and no conflict markers remain; nothing has been staged or committed.

All three conflict regions were in xclaimCommand or its doc comment, and I took the PR's side in each:

  • FORCE doc comment: now uses the PR's wording.
  • Existence check in the claim loop: uses the PR's exists variable. A dangling PEL entry is still dropped, and only an obeyed FORCE JUSTID (mustObeyClient, which exists on 8.0) may recreate a NACK for a deleted ID.
  • Non-JUSTID reply branch: adds the PR's serverAssert(exists).

The only branch adaptation was replacing objectGetVal(o) with o-&gt;ptr, since that accessor doesn't exist on 8.0. One of those was on an auto-merged line outside the markers, so it would have broken the build if left.

tests/unit/type/stream-cgroups.tcl needed no changes: the new test landed in the same appendonly yes server block as upstream and uses helpers already used by its sibling test.

I verified in a scratch copy outside the repo, which I've since removed:

  • Build: the resolved tree compiles cleanly.
  • Tests: ./runtest --single unit/type/stream-cgroups passes, including the new AOF rewrite test.
  • Bug present on 8.0: against the unfixed 8.0 source the new test fails (Expected '2' to be equal to '1'), so the backport is needed here.

The resolved diff is the same size as upstream: 9 insertions and 10 deletions in src/t_stream.c, plus the 25-line test.

I kept the PR's comment text verbatim, so two comments say "AOF/slot replay" even though 8.0 has no atomic slot migration. On this branch the exception covers the AOF client and the primary link. Say if you'd rather have them reworded to "AOF/replication".

AI-edited files requiring review

Full backport commit diff: commit 835db3b101d4.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5132

Hash HyperLogLog elements with a size_t length

2 AI-edited files

Claude Summary

Both conflicts are resolved in place, with no conflict markers left and nothing staged or committed. The change against 8.0 is the same size as the upstream PR: 1 line changed in src/hyperloglog.c and 8 lines added in tests/unit/hyperloglog.tcl.

src/hyperloglog.c

tests/unit/hyperloglog.tcl

  • Upstream puts the new test in a separate start_server {tags {"hll large-memory"}} block. 8.0 has a single hll server block and tags the CVE test at test level with {} {large-memory}.
  • I kept 8.0's structure and added the new test right after the CVE test, closing it with } {} {large-memory} so it only runs under --large-memory, as it does upstream. The test body is otherwise identical to upstream.
  • I dropped the extra closing brace from the upstream side. It closes a server block that does not exist on 8.0 and would have left the remaining 28 tests outside any server.

Verification (built and run in a scratch copy outside the repo, since removed)

  • Build: the resolved file compiles with no warnings under the settings the existing build used (-Werror -DLOG_REQ_RES, TLS, libc malloc).
  • Normal mode: unit/hyperloglog passes; the new test is skipped with "large memory flag not provided".
  • With --large-memory: all 30 tests pass, including the new 2 GiB PFADD test and everything that runs after it in the same server.
  • Negative control: against a build of unmodified 8.0 code, the new test crashes the server with a segfault in MurmurHash64A called from pfaddCommand.

One judgement call: on 8.0 the new test shares its server with the rest of the HLL tests, so under --large-memory the raised proto-max-bulk-len and client-query-buffer-limit stay in effect for the later tests. I di
... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit d0cd3702548f.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5153

Do not let forked script debug sessions postpone automatic saves

1 AI-edited file

Claude Summary

The conflict in src/server.c is resolved and no conflict markers remain. Nothing was staged or committed, so src/server.c still shows as unmerged until you git add it.

The conflict: there was one conflict region, inside serverCron(), at the "Check if a background saving or AOF rewrite in progress terminated" block. I kept the PR's restructuring and swapped in the 8.0 names for two helpers that don't exist on this branch:

Upstream 8.0 resolution Why
scriptingEngineDebuggerPendingChildren() ldbPendingChildren() The upstream name is not on 8.0; this is what HEAD's side of the conflict already called.
!hasActiveSaveOrChild() !hasActiveChildProcess() Upstream's helper also covers forkless saves, which 8.0 doesn't have.

The second check is not redundant on 8.0: checkChildrenDone() calls replicationStartPendingFork(), which can start a new child while reaping a debug session.

The test: tests/unit/scripting.tcl needed no adaptation. The auto-merged test sits in the same scope as upstream, and every helper and tag it uses exists on 8.0.

Verification (done in a scratch copy, since removed, so the working tree only has the server.c edit):

  • The resolved tree builds cleanly with the tree's existing settings, including -Werror.
  • The new test passes with the fix and fails without it ("Save point did not fire while a forked debug session was open"), so the backport is needed on 8.0.
  • The full unit/scripting suite passes, as do integration/rdb, integration/aof and unit/other.
  • I did not run the suite in TLS mode.

The resulting change is the same size as the upstream PR: 28 insertions and 2 deletions across the two files. The untracked src/commands_with_reply_schema.def was already there before I started and I left it alone.

AI-edited files requiring review

Full backport commit diff: commit e1a97244570d.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5176

Quote the replicaof host when rewriting the config file

1 AI-edited file

Claude Summary

The conflict in tests/unit/introspection.tcl is resolved, and the backport is verified on 8.0: the new test passes with the fix and fails without it.

The conflict

The PR adds one test, CONFIG REWRITE keeps a replicaof host with a newline on one line, directly after CONFIG REWRITE handles large unsigned memory config values. On 8.0 that spot is followed by the sysfs short-read block from #5158; upstream it is followed by two tests for configs 8.0 doesn't have (slot-migration-max-failover-repl-bytes, hash-seed).

The resolution

  • New test: inserted at top level after the same anchor test as upstream, before the sysfs block.
  • 8.0's sysfs block: kept unchanged.
  • Upstream-only neighbours: the SIGNED MEMORY CONFIG… and CONFIG hash-seed… tests are dropped, since they were only surrounding context and not part of this PR.
  • src/config.c: the auto-merge needed no adaptation; sdscatfmt, sdscatrepr, server.primary_host and server.primary_port all exist on 8.0.

The result against 8.0 is 3+/1− in src/config.c and 12+ in the test file, with changed lines byte-identical to the upstream commit.

Verification

I built and tested in a scratch copy outside the repo, which I have since deleted.

  • Build: the patched tree compiles with -Werror and no warnings.
  • Full unit/introspection: 58 passed, 0 failed, including the new test and the sysfs test right after it.
  • Without the fix: with 8.0's original config.c, the new test fails as the PR describes — the host comes back as 127.0.0.1 1.

Repo state

No conflict markers remain, and only the two listed files differ from HEAD. I did not run git add or git commit, so the test file still shows as unmerged (UU) and the cherry-pick is still in progress.

AI-edited files requiring review

Full backport commit diff: commit b9be94f7a953.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5369

Sanitize FUNCTION LIST error replies

2 AI-edited files

Claude Summary

The conflict in src/functions.c is resolved, and the auto-merged test needed one adaptation to run on 8.0. Nothing is staged or committed; the cherry-pick is still in progress for you to continue.

What I changed

src/functions.c — the single conflict, in the argument-parsing loop of functionListCommand. I took the PR's switch to addReplyErrorSdsSafe but kept 8.0's next_arg-&gt;ptr, because objectGetVal does not exist on 8.0:

addReplyErrorSdsSafe(c, sdscatfmt(sdsempty(), "Unknown argument %s", next_arg-&gt;ptr));

addReplyErrorSdsSafe already exists on 8.0 and is identical to upstream's.

tests/unit/functions.tcl — this merged without markers but would have failed at runtime. The new test calls test_defer {$rd close}, and test_defer is not defined on 8.0. I replaced it with an explicit $rd close at the end of the test body, which is how the other tests in this file close extra clients. The client is no longer closed if an assertion fails mid-test, same as the neighbouring tests.

The resulting diff against HEAD is 2 files, 10 insertions, 1 deletion — the same as the upstream commit.

Verification

I built and tested in a throwaway copy outside the repo, since a plain make in place would have wiped the existing build artifacts. The copy is deleted and the working tree holds only the two edits.

  • Before the fix: the new test fails against the pre-fix binary with Expected 'ERR Unknown argument bad' to match '*Unknown argument bad +FAKE*', so it does detect the bug on 8.0.
  • Build: clean with the tree's recorded settings, including -Werror.
  • After the fix: unit/functions passes 114/114, including the new test.
  • --log-req-res --force-resp3 mode: also 114/114, and 8.0's reply-schema validator exits 0 over the resulting logs.
  • Markers: none remain in either file, and git diff --check is clean.

I ran only unit/functions, not the full test suite.

AI-edited files requiring review

Full backport commit diff: commit 07b8194bd6d9.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5526

Fix flaky dual-channel mid-stream abort test under valgrind

1 AI-edited file

Claude Summary

The conflict in tests/integration/dual-channel-replication.tcl is resolved, and the test passes on 8.0 both natively and under valgrind. Nothing is staged or committed, and no other file was touched.

What the conflict was

Git misplaced the hunk. The incoming side was the entire upstream test, wrapped in foreach compression {no lz4}, dropped into the unrelated replica-announce-ip block at the end of the file. The 8.0 copy of the test sits earlier in the file with no compression loop, because 8.0 has no repl-compression.

How I resolved it

  • Conflict site: kept the 8.0 side unchanged, so the replica-announce-ip block is byte-identical to before.
  • The real test (Replica aborts streaming when the primary link breaks mid-stream): applied the PR's three scaling changes at 8.0's indentation. The set size becomes $::valgrind ? 1000 : 10000, the key-name pad $::valgrind ? 64000 : 4000, and the command count $::valgrind ? 150 : 3000.
  • Comment: the first comment is upstream's text verbatim. In the second, I replaced the lz4 sentence with the 8.0 mechanism: the buffer streams in blocks, each followed by a link check, and the longer name keeps it at many blocks with fewer commands.

The result is +13/−7 against 8.0 (upstream was +13/−8). The non-comment lines are identical to upstream's apart from indentation, and $::valgrind already exists on 8.0.

Verification

All runs were in a scratch copy under /tmp, since removed.

Check Result
Whole file, native, default jemalloc build 43 ok, 0 failed
Whole file, native, existing libc-malloc build 43 ok, 0 failed
Target test alone, native 3/3 passes on each build, ~10 s on jemalloc and ~24 s on libc-malloc
Target test alone, under valgrind (make valgrind build of 8.0) 4/4 passes, ~28 s each
Old parameters under valgrind ~286 ms per union, so the 4000-command flood would take ~19 min against a ~200 s load hold

The last row confirms 8.0 has
... summary truncated.

AI-edited files requiring review

  • tests/integration/dual-channel-replication.tcl — view diff

Full backport commit diff: commit f7f3a403f1ac.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5556

Refuse to load a replicaof cycle from nodes.conf

1 AI-edited file

Claude Summary

The validation failed in the new test, not the build: tests/unit/cluster/replicaof-cycle.tcl called cluster_nodes_conf_path, which does not exist on 8.0. I adapted the test in place; the fix has not been run, since the caller re-runs validation.

The first real error is at line 508 of the log: invalid command name "cluster_nodes_conf_path". src/cluster_legacy.c compiled and linked cleanly, and the two earlier tests in the file passed.

Two more helpers used by the same test, read_file and write_file, are also missing on 8.0 and would have failed next. All three are replaced inline, only in tests/unit/cluster/replicaof-cycle.tcl:

  • cluster_nodes_conf_path $obs: now built from config get dir and config get cluster-config-file, the same way tests/unit/cluster/packet.tcl does on this branch.
  • read_file on nodes.conf: now a plain open / read / close.
  • write_file: now open ... w / puts -nonewline / close, so the copied nodes.conf keeps the same content.
  • read_file $logfile (two places): now exec cat $logfile, as tests/unit/cluster/misc.tcl does on this branch.

I inlined these rather than defining procs named read_file / write_file in the test file, so nothing collides if a later backport brings the real helpers to 8.0. src/cluster_legacy.c is unchanged, and the test's assertions are the same as in the source PR.

AI-edited files requiring review

  • tests/unit/cluster/replicaof-cycle.tcl — view diff

Full backport commit diff: commit 7adf80ab3db2.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5644

Prevent size_t underflow in used_memory_dataset calculation

1 AI-edited file

Claude Summary

The first real error was invalid command name "test_defer" in tests/unit/info.tcl: that helper does not exist on 8.0. I fixed it by rewriting the new test's setup, because swapping in an explicit close would only have exposed a second failure. Nothing has been run; the re-run of unit/info is the first check of this change.

Why a one-line fix was not enough: the source test gets overhead above used memory by having 12 clients subscribe to one 256 KB channel, relying on pubsubMemOverhead() charging the channel name to every subscriber. On 8.0 that function only counts dict entries and buckets, so the test would stop at "used_memory_overhead never exceeded used_memory".

What I changed (only tests/unit/info.tcl):

  • The test now lives in its own start_server block, started with a 4 MB primaryauth override.
  • It runs config set primaryauth "", which frees memory that is counted in the startup baseline, so overhead exceeds used memory by about 4 MB.
  • It asserts that precondition directly instead of polling.
  • The test name and the three assertions on the fix (used_memory_dataset, dataset.bytes, keys.bytes-per-key all 0) are unchanged from the source PR.
  • The existing rehashing test and its server block are untouched.

src/object.c needed no adaptation; the clamp applied cleanly and the build step passed.

The test setup now differs from unstable, which a reviewer should know. If you would rather not carry a branch-specific test, the alternative is to drop the test from this backport and keep only the object.c fix.

AI-edited files requiring review

Full backport commit diff: commit 6db603245e3c.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5682

Abort dual channel sync cleanly when main link write fails after $ENDOFF

2 AI-edited files

Claude Summary

The conflict is resolved and the backport is verified on 8.0: the new test passes with the fix and the replica crashes with SIGSEGV without it. Nothing is staged or committed, so src/replication.c still shows as UU.

What the conflict was

The upstream fix lands in dualChannelReplHandleEndOffsetResponse(), which doesn't exist on 8.0. Git therefore offered about 184 lines of upstream-only helper functions as the "theirs" side. On 8.0 the same logic is inline in fullSyncWithPrimary().

Resolution

src/replication.c (+4 lines, same as upstream)

  • Dropped the whole "theirs" block; none of those functions belong on 8.0.
  • Added the guard at the equivalent spot, right after setupMainConnForPsync(server.repl_transfer_s) in the REPL_DUAL_CHANNEL_RECEIVE_ENDOFF branch.
  • It uses a plain return; instead of upstream's return C_RETRY;, because C_RETRY doesn't exist on 8.0. This is equivalent: err is already freed at that point, and the return skips both the NULL connSetReadHandler call and the RDB_LOAD state change.
  • The comment says "The error path" rather than "C_ERR" for the same reason.

tests/integration/dual-channel-replication.tcl (+36 lines vs upstream's +33)

  • The auto-merged test called test_defer, which isn't defined on 8.0, so it would have failed at runtime.
  • I replaced it with the branch's existing idiom: the fake primary is spawned at start_server scope and killed with catch {exec kill -9 $pid} right after the test.

tests/helpers/fake_dual_channel_primary_reset.tcl is byte-identical to upstream.

Verification

All of this was run in a scratch copy outside the repo, since deleted:

  • Build: compiles with -Werror using the tree's existing build settings.
  • With the fix: the new test passes, and the full integration/dual-channel-replication file passes (44 ok, exit 0).
  • Without the fix: the replica crashes with signal: 11, Accessing address: (nil), so the bug exists on 8.0 and the test
    ... summary truncated.

AI-edited files requiring review

  • src/replication.c — view diff
  • tests/integration/dual-channel-replication.tcl — view diff

Full backport commit diff: commit d51cf6c8aa1e.

Please review these AI resolutions for correctness before merging.

killAppendOnlyChild() waits with waitpid(-1, ...), which reaps any child that has exited, not just the AOF rewrite child, and drops its status. If a forked SCRIPT DEBUG session has ended but serverCron hasn't reaped it yet, stopping AOF during a rewrite reaps it there. Its pid then stays in the debugger children list, so serverCron logs "waitpid() returned an error" on every tick, and on shutdown the stale pid, which may belong to an unrelated process by then, gets a SIGKILL.

This patch waits for server.child_pid only, like TerminateModuleForkChild() already does.

serverCron doesn't reap children while a script is running, so the new test ends the debug session while the server is in a busy script, and starts and kills the rewrite right after the script. Once the debug session child is reaped, it checks that the server doesn't try to kill it on shutdown.

This affects all versions.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Backport-Source-PR: 5529
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5529

Fix killAppendOnlyChild reaping children other than the AOF rewrite child

1 AI-edited file

Claude Summary

The conflict in tests/unit/scripting.tcl is resolved and no conflict markers remain. Nothing was staged or committed, so the file still shows as unmerged (UU) until you git add it.

The conflict

  • There was one conflict region, inside the if {$is_eval eq 1 &amp;&amp; $script_compatibility_api == "redis"} { … } ;# is_eval scope, between the "Forked scripting debug session does not suspend save points" block and the "Test scripting debug protocol parsing" block.
  • The 8.0 side was empty. The incoming side carried two start_server blocks:
    • Dropped: the "SCRIPT DEBUG on one client…" block of five tests. It is surrounding context from other upstream PRs that were never backported to 8.0, not part of Fix killAppendOnlyChild reaping children other than the AOF rewrite child #5529, and it uses test_defer / test_defer_fail, which don't exist on 8.0.
    • Kept: the "Stopping AOF during a rewrite does not reap a forked scripting debug session" block, which is the test this PR adds. It sits in the same scope and relative position as upstream.

Result

  • The diff against the 8.0 head is 2 files, 58 insertions, 1 deletion — the same as the upstream commit. The 57 added test lines are byte-identical to the upstream hunk.
  • src/aof.c auto-merged correctly (waitpid(-1, …) → waitpid(server.child_pid, …) in killAppendOnlyChild) and needed no adaptation.
  • Every helper, config and server message the test relies on exists on 8.0 with the same behaviour as upstream.

Verification (in a scratch copy under /tmp, since deleted; this working directory was not rebuilt)

  • Without the fix: on the server binary already built here before the cherry-pick, the new test fails at its final assertion (Expected '0' to be equal to '1' on the "Killing debugging session" log count). So the bug is present on 8.0 and the test catches it.
  • With the fix: the new test passes, 7 runs out of 7 at about 311 ms each.
  • Full unit/scripting: passes, 657 ok and no errors.
  • AOF integration: integration/aof, `integration/aof-multi-
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 4433a5bf426e.

Please review these AI resolutions for correctness before merging.

…5558)

Followup for #5526 (Was missed when handling the valgrind failures)

Fixes #5553

After the mid-stream abort, the replica partially resyncs and has to
apply ~2500 buffered SUNIONSTORE commands. On slower CI runners (~3-4 ms
per command) that takes 7-10 s, which overruns the fixed 5 s budget in
wait_for_ofs_sync.

`wait_for_ofs_sync` now takes optional maxtries/delay arguments
(defaults unchanged), and this test uses 30s (3x largest observed
delay). The failure message also prints both offsets, so a real stall
can be told apart from a slow apply.

Signed-off-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Backport-Source-PR: 5558
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5558

Extend offset-sync wait after mid-stream abort in dual-channel test

2 AI-edited files

Claude Summary

Both conflicts are resolved and no conflict markers remain. The result is 5 insertions and 4 deletions across the two files, the same size as the upstream PR, and nothing was staged or committed.

tests/support/util.tcl

  • wait_for_ofs_sync now takes the optional {maxtries 50} {delay 100} arguments and passes them to wait_for_condition; the failure message prints both offsets.
  • I dropped check_replica_acked_ofs and wait_replica_acked_ofs from the incoming side. They are not part of this PR and do not exist on 8.0; they only appeared because they sit above this proc upstream.

tests/integration/dual-channel-replication.tcl

  • Git placed the conflict in the wrong test. The incoming side was the upstream repl-compression version of the mid-stream abort test, dropped into the middle of "dual-channel-replication sync completes with replica-announce-ip".
  • I kept the 8.0 side there unchanged and discarded the incoming copy, since 8.0 has no repl-compression loop.
  • The PR's actual change went onto 8.0's own "Replica aborts streaming when the primary link breaks mid-stream" test at line 1502: the comment plus wait_for_ofs_sync $primary $replica 300 100.

Verification

  • Running the whole integration/dual-channel-replication file passed with 44 ok and 0 errors, including the modified mid-stream test and both replica-announce-ip tests.
  • The existing src/valkey-server binary predates the current src/aof.c; I did not rebuild, since this test file does not exercise the AOF code.

AI-edited files requiring review

  • tests/integration/dual-channel-replication.tcl — view diff
  • tests/support/util.tcl — view diff

Full backport commit diff: commit 058efdf3b407.

Please review these AI resolutions for correctness before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-resolved-conflicts AI is used to resolve conflicts in automated backport PRs. backport Backport PR opened by valkey-ci-agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.