Skip to content

[backport] Backport sweep for 8.1 - #5507

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

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

Conversation

@valkeyrie-ops

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

Copy link
Copy Markdown
Contributor

Backport sweep for 8.1

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

Applied

Source PR Title Detail
#5417 Abort dual-channel sync if the primary link breaks while streaming conflicts resolved by Claude Code
#5358 Zero the module key handle so CloseKey is safe after a Call changes the key's type 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
#5090 Keep an IFEQ/IFNE value spelled GET when propagating SET GET 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
#2565 Fix the issue of incorrect commandlog metrics in the script
#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
#3440 Fix config rewrite producing negative values for unsigned memory configs conflicts resolved by Claude Code
#3541 Fix FD leak in connSocketBlockingConnect on timeout
#3503 Fix remove cached eval scripts on engine unregister conflicts resolved by Claude Code
#3583 Fix checkPrefixCollisionsOrReply returning non-zero on self-overlap 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
#5145 Ignore new nodes gossiped by a sender still in handshake conflicts resolved by Claude Code
#5132 Hash HyperLogLog elements with a size_t length conflicts resolved by Claude Code
#5166 Don't pause rehashing when iterating a hashtable with no table
#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.

4 candidate(s)
Source PR Title Outcome Reason
#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.1-9es3c355/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

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, no conflict markers remain, and nothing was staged or committed. The result is 171 insertions and 1 deletion, against 173 and 2 upstream.

One change goes beyond the literal conflict hunk and needs your review. In dualChannelSyncSuccess() I changed the abort path from replicationUnsetPrimary() to freeClientAsync(server.primary). Upstream already has that line at this PR's base; it came in with the repl-compression PR (#3853), which 8.1 does not have. Without it, the backported check makes a replica whose link drops promote itself to a standalone primary instead of reconnecting. I confirmed this by running the literal backport: both new tests failed with "Replica didn't resync" and the replica log showed it switching to primary with a new replication ID. With the change, the replica reconnects and resyncs, which is what the PR intends.

src/replication.c

  • The conflict was inside the block loop of streamReplDataBufToDb(). Upstream's loop is built around the repl-compression decode path, which does not exist on 8.1, so I kept 8.1's loop.
  • I added the PR's link check right after the per-block progress callback, using upstream's exact condition.
  • The helper primaryConnBrokenWhileStreaming() had merged cleanly and is unchanged.

tests/integration/dual-channel-replication.tcl

  • The conflict was at end of file. The incoming side carried four unstable-only tests as context (lazyfree of the local buffer, replica-announce-ip on the rdb channel, buffer memory fields, hash-field-expiration full sync); I dropped them because they are not part of this PR.
  • I kept the PR's two tests. The second lost its foreach compression {no lz4} wrapper and the two repl-compression config lines, since that config does not exist on 8.1; its name and one comment were adjusted to match.

Verification

I built and tested in a scratch copy outside the repository, since removed.

  • The build has no warnings and replication.c
    ... 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 1e36d101a2d8.

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: cb6a26a4-a017-4239-989f-4b19dc6deb77

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 23, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5358

Zero the module key handle so CloseKey is safe after a Call changes the key's type

3 AI-edited files

Claude Summary

All three conflicts are resolved in place and no conflict markers remain. Nothing is staged or committed, and only the three conflicted files differ from HEAD.

The result is 44 insertions and 1 deletion, the same size as the upstream PR.

Resolutions

  • src/module.c (VM_OpenKey): took the PR's zmalloc → zcalloc change. I kept 8.1's /* Setup the key handle. */ comment, because the "Set up" wording comes from an unrelated upstream typo commit (42aff62b3).
  • tests/modules/zset.c: kept only zset_close_after_call and its zset.close_after_call registration in ValkeyModule_OnLoad. I dropped the zset.rangebylex, zset.revrangebylex, zset.members and zset.walk code on the incoming side, which belongs to other upstream PRs not on 8.1.
  • tests/unit/moduleapi/zset.tcl: kept only the PR's new foreach test block, placed before the "Unload the module" test, and dropped the upstream-only tests for those same commands.

One adaptation to the PR's content

The test loop is {listpack 128 skiplist 0} instead of upstream's {listpack 128 btree 0}. Upstream replaced the skiplist zset encoding with btree; 8.1 still reports skiplist. Running upstream's unadapted variant against an 8.1 build fails with Expected 'btree' to be equal to 'skiplist'.

Verification

I built and tested in a scratch copy outside the repo, since removed.

  • Bug applies to 8.1: dbSetValue has the same keep-the-old-robj swap for a RAW string with refcount 1, and moduleCloseKey then reaches VM_ZsetRangeStop. The test's {1 5} result confirms that path is taken.
  • Build: valkey-server and the test modules compile with no warnings.
  • Tests: unit/moduleapi/zset passes, including both new cases (listpack and skiplist). The full module API suite also passes: 48/48 files, 561 ok, 0 errors.
  • Not run: valgrind is not installed here. As the PR notes, only a valgrind run detects the uninitialized read, so these runs show the test passes o
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 5a7dfe3dfa8c.

Please review these AI resolutions for correctness before merging.

@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 build failure is fixed in the worktree, along with a second incompatibility in the test file that the build error was hiding. Nothing was built or run here, so the re-validation is the first real check.

First real error (/tmp/backport-validation-1kkcxyy_.log:193):

cluster_legacy.c:3050:24: error: 'return' with a value, in function returning void [-Wreturn-mismatch]

The source PR (#4675) adds freeClusterLink(link); return 0; inside clusterProcessPingExtensions. That only works if the function returns int and its caller stops using the freed link; on 8.1 it returns void and the caller ignores it.

Changes in src/cluster_legacy.c:

  • clusterProcessPingExtensions now returns int: 0 when it freed the link, 1 otherwise, with the return contract added to its comment.
  • The single caller in clusterProcessPacket now does if (!clusterProcessPingExtensions(hdr, link)) return 0;, so the read handler stops touching the freed link.

Change in tests/unit/cluster/packet.tcl:

  • The new create_cluster_forgotten_node_packet helper called create_cluster_meet_packet with six arguments, but on 8.1 that proc takes only three. This would have failed the new test with a Tcl "wrong # args" error once the build passed.
  • The helper now calls the three-argument form and patches the header in place (type PING, gossip count 0, extensions 1), the same way the existing create_cluster_ping_packet_with_ext does.
  • I read the three extra arguments (0 1 $CLUSTERMSG_FLAG0_EXT_DATA) as gossip count, extension count and mflags, without having the unstable signature to confirm. The 8.1 helper already hardcodes the EXT_DATA flag, so I dropped the now-unused constant.

No files outside the two listed were touched.

AI-edited files requiring review

Full backport commit diff: commit 78667bb34b19.

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 in place, no markers remain, and nothing was staged or committed. The result is +58/−1 across the same three files as upstream, and the C changes add exactly the lines upstream added.

One thing you should know first: on 8.1 the new test passes with or without the fix, so it is not a regression guard on this branch. The fix itself is still needed here (details below).

What I changed

  • src/networking.c: git had placed the fix at the end of processIOThreadsReadDone, outside the while loop, because upstream moved the loop body into a per-client function that 8.1 doesn't have. I kept 8.1's processClientsCommandsBatch() there and applied the new condition and comment to the if (c->argc > 0) inside the loop.
  • src/debug.c: kept only the SET-CLOSE-AFTER-REPLY help lines. The BIO-DRAIN lines on the incoming side belong to a subcommand 8.1 doesn't implement. The auto-merged handler is untouched.
  • tests/unit/protocol.tcl (auto-merged): one line adapted, the start_server line. The test body is otherwise identical to upstream.
    • io-threads-always-active yes became events-per-io-thread 0. The former doesn't exist on 8.1 and the test server refused to start.
    • Added the external:skip tag. io-threads is immutable on 8.1, so without the tag an external-server run fails with "can't set immutable config".

How the bug behaves on 8.1

  • No assertion here: 8.1 has no command queue and no READ_FLAGS_COMMAND_NOT_FOUND assertion. An unfixed server silently executes the truncated command instead.
  • Reproduced: with SET a b NX cut off inside its last argument, the unfixed build ran SET a b and GET a returned b. The fixed build executed nothing.
  • Why the test can't see it: the upstream test only checks that the server survives, and nothing crashes on 8.1 either way.

Verification

All of it ran in scratch copies, since removed; the working tree's existing build artifacts are untouched.

... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 18fc064665c2.

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. 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

Both edits are in src/cluster_legacy.c:

  • The conflict (before clusterProcessPacket): I kept only the PR's new helper, clusterReplicaChainReaches(). The other function in the conflict, clusterExtractSlotFromWord(), was just surrounding context from an unrelated unstable-only change. It doesn't exist on 8.1 and has no callers there, so I dropped it.
  • A hunk git merged cleanly but which would not have built: the new log statement called humanNodename(...), a helper that doesn't exist on 8.1. I replaced the two calls with sender->human_nodename and sender_claimed_primary->human_nodename, which is what every neighbouring log line on 8.1 uses.

The result is the same size as upstream: 30 added / 2 removed in the C file, and the 163-line test file is byte-identical to upstream.

Verification

I built and tested in a scratch copy under /tmp, which I've since removed, so the repo has no build artifacts.

  • Build: compiles with CI's -Werror flags, no warnings.
  • New test: both scenarios in replicaof-cycle.tcl pass, and the server log shows the new "Ignoring claim…" line firing once per scenario.
  • Negative control: with unpatched 8.1 code, the same test crashes the observer on the primary->replicaof == NULL assertion from the PR description. So the bug exists on 8.1 and the test catches it.
  • Regressions: 143 passed, 0 failed across 15 related cluster test files, including failover, replica migration, slot migration and manual failover.
  • Formatting: clean under clang-format 18 with 8.1's own src/.clang-format, which differs from upstream's.

Things to know

  • Log output differs slightly from unstable: when a node has no human nodename, the new line prints () on 8.1, where unstable prints ip:port
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 6c70b2cd3776.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5090

Keep an IFEQ/IFNE value spelled GET when propagating SET GET

6 AI-edited files

Claude Summary

All five conflicted files are resolved with no conflict markers left, and nothing has been staged or committed — the cherry-pick is still in progress for you to git add and continue.

The fix needed porting rather than a straight merge, because 8.1 is structured differently from unstable:

  • src/server.c, src/server.h, src/t_hash.c: kept the 8.1 side, so they are byte-identical to HEAD and will show no change in the commit. The PR's hunks there touch parseExtendedCommandArgumentsOrReply and the hash field-expiry commands, none of which exist on 8.1.
  • src/t_string.c: applied the fix to 8.1's own parseExtendedStringArgumentsOrReply and setGenericCommand. The parser now reports the index of the IFEQ comparison value, and the GET-stripping loop skips that index. The callers are updated to match, and the upstream-only delex/msetex/increx code that came in as conflict context is dropped.
  • tests/unit/type/string.tcl: kept only the PR's new test, trimmed to IFEQ and renamed to match. The three IFNE tests in the conflict were pre-existing upstream context, not part of this PR.
  • tests/unit/moduleapi/misc.tcl (auto-merged): trimmed the foreach to the IFEQ case.
  • tests/modules/misc.c (auto-merged): left untouched. Its comment still says "IFEQ/IFNE", which is harmless.

The IFNE trimming is the one real deviation from upstream: SET on 8.1 has no IFNE, and SET k v IFNE GET GET returns a syntax error there, so those test cases could not pass.

I built the resolved tree in a scratch copy outside the repo (since removed) and it compiled with zero warnings. Results:

  • New tests: unit/type/string and unit/moduleapi/misc pass in full, including both new tests.
  • Negative control: against the original 8.1 t_string.c, both new tests fail, with the command propagated as set foo bar ifeq (comparison value stripped). So the bug exists on 8.1 and the trimmed tests catch it.
  • Regression: unit/expire, `unit/type/
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 8fb951209543.

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.

No fix for test-ubuntu-arm (run). No candidate passed its test and review in 3 rounds. Last: Refusing to port 604dcdb: the cherry-pick conflicts with the target head in src/hashtable.c, src/unit/test_hashtable.cpp. Adapt it as a patch if it is the right fix, or choose another action. Its diff: ```diff diff --git a/src/hashtable.c b/src/hashtable.c index a349ae9c0..0127c6d4c 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -1090,6 +1090,7 @@ static bucket *findBucketForInsert(hashtable *ht, uint64_t hash, int pos_in_buc / Helper to insert an entry. Doesn't check if an entry with a matching key * already exists. This must be ensured by the caller. */ static void insert(hashtable *ht, uint64_t hash, void *entry) { + assert(ht->safe_iterators == NULL); hashtableExpandIfNeeded(ht); rehashStepOnWriteIfNeeded(ht); int pos_in_bucket; @@ -2184,13 +2185,14 @@ size_t hashtableScanDefrag(hashtable *ht, size_t cursor, hashtableScanFunction f * is returned exactly once. * * For a safe iterator (when HASHTABLE_ITER_SAFE is set): - * It is allowed to modify the hash table while iterating. It pauses incremental - * rehashing to prevent entries from moving around. It's allowed to insert and - * replace entries. Deleting entries is only allowed for the entry that was just - * returned by hashtableNext. Deleting other entries is possible, but doing so - * can cause internal fragmentation, so don't. The hash table itself can be - * safely deleted while safe iterators exist - they will be invalidated and - * subsequent calls to hashtableNext will return false. + * It is allowed to delete and replace entries while iterating. It pauses + * incremental rehashing to prevent entries from moving around. Inserting new + * entries during safe iteration is NOT supported. + * Deleting entries is only allowed for the entry that was just returned by + * hashtableNext. Deleting other entries is possible, but doing so can cause + * internal fragmentation, so don't. The hash table itself can be safely deleted + * while s….

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

#2811 fixes test-ubuntu-jemalloc-fortify (run). Backport it to 8.1.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

#5696, open on unstable, fixes test-fedoralatest-tls-module-no-tls (run). Backport it to 8.1 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.

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

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 the scheduled test run of 8.1, the branch this pull request is into.

#2943 fixes test-alpine-32bit (run). Backport it to 8.1.

shohamazon and others added 10 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>
#5358)

VM_OpenKey allocates the ValkeyModuleKey with zmalloc, and moduleInitKeyTypeSpecific initializes only the union member for the value's type at open time. If a module then overwrites the same key through ValkeyModule_Call, dbSetValue keeps the old robj when it is RAW-encoded with refcount 1 and swaps the new value's type, encoding and pointer into it. The handle now sees a sorted set, so ValkeyModule_CloseKey calls VM_ZsetRangeStop, which reads key->u.zset.type from memory that was never written. Allocate the handle with zcalloc: zero is the "nothing active" state for every type, so cleanup on close is a no-op for state that was never set up.

No compatibility impact. A new zset.close_after_call command in the zset test module opens a string key, turns it into a sorted set with ZUNIONSTORE through ValkeyModule_Call, and closes it; unit/moduleapi/zset.tcl runs it with listpack and B+tree configurations. Only a valgrind run detects the uninitialized read.

Observed while checking PR 5080.

---------

Signed-off-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Backport-Source-PR: 5358
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>
When SET has GET and no expiry, the primary propagates it with every
argument after the value that spells GET removed. The IFEQ/IFNE
comparison value is free-form, so a comparison value of `GET` was
removed too, and replicas and the AOF then diverge from the primary. The
fix keeps the argument that is the comparison value.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Backport-Source-PR: 5090
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.1 branch from 9aa793a to 69d8833 Compare December 2, 2026 09:08
YueTang-Vanessa and others added 5 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>
In script, client will be replaced with its caller, so commandlog needs
to use the metrics of the client that currently executing the command.

Signed-off-by: zhaozhao.zz <zhaozhao.zz@alibaba-inc.com>
Backport-Source-PR: 2565
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>
…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>
madolson and others added 14 commits December 3, 2026 21:31
`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>
The first `hashtableNext` call on a safe iterator pauses rehashing
before it checks whether the hashtable has a bucket array, and then
stops with the iterator still in its initial position.
`hashtableCleanupIterator` never resumes an iterator in that position,
so every safe iteration of a table-less hashtable leaks one pause.
`FLUSHDB SYNC` on a standalone server leaves the keyspace hashtable in
that state, so one `KEYS` afterward stops rehashing that database for
good, and 32768 of them wrap the `int16_t` counter and crash the server
on the next delete. The fix checks for the missing table before pausing.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Backport-Source-PR: 5166
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>
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 #4877

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

1 AI-edited file

Claude Summary

The conflict in src/debug.c is resolved: both hunks now keep the 8.1 branch's condition lines and add the PR's loading guard. Nothing was staged or committed, and no other file was touched.

Both conflicts sat inside debugCommand(), at the top of the reload and loadaof branches of its else if chain. They arose only because upstream's surrounding lines read objectGetVal(c-&gt;argv[1]) while 8.1 reads c-&gt;argv[1]-&gt;ptr.

  • Resolution: I kept 8.1's c-&gt;argv[1]-&gt;ptr condition lines and inserted the PR's guard as the first statement of each branch: reply with shared.loadingerr and return when server.loading || server.async_loading.
  • Size: the diff against the 8.1 head is 10 insertions and no deletions, identical to the upstream PR.
  • Symbols: server.loading, server.async_loading, shared.loadingerr and addReplyErrorObject all exist on 8.1, and the same guard is already used in the populate branch of this function.
  • Checks: no conflict markers remain, git diff --check is clean, and gcc and clang syntax-only passes on src/debug.c produce no warnings. I did not run a full build or the test suite.

AI-edited files requiring review

Full backport commit diff: commit 1bad913df1bc.

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 #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 with no markers left, and the result matches the upstream PR line for line in size (19 lines changed in src/t_stream.c, 25 added in the test). Nothing was staged or committed, so src/t_stream.c still shows as UU until you git add it.

All three conflicts were in xclaimCommand, caused only by 8.1 using o-&gt;ptr where upstream uses objectGetVal(o), plus old comment wording:

  • FORCE doc comment: took the PR's new wording.
  • Existence check in the claim loop: took the PR's if (!exists) form, which works with the auto-merged int exists = ... line, the moved continue, and the new mustObeyClient(c) guard.
  • Reply path: added the PR's serverAssert(exists); and left 8.1's existing streamReplyWithRange(c, o-&gt;ptr, ...) line as it was, since the PR does not change that line.

The auto-merged int exists = streamEntryExists(objectGetVal(o), &amp;id); line stays verbatim. objectGetVal exists on 8.1 as a macro in src/server.h added for backported code, and earlier backports in this file use it the same way. mustObeyClient and streamEntryExists also exist on 8.1 with the same signatures.

The test file needed no adaptation; the new test landed in the same AOF-enabled start_server block as upstream.

Verification, done in a scratch copy that I have since removed:

  • Build: compiles with the branch's existing flags, including -Werror.
  • Tests: unit/type/stream-cgroups, unit/type/stream, integration/aof and integration/aof-multi-part all pass.
  • Negative control: with 8.1's pre-fix t_stream.c, the new test fails (one PEL entry after AOF reload instead of two), so the bug is real on 8.1 and this change fixes it.

The PR's comments mention "AOF/slot replay", but 8.1 has no CLUSTER MIGRATESLOTS. I kept the comments verbatim to stay aligned with upstream; on this branch the guard covers the AOF client and the primary link only.

AI-edited files requiring review

Full backport commit diff: commit 16dc13747c96.

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 and no conflict markers remain. The result is +9/−1 across the same two files, the same size as the upstream PR. Nothing is staged or committed, and no other files were touched.

Resolutions

src/hyperloglog.c — one conflict, on the MurmurHash64A signature line (line 423):

uint64_t MurmurHash64A(const void *key, size_t len, unsigned int seed) {

I took the PR's int len → size_t len change and kept 8.1's non-static linkage. The static on the incoming side comes from #2496, which is not on 8.1 and is not part of this PR.

tests/unit/hyperloglog.tcl — one conflict, at the end of the CVE-2025-32023 test:

  • Structure difference: on unstable the CVE test lives in its own start_server {tags {"hll large-memory"}} block (from Allow some tags only on top level to fix --tags filtering #3171, not on 8.1). On 8.1 it is the first test in the shared start_server {tags {"hll"}} block, gated by a test-level {large-memory} tag.
  • What I kept: HEAD's } {} {large-memory} closing for the CVE test, followed by the PR's new test body verbatim.
  • Adaptation 1: the new test closes with } {} {large-memory} instead of a bare }. Without that tag, the 2 GiB test would run in every normal test run on 8.1.
  • Adaptation 2: I dropped the incoming } that closes the large-memory server block on unstable. On 8.1 it would have closed the shared server block and left the other 29 tests outside any server.

Verification

I built a scratch copy outside the repo with the tree's existing settings (-Werror -DLOG_REQ_RES, BUILD_TLS=yes, MALLOC=libc), then deleted it.

  • Compile: hyperloglog.o builds cleanly under -Werror and the server links.
  • Normal run (./runtest --single unit/hyperloglog): both large-memory tests are skipped and the other 29 pass.
  • Large-memory run (--large-memory): all 31 pass, including PFADD with an element of 2^31 bytes.
  • Negative control: with the old int len signature put back in the scratch copy, the new tes
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 4137247ec9af.

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 #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 the backport compiles and passes on 8.1. Nothing was staged or committed, so the file still shows as UU until you git add it.

Resolution

  • Kept: the PR's new test, CLUSTER SETSLOT inside MULTI does not block on replicas, placed after CLUSTER SETSLOT with invalid timeouts inside the same start_cluster 3 3 block, as it is upstream.
  • Dropped: the CLUSTER SETSLOT MIGRATING/IMPORTING should not be allowed to target self test that appeared in the conflict region. It is not part of this PR and belongs to an upstream change that isn't on 8.1. The ERR Target node is myself reply it asserts doesn't exist anywhere in src/ here, so it would fail.
  • src/cluster_legacy.c: the auto-merged change needed no adaptation; c-&gt;flag.deny_blocking and forceCommandPropagation both exist on 8.1.

The result against HEAD is +6/−1 in src/cluster_legacy.c and +8/−0 in the test file, identical to the upstream PR.

Verification
I built and tested in a scratch copy under /tmp (since deleted), so the working tree was not touched beyond the one edited test file.

  • Build: compiles cleanly under the tree's existing -Werror settings.
  • With the fix: the whole unit/cluster/slot-migration file passes, including the new test.
  • Without the fix: the new test crashes the primary with ASSERTION FAILED ==&gt; multi.c:244 'c-&gt;flag.blocked == 0' is not true. That is the bug the PR describes, so the test does exercise it on 8.1.
  • Markers: no conflict markers remain in either file.

AI-edited files requiring review

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

Full backport commit diff: commit 6908bb31babe.

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 #5145

Ignore new nodes gossiped by a sender still in handshake

3 AI-edited files

Claude Summary

Both conflicts are resolved and no conflict markers remain in any of the three files. The resolved tree builds with -Werror and all of tests/unit/cluster passes (no failures). Nothing was staged or committed.

What I changed

  • src/cluster_legacy.c — in the MEET-from-unknown-node branch of clusterProcessPacket, I took upstream's new comment but kept 8.1's call, clusterProcessGossipSection(hdr, link);. On 8.1 that function returns void and the packet variable is hdr, so upstream's if (!clusterProcessGossipSection(msg, link)) return 0; would not compile. The actual fix (the !nodeInHandshake(link-&gt;node) check on the sender) had already merged cleanly.
  • tests/unit/cluster/cluster-reliable-meet.tcl — removed the "handshake timeout on both sides" test block, as upstream did. The conflict was only because 8.1 has meet_retry == 10 where upstream had 50. The remaining "one side" test sits in its own start_cluster block, unchanged.
  • tests/unit/cluster/packet.tcl (auto-merged, needed an adaptation) — the new test called create_cluster_meet_packet with a fourth count argument, but 8.1's helper takes three and hard-codes count=100, a bogus extensions value and the EXT_DATA flag. I dropped the extra argument and patched those three header fields with string replace, the same way the existing 8.1 tests in that file do. This adds 4 lines over upstream.

Verification

I built and tested in a scratch copy outside the repo, since removed, so only the three listed files were touched.

  • Removed test: the old "both sides" test fails on the fixed build ("Retried to meet Node 0 too many times"), because it depends on the behaviour this PR removes.
  • New test: it fails on unfixed 8.1 code (the gossiped node appears in CLUSTER NODES) and passes with the fix.
  • Size: 39 insertions / 93 deletions, against upstream's 35 / 93.

The untracked src/commands_with_reply_schema.def was already there before I started and I lef
... summary truncated.

AI-edited files requiring review

  • src/cluster_legacy.c — view diff
  • tests/unit/cluster/cluster-reliable-meet.tcl — view diff
  • tests/unit/cluster/packet.tcl — view diff

Full backport commit diff: commit 2371134b08de.

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, no conflict markers remain, and the new test passes on 8.1. Nothing was staged or committed, so src/server.c still shows as unmerged (UU) until you git add it.

The conflict: a single hunk inside serverCron(), at the "Check if a background saving or AOF rewrite in progress terminated" block. I took the upstream restructuring and swapped in the 8.1 names for two helpers that don't exist on this branch:

  • scriptingEngineDebuggerPendingChildren() became ldbPendingChildren(), which is what 8.1 already used on that line.
  • hasActiveSaveOrChild() became hasActiveChildProcess(). Upstream defines the former as hasActiveChildProcess() || isSaveInProgress(), and the forkless-save half doesn't exist on 8.1.

Resolved code:

    int had_child = hasActiveChildProcess();
    if (had_child || ldbPendingChildren()) {
        run_with_period(1000) receiveChildInfo();
        checkChildrenDone();
    }

    /* Forked script debugging sessions are not the active child, and an idle
     * one can live indefinitely, so they must not postpone the save points and
     * the automatic AOF rewrite. */
    if (!had_child &amp;&amp; !hasActiveChildProcess()) {

tests/unit/scripting.tcl: the auto-merged test needed no changes. It landed in the same place as upstream, and every helper it uses exists on 8.1.

Verification, done in a scratch copy of the tree (since deleted) so the working directory was not touched:

  • The resolved file compiles with the branch's existing build settings, including -Werror.
  • The new test "Forked scripting debug session does not suspend save points" passes with the fix.
  • The same test fails against the unfixed 8.1 server.c ("Save point did not fire while a forked debug session was open"), so the bug is present on 8.1 and the backport fixes it.
  • unit/scripting, integration/rdb, unit/other, integration/aof and integration/aof-multi-part all pass.

The diff against HEAD i
... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit ef582f02c5b0.

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 no conflict markers remain. The result differs from 8.1 by exactly what the upstream PR changed: +3/−1 in src/config.c and +12/−0 in the test file. I did not run git add or git commit, so the test file still shows as unmerged (UU).

Resolution

  • Kept: the PR's one new test, CONFIG REWRITE keeps a replicaof host with a newline on one line. It sits as a top-level test right after CONFIG REWRITE handles large unsigned memory config values, the same position as upstream.
  • Kept: the 8.1-only sysfs short-read block (CONFIG REWRITE fails when the old config file reads short), unchanged, directly after the new test.
  • Dropped: two tests that appeared on the incoming side only as surrounding context from unstable: SIGNED MEMORY CONFIG allows negative number and CONFIG hash-seed is immutable and settable at startup. They are not part of this PR, and their configs (slot-migration-max-failover-repl-bytes, hash-seed) don't exist on 8.1.

src/config.c needed no adaptation: sdscatfmt (with %s/%i) and sdscatrepr exist on 8.1 with the same signatures.

Verification

I built and ran the tests in a throwaway copy outside the repo, since deleted, so the working tree carries only the two intended edits.

  • Compile: the fix builds cleanly on 8.1 with the tree's existing settings (-Werror, TLS, libc malloc).
  • Before the fix: the new test fails on 8.1. The server restarts replicating from 127.0.0.1 and loads the injected maxmemory line.
  • After the fix: the new test passes. The rewritten file holds replicaof "127.0.0.1 1\nmaxmemory 1234567\n#" 1 on one line.
  • Full file: unit/introspection passes, 71 ok with no failures, including the sysfs test that follows the new one.

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 0960fb6f0942.

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 is resolved and the backport works on 8.1: it compiles under -Werror, and the full unit/functions file passes (116 ok, 0 err), including the new test. Nothing is staged or committed.

What I changed

src/functions.c (the conflict, inside the argument-parsing loop of functionListCommand)

  • The two sides differed only in how the argument value is read: 8.1 has next_arg-&gt;ptr, upstream has objectGetVal(next_arg).
  • I kept 8.1's next_arg-&gt;ptr and applied the PR's actual change, addReplyErrorSds → addReplyErrorSdsSafe. addReplyErrorSdsSafe already exists on 8.1.
  • objectGetVal would also have compiled (8.1 has a compatibility macro for it), but every other line in this file uses -&gt;ptr.

tests/unit/functions.tcl (auto-merged, but broken on 8.1)

  • The merged test called test_defer {$rd close}, and test_defer does not exist on 8.1, so the test would have errored as merged.
  • I replaced it with a plain $rd close at the end of the test body, which is how other 8.1 tests close extra clients (e.g. tests/unit/multi.tcl).
  • The one difference from upstream: if an assertion fails, the client stays open until the test server shuts down.

The resolved diff against HEAD is 10 insertions and 1 deletion across the two files, the same as the upstream PR.

Verification

  • Markers: none remain in either file.
  • Before/after on the wire: sending FUNCTION LIST "bad\r\n+FAKE" then PING to the leftover pre-fix build gave -ERR Unknown argument bad\r\n+FAKE\r\n+PONG\r\n, three reply lines for two commands. The rebuilt server gives -ERR Unknown argument bad +FAKE\r\n+PONG\r\n.
  • The test detects the bug: run against that pre-fix server, the adapted test fails with Expected 'ERR Unknown argument bad' to match '*Unknown argument bad +FAKE*'; against the fixed server it passes.

To check this I rebuilt src/valkey-server incrementally with the tree's existing build settings, so that binary is now newer than the `va
... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit b7ea7be81e98.

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 resolved test passes on 8.1 both natively and under valgrind. Nothing is staged or committed.

What was wrong with the conflict

Git put the conflict markers in the wrong test. On 8.1 the mid-stream abort test has no foreach compression {no lz4} wrapper, because repl-compression doesn't exist in 8.1's src/. The upstream hunk therefore matched the trailing replica-announce-ip test instead, and the "theirs" side was a full copy of the upstream test dropped into that scope.

Resolution

  • Tail of the file: restored to 8.1's version, so the replica-announce-ip tests are untouched.
  • Mid-stream abort test (the 8.1 one, around line 1512): applied the PR's actual changes at 8.1's indentation. Under $::valgrind the set is 1000 members instead of 10000, the key name is 64000 bytes instead of 4000, and the command count is 150; natively the count goes from 4000 to 3000. $::valgrind already exists in tests/test_helper.tcl and is used elsewhere in this file.
  • Not brought over: the foreach compression wrapper, the repl-compression config lines and the test-title suffix.
  • One comment adapted: upstream's rationale for the longer key name is about lz4's 1 MB decode budget, which doesn't apply here. I kept 8.1's existing wording (the buffer streams in many blocks, each followed by a link check) and updated the size to ~10 MB.

The result is 13 insertions and 7 deletions against 8.1 (upstream: 13 and 8), with no conflict markers left. The non-comment lines match upstream apart from indentation.

Verification

All runs were done in scratch copies under /tmp, since removed; the only working-tree change is the conflicted file.

Run Result
Whole test file, native, existing 8.1 build all 42 tests pass, including the changed test (15.8 s) and both replica-announce-ip tests
Changed test under valgrind, existing -O3 build pass
... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit 67b78bc04b35.

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 backport's new test failed because it calls three Tcl helpers that don't exist on 8.1; I replaced them inline in tests/unit/cluster/replicaof-cycle.tcl. Nothing was re-run, per the constraints, so the fix is untested until the caller's validation pass.

First real error (log line 530): invalid command name "cluster_nodes_conf_path" in "Replicaof cycle in nodes.conf is refused at startup". Both builds succeeded and the two earlier tests in the file passed. read_file and write_file, used a few lines later in the same test, are also missing on 8.1 and would have failed next.

Changes, all inside that one test:

  • nodes.conf path: cluster_nodes_conf_path $obs is now built from R $obs config get dir and config get cluster-config-file, the same way tests/unit/cluster/packet.tcl does it on 8.1.
  • Reads: the three read_file calls are now exec cat, as misc.tcl and packet.tcl already do on this branch.
  • Write: write_file is now a plain open / puts / close. I used puts with its newline because exec cat strips the trailing one, so the copied nodes.conf still ends the way the original does.

src/cluster_legacy.c is untouched: it compiled cleanly with -Werror, and I found nothing in the 8.1 loader that would stop before the new cycle check.

AI-edited files requiring review

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

Full backport commit diff: commit a34ea8f81328.

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

I removed the new regression test from tests/unit/info.tcl and left the src/object.c fix as it was; nothing has been re-run, so the repair is unverified until validation runs again.

First real error: ./runtest --single unit/info aborted with invalid command name "test_defer". The test added by #5644 calls a test helper that does not exist on 8.1. Every other validation step passed, including both builds and all pre-existing unit/info tests.

Why I dropped the test rather than swapping the helper: the test cannot pass on 8.1 even with test_defer replaced. It relies on pubsubMemOverhead() charging the channel name size to every subscriber, so that overhead exceeds used memory. On 8.1 that function counts only dict overhead (src/pubsub.c:802), so the 12 subscribers never push used_memory_overhead above used_memory. The test would fail at its wait_for_condition instead.

What the backport now contains: only the src/object.c change — the clamp on mh-&gt;dataset and the zero-guard on peak_perc. tests/unit/info.tcl is back to its release-branch content, so the 8.1 backport carries the fix with no regression test.

I found no 8.1 code path that deterministically produces the underflow, and making the original scenario work would mean changing src/pubsub.c, which is outside the allowed files. If you would rather the backport not land without a test, revert my edit to tests/unit/info.tcl and the run will fail as before for a human to pick up.

AI-edited files requiring review

Full backport commit diff: commit 1f3b67ba1be9.

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

1 AI-edited file

Claude Summary

The validation failure was the new test calling test_defer, which does not exist in the 8.1 test framework; I replaced it with an equivalent cleanup in the test file. Nothing was run here, so the fix is unverified until validation is re-run.

  • First real error: [exception]: Executing test client: invalid command name "test_defer" at tests/integration/dual-channel-replication.tcl:1630. The build itself succeeded and all earlier tests in the file passed.
  • Timeout: the run's exit code: timeout is most likely a side effect of the same error, since the exception left the fake primary process running. I did not confirm that from the log.
  • Fix: in tests/integration/dual-channel-replication.tcl, the test body is now wrapped in catch, the fake primary is killed with catch {exec kill -9 $pid} afterwards, and any error is re-raised with error $err $errinfo. This preserves the source PR's intent: the fake primary is killed whether the test passes or fails, and assertion failures are still reported as normal test failures.
  • Unchanged: src/replication.c and tests/helpers/fake_dual_channel_primary_reset.tcl needed no adaptation. The other helpers the test uses and the two log messages it waits for all exist on 8.1.

AI-edited files requiring review

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

Full backport commit diff: commit bc93356beb1f.

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. The result matches the upstream PR exactly: 57 lines added to the test file plus the one-line waitpid change in src/aof.c.

  • Resolution: I kept only the PR's new start_server block with the test "Stopping AOF during a rewrite does not reap a forked scripting debug session". It sits inside the if {$is_eval eq 1 &amp;&amp; $script_compatibility_api == "redis"} scope, between the "Forked scripting debug session does not suspend save points" block and the "Test scripting debug protocol parsing" block, as upstream.
  • Dropped: the incoming side also carried about 140 lines of unrelated SCRIPT DEBUG tests from other upstream PRs. They are not part of Fix killAppendOnlyChild reaping children other than the AOF rewrite child #5529 and call test_defer, which does not exist on 8.1.
  • src/aof.c: the auto-merged change needed no adaptation.

Validation on 8.1:

  • Without the fix: the new test fails against the previously built binary, so it reproduces the bug on this branch.
  • With the fix: after rebuilding, the new test passes, including 15 of 15 repeat runs.
  • Wider suites: the full unit/scripting file, integration/aof, integration/aof-multi-part, integration/aof-race and unit/shutdown all pass.

I did not run git add or git commit, so scripting.tcl still shows as unmerged (UU). The untracked src/commands_with_reply_schema.def was there before I started and I left it alone.

AI-edited files requiring review

Full backport commit diff: commit 5ec1e2f44049.

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 against 8.1 is 5 insertions and 4 deletions across the two files, the same size as the upstream PR. Nothing was staged or committed.

tests/support/util.tcl

  • wait_for_ofs_sync now takes the optional maxtries and delay arguments (defaults 50 and 100, so the existing two-argument callers behave as before) and passes them to wait_for_condition.
  • The failure message that prints both offsets had already merged cleanly and is kept.
  • I dropped check_replica_acked_ofs and wait_replica_acked_ofs from the incoming side. They are not on 8.1 and are not part of this PR; they only appeared because git needed surrounding context from unstable.

tests/integration/dual-channel-replication.tcl

  • Git placed the conflict in the wrong test. On unstable the mid-stream test sits inside a foreach compression {no lz4} loop that 8.1 does not have, so the incoming side landed on the "sync completes with replica-announce-ip" test. I restored that block to the 8.1 version, unchanged.
  • The PR's actual change is applied to the 8.1 copy of "Replica aborts streaming when the primary link breaks mid-stream": the call is now wait_for_ofs_sync $primary $replica 300 100, with the upstream comment above it. I did not bring over the compression loop or repl-compression settings.

Verification

  • The full integration/dual-channel-replication file passes with the existing server build (43 tests ok, exit 0), including the changed test and the neighbouring replica-announce-ip tests.
  • A standalone check of the proc with stubbed offsets confirmed 50 × 100 ms by default, 300 × 100 ms with the new arguments, and a failure message of the form "replica offset didn't match in time (1000 vs 400)".
  • A first attempt using --only on the single test failed in an earlier, unrelated block (wait_process_paused) before reaching the changed test, apparently because setup code there depends on a test body the filter skipped. I
    ... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit fc9f63458e7b.

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.