Skip to content

[backport] Backport sweep for 9.0 - #5498

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

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

Conversation

@valkeyrie-ops

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

Copy link
Copy Markdown
Contributor

Backport sweep for 9.0

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

CI fixes for this sweep are in #5701.

Applied

Source PR Title Detail
#5366 Fix double mutex unlock when shrinking IO threads conflicts resolved by Claude Code
#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
#4971 Skip pubsub channel defrag while a pending reply holds a reference conflicts resolved by Claude Code
#5476 Fix RDB checker infinite loop on an RDB truncated inside a module value conflicts resolved by Claude Code
#5143 Keep slot imports loaded during a swapdb full sync conflicts resolved by Claude Code
#5690 Send tracking invalidation on SWAPDB
#5611 Propagate BITFIELD when OVERFLOW FAIL only creates or grows the key
#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
#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
#5177 Size valkey-check-rdb stats for every selected DB conflicts resolved by Claude Code
#5174 Fix GEOSEARCH BYPOLYGON when the vertex centroid is outside geohash range
#5145 Ignore new nodes gossiped by a sender still in handshake conflicts resolved by Claude Code
#5140 Reject RESET on slot migration clients
#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
#5359 Reset slot migration snapshot pipes when the snapshot fork fails conflicts resolved by Claude Code
#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
#5471 Fix valkey-check-rdb --stats crash on keys before SELECTDB and huge DB IDs 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
#4541 Reject module cross-slot BlockClientOnKeys in cluster mode conflicts resolved by Claude Code
#5713 Fix crash in VM_GetClientInfoById for a client without a connection conflicts resolved by Claude Code
#5511 Fix integer precision loss in HINCRBY propagation
#5529 Fix killAppendOnlyChild reaping children other than the AOF rewrite child conflicts resolved by Claude Code
#5144 Don't finalize a full sync that was cancelled while loading from disk conflicts resolved by Claude Code
#5558 Extend offset-sync wait after mid-stream abort in dual-channel test conflicts resolved by Claude Code
#5655 Skip the pending channel reply defrag test in log-req-res mode

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.

7 candidate(s)
Source PR Title Outcome Reason
#4574 Fix script debugger uaf skipped-conflict target branch lacks conflicted file(s): src/modules/lua/debug_lua.c, src/modules/lua/engine_lua.c
#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-validation-failed BACKPORT_UNMAPPED_TEST_PATHS=["src/unit/test_cluster_module.cpp"] changed test path(s) have no explicit validation mapping: src/unit/test_cluster_module.cpp Branch-native test adaptation: test adaptation not applied: invalid generated test path(s): src/unit/test_files.h
#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
#5534 Fix slot export accepting a slot claim from a node other than the target error merge SHA 5804dbf does not match the aggregate patch of the source commits (6c11c7f..c570268). The pull request was either rebase-merged (its merge SHA is only the final rewritten commit) or the base branch advanced over the same lines before the merge. Backport it manually.
#5669 Keep reply blocks until the IO write completion is processed skipped-conflict test adaptation not applied: invalid generated test path(s): src/unit/test_files.h

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

Fix double mutex unlock when shrinking IO threads

1 AI-edited file

Claude Summary

The conflict in src/io_threads.c is resolved, and the fix is confirmed to be needed and working on 9.0. Nothing is staged or committed, and no other file was touched.

Resolution

  • The single conflict was in the shrink loop of updateIOThreads(). I took the PR's side: the extra pthread_mutex_unlock(&io_threads_mutex[i]); and its old comment are gone, replaced by the PR's comment line, verbatim.
  • The diff against 9.0 is 1 insertion and 2 deletions, the same as upstream.
  • The conflict was only textual: 9.0 has // Unblock inactive thread. where upstream had /* Unblock inactive thread. */ (restyled by Redesign IO threading communication model #3324, which is not on 9.0).

Why it applies to 9.0

  • Fix deadlock in IO thread shutdown during panic #2898 is on the branch (52547bf), so shutdownIOThread() already unlocks the mutex of inactive threads.
  • updateIOThreads() sets active_io_threads_num = 1 before the loop, so every removed thread takes that unlock. The line removed was a second unlock of the same mutex.

Verification

  • Markers: none remain, and git diff --check is clean.
  • Build: compiles with -Werror and no warnings.
  • Existing test: "test io-threads are runtime modifiable" in tests/unit/other.tcl passes in default and --io-threads modes. The PR body cites io-threads.tcl, which does not exist on 9.0; this test is the equivalent shrink coverage.
  • Stress: 300 random resizes under benchmark load completed with no hang or crash, and all 248 threads removed by shrinks were joined.
  • Before/after: with error-checking mutexes added in the throwaway copy, the 9.0 HEAD code logged one failed unlock in shutdownIOThread per removed thread (89 of 89). The resolved file logged none (0 of 84).

All building and testing ran in a temporary copy under /tmp, which I have deleted.

AI-edited files requiring review

Full backport commit diff: commit ac78eb4759de.

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: d7badc1b-0784-4f51-a0b2-50738b16965b

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

The conflict in src/replication.c is resolved and no conflict markers remain. One change goes beyond the textual conflict and needs your review: I changed the abort path in dualChannelSyncSuccess().

The abort-path change. On 9.0 a failed stream ends in replicationUnsetPrimary(), where upstream has freeClientAsync(server.primary). Upstream got that line from the replication-compression feature (#3853), which is not on 9.0 or 9.1. With 9.0's line left alone, the PR's new check made the replica promote itself to a standalone primary on link loss instead of reconnecting. I confirmed this on a build: both new tests failed with "Replica didn't resync" and the replica's log role flipped from S to M. I swapped in upstream's one line. That branch was unreachable on 9.0 before this PR, so no existing behaviour changes.

What else changed

  • streamReplDataBufToDb(): kept 9.0's loop (there is no compressed-stream reader on this branch) and added the PR's check right after replStreamProgressCallback(), using upstream's condition verbatim. primaryConnBrokenWhileStreaming() is added unchanged.
  • tests/integration/dual-channel-replication.tcl: the second test looped over {no lz4} and set repl-compression, which doesn't exist on 9.0. I removed the loop and the two config lines, dropped the compression wording from the test name and one comment, and de-indented the block. The first test is untouched.

The result is +171/−1 against upstream's +173/−2.

Verification (on scratch copies under /tmp/bp5417, not in the repo)

  • The build has no warnings, and clang-format 18 with the project style is clean on the changed lines.
  • Both new tests pass, including six repeated runs and a run under AddressSanitizer with no reports.
  • The full integration/dual-channel-replication suite passes (43 tests).
  • replication, replication-psync, replication-buffer and psync2-master-restart pass (181 tests).

Nothing was staged or committed, so `src/re
... 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 0e5440f03d60.

Please review these AI resolutions for correctness before merging.

@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. I did not run git add or commit, so the three files still show as unmerged and the cherry-pick is still in progress.

The change against the 9.0 tip is +44/-1 across the same three files, the same size as upstream. Its changed lines are identical to the upstream commit except for one word (the adaptation below).

What I did in each file:

  • src/module.c (inside VM_OpenKey, line 4233): took only the PR's change, zmalloc to zcalloc. I kept 9.0's comment wording ("Setup the key handle"); the "Set up" spelling on the incoming side comes from a different unstable commit.
  • tests/modules/zset.c: kept only zset_close_after_call (file scope, between zset_incrby and ValkeyModule_OnLoad) and its zset.close_after_call registration (inside OnLoad, before the final return). The rangebylex, members and walk functions and registrations on the incoming side were context from unstable commits that are not on 9.0, so I dropped them.
  • tests/unit/moduleapi/zset.tcl: kept only the PR's foreach test block and the config reset after it (inside start_server, before the "Unload the module" test). The rangebylex, members and walk tests were dropped for the same reason.

One branch adaptation: the PR's test loops over {listpack 128 btree 0}, but 9.0 has no btree encoding; sorted sets there are skiplists. I changed that pair to skiplist 0. Running the upstream wording unchanged on 9.0 fails with "Expected 'btree' to be equal to 'skiplist'".

Verification, done in scratch copies under /tmp so the repo tree was not touched:

  • The resolved tree builds cleanly and unit/moduleapi/zset passes, including both new cases (listpack and skiplist).
  • The full module API suite passes: 49 units, 572 tests ok, 0 failures.
  • The fix is needed and effective on 9.0. valgrind is not installed here, so I used a MemorySanitizer build instead. With 9.0's current module.c, the new test fails with use-of-uninitialized-value in VM_ZsetRangeSto
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 3f55eed52039.

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 error is fixed and the backport is adapted to 9.0; nothing was built or run here, so the re-run of validation is the first check.

First real error: cluster_legacy.c:3440: 'return' with a value, in function returning void. The backported fix for #4675 frees the link and does return 0; inside clusterProcessPingExtensions, but on 9.0 that function is void and its caller ignores the result.

Changes, both within the listed files:

  • src/cluster_legacy.c: clusterProcessPingExtensions now returns int (1 if the link is still valid, 0 if it was freed). Its single call site in clusterProcessPacket now does if (!clusterProcessPingExtensions(hdr, link)) return 0;, so the read handler does not touch the freed link.
  • tests/unit/cluster/packet.tcl: create_cluster_forgotten_node_packet called create_cluster_meet_packet with six arguments, but the 9.0 helper takes three, so the test would have failed with a wrong-args error once the build passed. It now uses the three-argument helper and patches the header fields in place (type PING, count 0, extensions 1, ext-data flag), the same way the existing create_cluster_ping_packet_with_ext does.

I could not see the unstable helper's signature, so I read the three extra arguments as count, extensions and mflags from their values (0 1 $CLUSTERMSG_FLAG0_EXT_DATA).

AI-edited files requiring review

Full backport commit diff: commit d5e1244a3a98.

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 the backport of #3245 is verified on 9.0: it builds under the tree's -Werror settings and the new regression test passes. Nothing is staged or committed, and no conflict markers remain.

The resolved change is the same size as upstream (58 insertions, 1 deletion) and differs from it in exactly two lines, both target-branch adaptations.

Conflict resolutions

  • src/networking.c: upstream had split the per-client logic into a helper that 9.0 doesn't have, so git dumped that helper's body after the loop in processIOThreadsReadDone(). I kept 9.0's return processed; there and applied the actual fix inside the loop at src/networking.c:6728, with upstream's comment.
  • src/debug.c: I kept only the SET-CLOSE-AFTER-REPLY help entry. The incoming side also carried a BIO-DRAIN help entry, which is not part of this PR and whose subcommand doesn't exist on 9.0.

Adaptations beyond the conflict markers

  • src/debug.c:1114: the auto-merged handler called objectGetVal(), which doesn't exist on 9.0. I changed it to c->argv[1]->ptr, as the rest of the file does.
  • tests/unit/protocol.tcl:399: the test started its server with io-threads-always-active yes, a config 9.0 doesn't have. I replaced it with events-per-io-thread 0, which is what 9.0's own test framework uses for --io-threads and what upstream's IO threading redesign (Redesign IO threading communication model #3324, not on 9.0) renamed.

Verification

I built and ran tests in a scratch copy outside the repo, since deleted, so the working tree holds only the three edited files.

  • Fix present: the new test passes in default, --io-threads, --tls and --tls --io-threads modes.
  • Fix reverted (scratch only): the same test crashes the server at server.c:4253 'c->read_flags & READ_FLAGS_COMMAND_NOT_FOUND' is not true, the assertion the PR describes. So the adapted test does reproduce the bug on 9.0.
  • Regression pass: with --io-threads, the protocol, networking, queryb
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit cb5aac5c30b4.

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 backport is the same size as upstream (193 insertions, 2 deletions across the two files). Nothing was staged or committed, so the cherry-pick is still in progress with src/cluster_legacy.c unmerged in the index.

What I changed

Both edits are in src/cluster_legacy.c:

  • Conflict region (file scope, between clusterIsValidPacket() and clusterProcessPacket()): I kept only the PR's new helper, clusterReplicaChainReaches(). The incoming side also carried clusterExtractSlotFromWord(), which is surrounding upstream code rather than part of this PR, and has no callers on 9.0, so I dropped it.
  • Auto-merged hunk inside clusterProcessPacket(): it applied without markers but would not have compiled. The new log line called humanNodename(), a helper from an unrelated upstream change (Add logging helper function to print node's ip:port when nodename not explicitly set #2777) that is not on 9.0. I replaced the two calls with sender->human_nodename and sender_claimed_primary->human_nodename, as the neighbouring 9.0 log lines do.

Those two lines are the only difference from the upstream diff. tests/unit/cluster/replicaof-cycle.tcl is byte-identical to upstream. The helpers, packet layout and flag values it relies on all exist unchanged on 9.0.

Verification

I built and tested in a temporary copy outside the repo, which I have since removed.

  • Build: compiles cleanly with CI's -Werror, and clang-format 18 (the version CI uses) reports no changes.
  • New test on the resolved build: both cases pass, and passed 8 out of 8 times in a loop. The observer logs the new "Ignoring claim…" notice once per scenario.
  • New test on unpatched 9.0: fails with the assertion the PR targets, 'primary->replicaof == NULL' is not true, reached through clusterProcessPacket. So the bug exists on 9.0 and the test catches it here.
  • Related cluster tests: replica-migration, manual-failover, manual-takeover, failover2, shardid-propagation, noflags
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit bc2f29121056.

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

7 AI-edited files

Claude Summary

All five conflicted files are resolved with no conflict markers left, and the fix works on 9.0: the resolved tree builds with -Werror and the new tests pass. Nothing was staged or committed; the cherry-pick is still in progress for you to continue.

The main thing shaping the resolution is that 9.0 has IFEQ but not IFNE, and lacks DELEX, MSETEX, INCREX, objectGetVal and argv_borrowed. Most of the incoming side was unrelated upstream context, so only the compare_idx plumbing came across.

Conflicted files

  • src/server.c / src/server.h: kept 9.0's parameter order for parseExtendedCommandArgumentsOrReply and inserted int *compare_idx just before compare_val. The upstream-only IFNE branch is dropped, and the doc comment says IFEQ rather than IFEQ/IFNE.
  • src/t_hash.c: the HSETEX and HGETEX call sites pass NULL for the new parameter.
  • src/t_string.c:
    • setGenericCommand takes comparison_idx and skips that index when stripping GET.
    • SET passes the parsed index; SETNX, SETEX and PSETEX pass -1.
    • 9.0's ->ptr access, long long milliseconds and GETEX validation order are kept as they were.
    • The upstream-only delexCommand, msetexCommand and increxCommand blocks are dropped.
  • tests/unit/type/string.tcl: kept only the PR's new test, reduced to the IFEQ case; the three upstream IFNE tests in the conflict region are not part of this PR and are dropped.

Auto-merged files I adapted

  • tests/unit/moduleapi/misc.tcl: the loop is reduced to the IFEQ pair, because the IFNE iteration would be a syntax error on 9.0.
  • tests/modules/misc.c: comment wording only (IFEQ instead of IFEQ/IFNE).

Verification

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

  • Fix confirmed on 9.0: with 9.0's original sources the two new tests fail, propagating set foo bar ifeq with the comparison value stripped. With the backport they pass, propagating
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit f8b3f231618d.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4971

Skip pubsub channel defrag while a pending reply holds a reference

1 AI-edited file

Claude Summary

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

Resolution. The single conflict was at the end of the channel-move block in defragPubsubScanCallback:

  • Kept from 9.0: hashtableResetIterator(&iter); — the PR's hashtableCleanupIterator does not exist on this branch.
  • Taken from the PR: the comment and allocatorDefragFree(channel, allocation_size); placed right after it, inside the if (newchannel) block.

The rest of the PR's change to that function had already merged cleanly. tests/unit/memefficiency.tcl needed no adaptation; every helper and config it uses exists on 9.0.

Size. The diff against HEAD is +14/−3 in src/defrag.c and +86 in the test file, identical to the upstream PR.

Verification. I built in a scratch copy under /tmp (since removed) so the worktree has no build artifacts.

  • Build: the resolved tree compiles with jemalloc and no compiler warnings.
  • New test: Active Defrag pubsub with a pending channel reply: standalone passes.
  • Control: with 9.0's original defrag.c, the same test crashes the server on defrag.c:762 'channel->refcount == (int)hashtableSize(clients) + 1' is not true, so the test does reproduce the bug on this branch.
  • Regression: the existing Active Defrag pubsub tests pass in both standalone and cluster mode. That matters because the PR makes channel-name moves live again on 9.0.

I did not run the rest of the test suite.

AI-edited files requiring review

Full backport commit diff: commit 7673e6cb375d.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5476

Fix RDB checker infinite loop on an RDB truncated inside a module value

1 AI-edited file

Claude Summary

The validation failure is fixed in the test file; nothing has been re-run, so the fix is unverified until the caller's validation pass.

First real error (log line 672): both builds passed, and the only failure was in ./runtest-moduleapi --single unit/moduleapi/check-rdb-module-eof:

[exception]: Executing test client: can't read "::VALKEY_CHECK_RDB_BIN": no such variable.

Cause: the new test uses the ::VALKEY_CHECK_RDB_BIN and ::VALKEY_SERVER_BIN globals, which the 9.0 test suite does not define. On 9.0 the tests call the binaries by relative path, e.g. exec src/valkey-check-rdb … in tests/integration/valkey-check-rdb.tcl and src/valkey-server in tests/support/server.tcl:531.

Fix (only tests/unit/moduleapi/check-rdb-module-eof.tcl):

  • $::VALKEY_CHECK_RDB_BIN → src/valkey-check-rdb (two places)
  • $::VALKEY_SERVER_BIN → src/valkey-server (one place)

src/rdb.c is unchanged: it compiled cleanly under -Werror.

I also checked that the other things the test relies on exist on 9.0: the helper procs, the keep_persistence option, the test___dt type name, and the two log strings it matches.

AI-edited files requiring review

  • tests/unit/moduleapi/check-rdb-module-eof.tcl — view diff

Full backport commit diff: commit 1e9d5af8f952.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5143

Keep slot imports loaded during a swapdb full sync

3 AI-edited files

Claude Summary

All three conflicts are resolved, no conflict markers remain, and the result builds and passes its tests on 9.0. Nothing is staged or committed — the three files still show as unmerged until you git add them.

How each conflict was resolved

  • src/cluster_migrateslots.c, in clusterRDBLoadSlotImport: took the PR's new dbarray argument but kept 9.0's job_name->ptr, because objectGetVal does not exist on this branch.
  • src/cluster_migrateslots.c, in clusterCommandSyncSlotsFinish: kept the 9.0 side. The incoming lines were a guard (if (job->state == target_state) return;) from Ignore SYNCSLOTS FINISH for an already finished import job #5367, which is not on 9.0; this PR only reworded its comment.
  • src/cluster_migrateslots.h: kept 9.0's clusterRDBSaveSlotImports(rio *rdb) (the rdbver parameter is not on this branch) and took the new clusterRDBLoadSlotImport(rio *rdb, serverDb **dbarray).
  • tests/unit/cluster/cluster-migrateslots.tcl, end of file: kept the 9.0 side. The incoming ~110 lines were whole test blocks from Ignore SYNCSLOTS FINISH for an already finished import job #5367 and the forkless-sync work, neither of which is on 9.0; this PR only changed three lines inside one of them.

One adaptation outside the conflict regions

The PR's new test (Full sync ($mode) of a replica during import…) merged cleanly but calls test_config_set, which 9.0 does not have. I replaced it with the file's existing pattern: save the old repl-diskless-load value, set it, and restore it at the end of the test. Unlike the upstream helper, the restore does not run if the test fails partway, which matches the other tests in this file.

src/rdb.c and src/replication.c needed no changes.

Verification

I built and tested in a scratch copy under /tmp (since removed), so the working tree has no build artefacts.

  • Build: compiles with no warnings, and the four C files are clang-format clean.
  • New test, with the fix: all six cases pass (swapdb / on-empty-db / disabled, each with 500 and 0 keys).
  • New test, without the fix: the repli
    ... summary truncated.

AI-edited files requiring review

  • src/cluster_migrateslots.c — view diff
  • src/cluster_migrateslots.h — view diff
  • tests/unit/cluster/cluster-migrateslots.tcl — view diff

Full backport commit diff: commit a662c9c7924c.

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.

#3212 fixes test-ubuntu-libc-malloc (run). Backport it to 9.0.

@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 (run). Backport it to 9.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 #5701 with a fix for test-ubuntu-tls-no-tls (run): ff25a03.

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

Opened #5703 into unstable with a fix for test-sanitizer-force-defrag (run). Backport it to 9.0 once it merges.

sarthakaggarwal97 and others added 11 commits December 2, 2026 09:05
When the IO threads pool shrinks, updateIOThreads unlocks each removed thread's mutex and then calls shutdownIOThread, which unlocks the same mutex again. Unlocking a mutex that is not locked is undefined behavior.

The unlock in shutdownIOThread was added in #2898, but the older one in updateIOThreads was never removed. This PR removes it, so shutdownIOThread is the single owner of the unlock, as it already is for killIOThreads.

No behavior change on Linux or macOS, where the second unlock on a default mutex returns 0; the existing io-threads.tcl shrink tests cover the path.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Backport-Source-PR: 5366
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…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>
…4971)

With reply copy avoidance, a queued SUBSCRIBE/UNSUBSCRIBE reply keeps a
reference to a RAW channel object until it is written. A subscriber that
stops reading keeps that reference, so the next pubsub defrag pass
aborts on the refcount assert in defragPubsubScanCallback.

Only move the channel when its refcount is exactly subscribers + 1, and
skip it for this cycle otherwise. The assert becomes >=, so a missing
reference still aborts.

This also makes channel name defrag work again. Since the switch to
hashtable, the callback used activeDefragStringOb(), which skips any
object with refcount != 1, so channels were never moved. The old object
is now freed only after every client's reference points at the new one,
because the loop looks clients up by the old pointer.

---------

Signed-off-by: Yechiel Merzbach <yechielm@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Backport-Source-PR: 4971
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>
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
valkeyrie-ops Bot and others added 10 commits December 3, 2026 22:25
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
…B IDs (#5471)

`valkey-check-rdb` starts with `selected_dbid = -1`. With `--stats`, a key that comes before any `SELECTDB` opcode makes `computeDatasetProfile()` index `rdbstate.stats[type + (-1) * OBJ_TYPE_MAX]`, before the start of the array, and crash. The server loads such keys into DB 0, so the checker now starts from DB 0 too.

The DB ID read from `SELECTDB` is a 64-bit length stored in an `int`, and `(databases + 1) * OBJ_TYPE_MAX` is computed as an `int`. `SELECTDB 4294967295` sets `selected_dbid` back to -1, and IDs near `INT_MAX` overflow the size computation. IDs above `INT_MAX` are now reported as "Invalid DB ID", and with `--stats`, IDs from `INT_MAX / OBJ_TYPE_MAX` on are reported as too large for `--stats`.

Both problems came with the RDB analysis reports (#1743), so they are in every release since 9.0.0.

Backport-Source-PR: 5471
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>
If a module blocks a client on keys whose slots differ from the command's
slot, the blocked client is later checked by clientsCronHandleTimeout(),
which calls clusterRedirectBlockedClientIfNeeded(). There it hits the
slot == c->slot assertion (added in #2165), since we do not allow cross-slot
commands, and the server aborts.

A module can reach this through incorrect use of the API. Even though
it is a misuse, it should not be able to crash the server, so reject it
in moduleBlockClient() by checking each key against c->slot and reply with
an error instead of blocking. Modules that set
VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION manage key distribution themselves,
so skip the validation for them, including the redirect check in
clusterRedirectBlockedClientIfNeeded().

This adds one more error path that aborts after the blocked handle has
been allocated. Such paths must reset bc->client to NULL, otherwise a
later VM_UnblockClient() dereferences will crash the server. Only the
Lua/MULTI path did this; apply the same to the other paths as well.

Detached handles from key-blocking calls must also be releasable with
VM_UnblockClient() even when no timeout callback was provided; otherwise
they leak.

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

A module command that asks for information about its own caller crashes
the server when it runs from a script, a function or `VM_Call`.

A typical case is an audit or rate-limiting module that logs or limits
by the caller's address:

```c
int AuditSet(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) {
    ValkeyModuleClientInfo ci = VALKEYMODULE_CLIENTINFO_INITIALIZER_V1;
    ValkeyModule_GetClientInfoById(&ci, ValkeyModule_GetClientId(ctx));
    log_access(ci.addr, ci.port, argv[1]);
    ...
}
```

`AUDIT.SET k v` from a normal client works, but the following crashes
with SIGSEGV:

```
EVAL "return server.call('AUDIT.SET', KEYS[1], ARGV[1])" 1 k v
```

Inside the script the command runs through the script's fake client,
which has no connection, and `call()` makes it
`server.executing_client`. `VM_GetClientInfoById()` returns
`server.executing_client` when the id matches, and
`modulePopulateClientInfoStructure()` then dereferences `client->conn`
for the TLS flag and the peer address.

`modulePopulateClientInfoStructure()` skips the TLS flag and the peer
address and port when the client has no connection. The structure is
zeroed first, so such clients report an empty address and port 0, and
still report their other flags (including `fake`), db and id.

New test in `tests/unit/moduleapi/misc.tcl`, "test module clientinfo api
- called from a script", runs `test.clientinfo` through `EVAL` and
checks the returned info. Without the fix the server crashes with signal
11.

---------

Signed-off-by: Eran Liberty <eran.liberty@gmail.com>
Co-authored-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
Backport-Source-PR: 5713
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 #4541

Reject module cross-slot BlockClientOnKeys in cluster mode

2 AI-edited files

Claude Summary

The conflict in tests/unit/moduleapi/cluster.tcl is resolved and no conflict markers remain in any of the five files. Nothing is staged or committed.

What I changed

  • tests/unit/moduleapi/cluster.tcl (the conflict): I kept only the 35 lines the PR adds — the blockonkeys.so start_cluster 1 0 block with its three tests, placed as the last block inside the tags { … } scope before } ;# end tag. I dropped the two unrelated tests on the incoming side ("MODULE LOAD is blocked during atomic slot migration" from Prevent module loading during async replication and slot migration #3039 and "Module VM_OpenKey cross-slot undeclared key access" from Resolve slot from key for module and arbitrary-key commands #4424). Neither is on 9.0.
  • src/module.c (auto-merged, would not compile): the new slot check called objectGetVal(keys[i]), which does not exist on 9.0. I changed it to keys[i]-&gt;ptr, the 9.0 convention already used in clusterRedirectBlockedClientIfNeeded().

The other three auto-merged files needed no changes. The result against 9.0 is 282 insertions and 11 deletions across the same five files as upstream, and the changed lines are identical to upstream apart from that one line.

Verification

I built and tested in a scratch copy under /tmp (since deleted), so the working directory holds only the two edits above.

  • Build: the server compiled cleanly under the tree's existing -Werror -DLOG_REQ_RES settings, and the test modules built without warnings.
  • Affected tests: unit/moduleapi/blockonkeys and unit/moduleapi/cluster pass, including all seven tests the PR adds.
  • Full module API suite: 50 units ran with one failure, "Module command introspection via COMMAND DOCS" in cmdintrospection.tcl. That came from my invocation: the binary is a -DLOG_REQ_RES build and I ran without --log-req-res. Re-running that unit with the flag passes.

Things to know before committing

  • src/module.c shows MM and cluster.tcl still shows UU; both need git add before git cherry-pick --continue.
  • src/commands_with_reply_schema.def was already
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit f61377dad6aa.

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 and no conflict markers remain in either file; nothing was staged or committed.

All three conflict regions sit inside xclaimCommand (its header comment and the per-ID claim loop), and each takes the PR's side:

  • FORCE doc comment: now carries the PR's wording about AOF/slot replay of FORCE JUSTID restoring a deleted ID.
  • Existence check: the loop uses the PR's if (!exists) with its new comment.
  • Reply path: serverAssert(exists); is added before the streamReplyWithRange assert.

The one branch adaptation was replacing objectGetVal(o) with o-&gt;ptr in two places, because objectGetVal does not exist on 9.0. One of those was on an auto-merged line outside the conflict markers (int exists = ...), which would have broken the build if left alone.

tests/unit/type/stream-cgroups.tcl needed no changes: the new test landed inside the existing AOF-enabled start_server block and uses only helpers already present on 9.0.

The resolved diff is the same size as upstream: 34 insertions and 10 deletions across the two files.

I built and tested in a scratch copy outside the repo, so the working tree only has the src/t_stream.c edits:

  • Build: make succeeds.
  • Tests: unit/type/stream-cgroups (including the new test), unit/type/stream, unit/multi, unit/pubsub and unit/cluster/cluster-migrateslots all pass.
  • Bug reproduces on 9.0: with the C fix reverted, the new test fails with Expected '2' to be equal to '1', so the backport is fixing a real problem on this branch.

AI-edited files requiring review

Full backport commit diff: commit 2927dc1221eb.

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 the same size as the upstream PR (9 insertions, 1 deletion), and nothing was staged or committed.

Resolutions

  • src/hyperloglog.c: I applied the PR's change of int len to size_t len on MurmurHash64A and kept the function non-static, as it is on 9.0. The static on the incoming side comes from Add static specifier to the internal functions of HLL #2496, which is not on 9.0.
  • tests/unit/hyperloglog.tcl: I added the new test right after the CVE-2025-32023 test, inside the existing start_server {tags {"hll"}} block, with the body unchanged from upstream. It closes with } {} {large-memory} like its neighbour, because the separate hll large-memory server block on the incoming side comes from Allow some tags only on top level to fix --tags filtering #3171, which is not on 9.0.

Verification

I built a copy of the 9.0 tree outside the repo and ran unit/hyperloglog there:

Build Invocation Result
Unfixed 9.0 new test only, --large-memory Server crashes with signal 11 in MurmurHash64A ← hllAdd ← pfaddCommand
Fixed --large-memory 31/31 pass, including the new test
Fixed default 29 pass; the two large-memory tests are skipped as intended

The fixed build compiled with no warnings, and a standalone comparison of the old and new signatures gave identical hashes for every tested length below 2^31.

Things to know

  • The 9.0 daily CI will not run the new test. The large-memory jobs use --large-memory --tags large-memory, and on 9.0 that skips the whole hll block because the tag is only on the tests, not the server block. I confirmed this with a run: 0 tests executed. The existing CVE-2025-32023 test already has the same gap; the new test only runs under --large-memory without --tags.
  • The test leaves two config limits raised on the shared server. proto-max-bulk-len and client-query-buffer-limit stay at 10 GB for the rest of the block, where upstream discards the server. No later test in the file uses eith
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 339b8cbb5073.

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 backport is the same size as the upstream PR (28 insertions, 2 deletions). Nothing was staged or committed.

Structure: the single conflict was inside serverCron(), at the "Check if a background saving or AOF rewrite in progress terminated" block. The resolution keeps the PR's restructuring there: reap children first, then evaluate save points and the automatic AOF rewrite in a separate if instead of the old else.

9.0 adaptations: two helpers the PR uses don't exist on 9.0, so I mapped them to what the branch already has.

  • Pending debug children: scriptingEngineDebuggerPendingChildren() becomes ldbPendingChildren(), which 9.0 already called at this spot.
  • Save-in-progress check: hasActiveSaveOrChild() becomes hasActiveChildProcess(). 9.0 has no forkless save, so the two are equivalent here. I kept this re-check after reaping because checkChildrenDone() can start a replication fork.

tests/unit/scripting.tcl auto-merged into the same scope as upstream and needed no changes; its hunk is identical to the PR's.

Verification (run in a scratch copy, since removed, so the working tree was untouched beyond src/server.c):

  • Build: compiles cleanly with the tree's existing settings, including -Werror.
  • New test: "Forked scripting debug session does not suspend save points" passes with the resolution and fails on the pre-fix 9.0 code with "Save point did not fire while a forked debug session was open".
  • Regression: unit/scripting, unit/other, unit/shutdown, integration/rdb, integration/aof and integration/aof-multi-part all pass (814 tests, no errors).
  • Formatting: clang-format 18 reports no changes on the edited lines.

src/server.c still shows as unmerged (UU) because I did not run git add.

AI-edited files requiring review

Full backport commit diff: commit 0544e77a4850.

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

Reset slot migration snapshot pipes when the snapshot fork fails

1 AI-edited file

Claude Summary

The conflict is resolved: the 9.0 commit will carry only the 3-line C fix, and the PR's new test is not backported because it cannot run on this branch. No conflict markers remain, and I did not stage or commit anything.

Test file (tests/unit/cluster/cluster-migrateslots.tcl) — I took the 9.0 side, so the file is byte-identical to HEAD. The single conflict sat at the end of the file, after the last start_cluster block, and the incoming side was 109 lines:

  • 31 lines from this PR: the new test was appended to a forkless-BGSAVE cluster block that 9.0 does not have. Its forkless-infrastructure-enabled and forkless-policy overrides are not 9.0 configs, and there is no forkless code anywhere in src/.
  • 78 lines from other unstable-only commits: a swapdb full-sync test and two other forkless tests, which are not part of this PR.

The test also cannot be adapted. It relies on a forkless BGSAVE making serverFork() refuse while no child process exists. On 9.0 the export and serverFork() both gate on hasActiveChildProcess(), so the fixed path is only reachable through a real OS fork() failure. Nothing on 9.0 can inject one: DEBUG has only PAUSE-AFTER-FORK, and the test suite has no process-limit helper.

C file (src/cluster_migrateslots.c) — I kept the auto-merged change untouched. slotExportJobBeginSnapshotToTargetSocket is now byte-identical to upstream's version, and the bug it fixes is real on 9.0. A syntax-only gcc pass with the Makefile's warning flags came back clean.

Things to know before you continue the cherry-pick:

  • Commit size: it will be 3 insertions rather than upstream's 34.
  • No regression test: the fix lands on 9.0 without test coverage for the fork-failure path.
  • Not run: I did not do a full build or run the test suite.

AI-edited files requiring review

  • tests/unit/cluster/cluster-migrateslots.tcl — view diff

Full backport commit diff: commit 50b969b07b08.

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 no conflict markers remain. The backport compiles under -Werror and the full unit/functions test file passes on this branch.

Nothing is staged or committed, so tests/unit/functions.tcl now shows as MM: the index still holds the cherry-pick's version with test_defer. Both files need a git add before git cherry-pick --continue, or the commit will pick up the broken test.

What I changed

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

  • I took the PR's change, addReplyErrorSds → addReplyErrorSdsSafe, which exists on 9.0 with the same behaviour as upstream.
  • I kept 9.0's next_arg-&gt;ptr instead of the incoming objectGetVal(next_arg), because objectGetVal does not exist on this branch.
addReplyErrorSdsSafe(c, sdscatfmt(sdsempty(), "Unknown argument %s", next_arg-&gt;ptr));

tests/unit/functions.tcl (auto-merged, but needed adapting):

  • The new test called test_defer {$rd close}, and test_defer is not defined on 9.0, so the test would have died with invalid command name.
  • I replaced it with a plain $rd close as the last line of the test body, which is how the other tests in this file close an extra client.
  • The difference from upstream is that the client is not closed if an assertion fails.

Verification

I built and tested in a throwaway copy outside the repo, so the working tree only differs in the two files.

  • Build: functions.c compiled and linked cleanly with the tree's existing settings, including -Werror.
  • Tests: ./runtest --single unit/functions exited 0 with no errors, and the new test FUNCTION - sanitize function list errors reported [ok].
  • Negative control: with the old addReplyErrorSds call put back in the copy, the new test fails (Expected 'ERR Unknown argument bad' to match '*Unknown argument bad +FAKE*'), so it does catch the bug on 9.0.
  • Size: the diff against HEAD is 10
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 8a615b87299e.

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

Fix valkey-check-rdb --stats crash on keys before SELECTDB and huge DB IDs

1 AI-edited file

Claude Summary

The validation failure is fixed in tests/integration/valkey-check-rdb.tcl; nothing was built or run here, so the re-run is the check.

First real error: invalid command name "write_binary_file" in the new test Check RDB stats when a key precedes any SELECTDB. The build itself succeeded; only the test file needed adapting.

What I changed (test file only):

  • Missing helper: write_binary_file does not exist on 9.0. I replaced the three calls with the inline open / fconfigure -translation binary / puts -nonewline / close sequence that the neighbouring test in the same file already uses.
  • Missing global: $::VALKEY_CHECK_RDB_BIN is not defined anywhere under tests/ on 9.0. I replaced the four uses with src/valkey-check-rdb, as every other check-rdb test on this branch does.
  • Stats-limit value: OBJ_TYPE_MAX is 7 on 9.0, while the source test's DB ID 268435455 is INT_MAX / 8. On 9.0 that ID is below the limit, so --stats would not reject it and would instead try to grow the stats array to roughly 1.9 billion entries. I changed the test to the 9.0 limit: DB ID 306783378 (INT_MAX / 7, bytes fe 80 12 49 24 92), with the expected message DB ID 306783378 is too large for --stats (max 306783377).

The third item was not in the validation log, because the run aborted at the first exception before reaching that test.

src/valkey-check-rdb.c is unchanged: its checks are written in terms of INT_MAX / OBJ_TYPE_MAX, so they are already correct for 9.0.

AI-edited files requiring review

  • tests/integration/valkey-check-rdb.tcl — view diff

Full backport commit diff: commit ba9554742b18.

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 in place. No conflict markers remain, nothing is staged or committed, and the cherry-pick is still in progress for you to continue.

One thing needs your decision: this backport should be followed by upstream #5558 (334dd6c), which is not on 9.0 or the 9.0 sweep branch.

What I did

  • Structure: on 9.0 the test sits directly in a top-level start_server block. Upstream wraps it in "foreach compression {no lz4}", and 9.0 has no repl-compression at all. Hunk 1 is in the outer block (primary setup) and hunk 2 is inside the test body; both keep 9.0's scope and indentation.
  • Left out: the foreach wrapper, the repl-compression config lines and the test-name suffix.
  • Code lines: taken from the PR unchanged (bigset_members, pad and n, each scaled on $::valgrind, which this file already uses on 9.0).
  • Comment: the only deviation is three comment lines. Upstream's wording about lz4 and "easily compressed" bytes does not apply here, so it now describes what 9.0 does (a link check after every buffered block).
  • Size: 13 insertions and 7 deletions, against upstream's 13 and 8.

Verification

All runs used scratch copies under /tmp, since removed; the worktree was not otherwise touched.

  • Existing 9.0 binary, native: the resolved test passed in all 10 runs (about 15.5 s each), and the whole file passed with 43 ok and 0 errors.
  • Default jemalloc build of 9.0: 8 of 8 passed.
  • TLS: 11 of 11 passed.
  • Valgrind ("make valgrind" build, daily-job flags): 7 of 7 passed in 23.5 to 24.2 s, close to the PR's quoted 25 s.
  • The bug exists on 9.0: under valgrind the old parameters cost about 259 ms per union, so the old 4000-command flood would take about 17 minutes against a roughly 200 s load hold. The new flood takes 5.7 s.

Valgrind was not installed. I downloaded the valgrind and libc6-dbg packages from the configured Ubuntu mirror, unpacked them into /tmp without installing anything, and deleted them after
... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit 1e00d07bec13.

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 failure was in the new test, not the build: unit/cluster/replicaof-cycle aborted with invalid command name "cluster_nodes_conf_path". I fixed it in tests/unit/cluster/replicaof-cycle.tcl only; nothing has been re-run, so the fix is unverified until the caller's validation pass.

Two things the source PR's test relies on are missing on 9.0:

  • Helper procs: cluster_nodes_conf_path, read_file and write_file exist on 9.0 only inside tests/unit/cluster/noflags-role-recovery.tcl, which is not loaded when this test runs alone. I added identical copies to replicaof-cycle.tcl.
  • Server binary variable: $::VALKEY_SERVER_BIN is not defined anywhere on 9.0, so it would have failed next. I replaced it with src/valkey-server, as tests/unit/cluster/misc.tcl does on this branch.

src/cluster_legacy.c is unchanged: it compiled cleanly with -Werror.

AI-edited files requiring review

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

Full backport commit diff: commit 462d6e985881.

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 changed how the new regression test in tests/unit/info.tcl triggers the overflow condition, because the source PR's trigger cannot work on 9.0. Nothing was run, so the adapted test is unverified until the caller's re-run.

First real error: [exception]: Executing test client: invalid command name "test_defer" in unit/info. The test helper test_defer does not exist on 9.0. The build itself succeeded and src/object.c needed no change.

Why a helper swap was not enough: the source test relies on each subscriber being charged the full size of a shared 256KB channel name. On 9.0, pubsubMemOverhead() only counts the per-client hashtable buckets, so overhead never exceeds used_memory that way. With only test_defer replaced, the test would have failed at "used_memory_overhead never exceeded used_memory".

What the test does now:

  • A second client queues about 8MB of ECHO arguments inside MULTI.
  • The test waits until mem_clients_normal exceeds 4MB, meaning clientsCron has counted that memory.
  • It then runs DEBUG pause-cron 1 and DISCARD, so the memory is freed while the accounted client overhead stays stale.
  • The test name and the three assertions from the source PR (used_memory_dataset, dataset.bytes, keys.bytes-per-key all 0) are unchanged.
  • Cron is resumed and the client closed at the end.

This depends on maxmemory-clients being 0, which is the default and is not overridden in the test config; otherwise client memory would be refreshed on DISCARD.

For the reviewer: the 9.0 test now differs from the one on unstable. If you would rather not carry a branch-specific test, the alternative is to drop it and backport only the src/object.c clamp.

AI-edited files requiring review

Full backport commit diff: commit 9c68120b55a0.

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 failed on invalid command name "test_defer" in the new test at tests/integration/dual-channel-replication.tcl:1683; that helper does not exist on 9.0. I replaced it with the cleanup idiom 9.0 already uses, and nothing has been re-run, per the constraints.

  • Fix: the test body is now wrapped in catch { ... } errmsg options, followed by catch {exec kill -9 $pid} and a rethrow via return -options $options $errmsg on failure. This is the same pattern as tests/unit/cluster/cluster-migrateslots.tcl:770-787, and it keeps the source PR's intent of killing the fake primary whether the test passes or fails.
  • Timeout: the run's exit code: timeout is probably a side effect of the same error: the aborted test never killed the fake primary, which serves until killed. I did not confirm that from the log.
  • Rest of the backport: the src/replication.c change compiled, and tests/helpers/fake_dual_channel_primary_reset.tcl is unchanged. The other helpers the test calls and the two log messages it waits for all exist on 9.0.

Only tests/integration/dual-channel-replication.tcl was edited.

AI-edited files requiring review

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

Full backport commit diff: commit 2c6bfaccb9a8.

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

Fix crash in VM_GetClientInfoById for a client without a connection

2 AI-edited files

Claude Summary

Both conflicts are resolved in the working tree with no conflict markers left; nothing was staged or committed, so the two files still show as UU in git status.

Verification, done in a scratch copy outside the repo (since removed) using the tree's existing build settings (TLS enabled, -Werror):

  • With the fix: the server builds cleanly and unit/moduleapi/misc passes 44/44 over both plain TCP and --tls.
  • Without the fix: with 9.0's original module.c, the new test crashes the server with signal 11 inside test_clientinfo called from the script, so the bug exists on 9.0 and the backported test catches it.

src/module.c

  • The two code hunks in modulePopulateClientInfoStructure had auto-merged correctly. connIsTLS exists on 9.0 and handles a NULL connection.
  • The conflict was in the VM_GetClientInfoById doc comment. I added only the PR's note about clients without a connection and kept 9.0's "However passing NULL..." line. The "flags ... were added in Valkey 9.1" note on the incoming side belongs to Add more client info flags to module API #2868, which is not on 9.0.

tests/unit/moduleapi/misc.tcl

  • Git had anchored the hunk between the two tracking tests, and the incoming side carried the foreach cmd {rm_call vm_call_argv} wrapper from Adds new (hidden) ValkeyModule_CallArgv API functions #3122, which is not on 9.0. I kept 9.0's tracking tests as they were.
  • The new test now sits directly after test module clientinfo api and before tracking with rm_call sanity, mirroring upstream's placement.
  • The flags check is the one semantic difference from upstream. parse_client_flags and the fake flag come from Add more client info flags to module API #2868 and don't exist on 9.0, so the fake assertion is dropped. The "ssl" ni $flags check became an exact match on "::::::", in the style the neighbouring test already uses. That is slightly stricter than upstream, because it asserts no flags at all rather than just no ssl.

The resolved diff is module.c +12/−4 (same as upstream) and misc.tcl +12 (upstream +13). No other files were modified.

AI-edited files requiring review

Full backport commit diff: commit 5e50cb324e5b.

Please review these AI resolutions for correctness before merging.

imasahiro and others added 2 commits December 4, 2026 01:26
Apple ARM64 uses 53-bit precision for long doble. Formatting the integer
result through long double can round large integers on a platform with
insufficient precision.

Signed-off-by: Masahiro Ide <masahiro.ide@lycorp.co.jp>
Backport-Source-PR: 5511
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
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 in either file. Nothing is staged or committed, so the file still shows as unmerged until you run git add.

There was one conflict region, inside the if {$is_eval eq 1 &amp;&amp; $script_compatibility_api == "redis"} block, between the "Forked scripting debug session does not suspend save points" server block and the "Test scripting debug protocol parsing" server block. The upstream side carried two things there:

  • This PR's new test: the start_server block "Stopping AOF during a rewrite does not reap a forked scripting debug session". I kept it verbatim, as a sibling block in the same position upstream has it.
  • Five tests from a different PR (Limit the Lua debugger to the client that runs the session #5596): that PR is not on 9.0, and its tests use test_defer and test_defer_fail, which do not exist on this branch. I dropped them.

The resulting change against HEAD is +57/-0 in tests/unit/scripting.tcl and +1/-1 in src/aof.c, line-for-line identical to the upstream commit. The auto-merged src/aof.c needed no adaptation.

Every helper and server message the new test uses exists on 9.0. I also ran it in a scratch copy of the tree outside the working directory, since removed:

  • Without the fix (the build already in the tree predated the aof.c change): the new test fails at its final assertion, so it reproduces the bug on 9.0.
  • With the fix: the new test passes 3 out of 3 runs.
  • Full unit/scripting run: passes with no errors, and the new test runs once, between its expected neighbours.

AI-edited files requiring review

Full backport commit diff: commit 9ce634b59aad.

Please review these AI resolutions for correctness before merging.

…#5144)

A replica loading a disk-based full sync processes events from inside
`rdbLoad()`. If a cluster bus message handled there moves it to a new
primary (an ordinary failover, or `CLUSTER FAILOVER TAKEOVER` on another
replica), the sync being loaded is cancelled and a new handshake starts.
When the load returns, the replica finalizes the cancelled sync anyway.
It closes the new sync's temp file, reports the link as up with the new
primary's replication ID, and keeps the old primary's dataset with no
further resync. This patch treats a load that spans a
`cancelReplicationHandshake()` call as failed and leaves the newer
sync's state alone.

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

Don't finalize a full sync that was cancelled while loading from disk

2 AI-edited files

Claude Summary

The conflict in src/replication.c is resolved and the backport works on 9.0: the new test passes with the fix and fails without it. Nothing is staged or committed; src/replication.c still shows as unmerged and the test-file adaptation is an unstaged edit, so both need git add before git cherry-pick --continue.

What conflicted

Both conflict regions were inside replicaLoadPrimaryRDBFromDisk(). Upstream's version of that function depends on RDBFLAGS_EMPTY_DATA and RDB_INCOMPATIBLE, which come from a different change that is not on 9.0.

Resolution in src/replication.c

  • Kept from 9.0: the explicit "Flushing old data" emptyData() before the load, and the unconditional discard on failure.
  • Applied from the PR:
    • the cancellations snapshot right before rdbLoad();
    • the post-load check that logs "Sync was cancelled while loading the DB" and sets retval = RDB_FAILED;
    • the log wording change to "Discarding the loaded data".
  • Adapted: 9.0 called rdbLoad() inline in the if, so I introduced int retval = rdbLoad(..., RDBFLAGS_REPLICATION) and changed the condition to if (retval != RDB_OK).
  • Dropped: the RDBFLAGS_EMPTY_DATA flag and the RDB_INCOMPATIBLE branch.

The counter declaration and the increment in cancelReplicationHandshake() had merged cleanly and are in the right places.

Adaptation in tests/unit/cluster/manual-takeover.tcl

The cherry-picked test called test_config_set, a helper that does not exist on 9.0 (it comes from upstream #4871). I replaced the two calls with plain R 1 config set ..., matching the rest of the file. The test's cluster is torn down right after, so nothing needs restoring.

Verification

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

  • Build: clean, no warnings.
  • New test with the fix: passes.
  • New test with 9.0's original replication.c: fails with "Replica kept the old primary's dataset", the symptom the PR describes.
  • **R
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit b33410bb602e.

Please review these AI resolutions for correctness before merging.

Baraa-Hasheesh and others added 2 commits December 5, 2026 05:24
…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>
The Daily reply-schemas-validator job fails since the test "Active
Defrag pubsub with a pending channel reply" was added in #4971:

    Reply schema validation failed for CONFIG SET
    min-io-threads-avoid-copy-reply: 'OK' was expected (response: null)

The test runs "config set min-io-threads-avoid-copy-reply 1" on a server
without IO threads. After that, isCopyAvoidPreferred() returns 1 for
every reply, so each reply buffer starts with a binary payload header
(and holds object pointers for bulk strings) instead of plain RESP. The
req-res logger (reqresAppendResponse() in src/logreqres.c) copies the
reply buffer as is, so the .reqres file holds the header before "+OK"
and the validator cannot parse the reply.

The test needs copy avoidance for its whole body, so it cannot run in
log-req-res mode. Tag it with logreqres:skip, like the other tests that
set min-io-threads-avoid-copy-reply to 1 (tests/unit/networking.tcl and
tests/unit/obuf-limits.tcl). It still runs in all other jobs. The {0}
result pattern is the value that "$listener close" returns.

Fixes #5642

Signed-off-by: Eran Ifrah <eifrah@amazon.com>
Backport-Source-PR: 5655
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

1 AI-edited file

Claude Summary

The conflict is resolved and the backport now matches the upstream PR exactly: +2/−1 in tests/integration/dual-channel-replication.tcl and +3/−3 in tests/support/util.tcl. No conflict markers remain, and I did not run git add or git commit.

Git had placed the conflict hunk in the wrong test. On 9.0 the "Replica aborts streaming when the primary link breaks mid-stream" test is not wrapped in the foreach compression {no lz4} loop, so the PR's hunk landed in the fake-primary "$ENDOFF" test at the end of the file, which the PR never touches.

  • Misplaced conflict region: I kept the HEAD side as is, so the fake-primary test is byte-identical to 9.0.
  • Actual PR change: I applied it to the correct test at tests/integration/dual-channel-replication.tcl:1671, at 9.0's indentation: the comment line plus wait_for_ofs_sync $primary $replica 300 100.
  • tests/support/util.tcl: the auto-merge needed no adaptation. wait_for_ofs_sync is defined only there, the optional maxtries/delay arguments keep the old defaults, and every other caller still passes two arguments.

I ran the full integration/dual-channel-replication file with the existing src/valkey-server binary (built before the branch's latest src/aof.c change): all tests passed, including the changed test.

Running that test alone with --only aborts before reaching it. Setup code at line 768 depends on an earlier skipped test, which is unrelated to this change.

AI-edited files requiring review

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

Full backport commit diff: commit 77c3363a1825.

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.