Skip to content

[backport] Backport sweep for 9.1 - #5499

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

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

Conversation

@valkeyrie-ops

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

Copy link
Copy Markdown
Contributor

Backport sweep for 9.1

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

Applied

Source PR Title Detail
#4951 Fix MSETEX key discovery in cluster mode conflicts resolved by Claude Code
#5366 Fix double mutex unlock when shrinking IO threads
#5417 Abort dual-channel sync if the primary link breaks while streaming conflicts resolved by Claude Code
#4785 Deflake COPY Preserves TTLs test under libc malloc 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
#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
#5476 Fix RDB checker infinite loop on an RDB truncated inside a module value
#5596 Limit the Lua debugger to the client that runs the session conflicts resolved by Claude Code
#5143 Keep slot imports loaded during a swapdb full sync conflicts resolved by Claude Code
#5684 Fix wrong maxlen value in the script debugger on 32-bit builds
#5669 Keep reply blocks until the IO write completion is processed conflicts resolved by Claude Code
#4140 Retry PSYNC on -BUSY error instead of downgrading to SYNC conflicts resolved by Claude Code
#4152 Account for deferred client frees during eviction conflicts resolved by Claude Code
#4380 Resolve a key's slot from the key, not from the executing command
#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
#5141 Don't block CLUSTER SETSLOT on replica acks when the client cannot block
#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
#5584 Fix double free of the key iterator on AOF rewrite write error conflicts resolved by Claude Code
#5269 Validate cluster module message lengths before allocation
#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
#5690 Send tracking invalidation on SWAPDB
#5611 Propagate BITFIELD when OVERFLOW FAIL only creates or grows the key
#4973 Fix AOF/slot-migration dropping deleted stream PEL entries conflicts resolved by Claude Code
#4541 Reject module cross-slot BlockClientOnKeys in cluster mode
#5446 Don't let a retried election demote a primary others see as up conflicts resolved by Claude Code
#5511 Fix integer precision loss in HINCRBY propagation
#5713 Fix crash in VM_GetClientInfoById for a client without a connection
#5529 Fix killAppendOnlyChild reaping children other than the AOF rewrite child
#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.

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

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

Fix MSETEX key discovery in cluster mode

2 AI-edited files

Claude Summary

The conflict in tests/unit/cluster/misc.tcl is resolved and no conflict markers remain. One auto-merged file also needed a small adaptation to run on 9.1. Nothing was staged or committed; my edits are in the working tree only.

What I changed

  • tests/unit/cluster/misc.tcl (the conflict): upstream added the MSETEX cluster key routing test to a start_cluster 2 0 block that does not exist on 9.1. The conflict's incoming side also carried conditional-EXEC and WATCH tests plus a get_nodes_conf_path proc from PRs that were never backported. I kept only this PR's test, unchanged, inside its own start_cluster 2 0 {tags {external:skip cluster}} block, placed after the Cross-slot transaction block. It needs two primaries, and no existing block in the file was suitable.
  • tests/unit/cluster/cluster-migrateslots.tcl (auto-merged, but broken on 9.1): the new test called wait_for_migration 0 $slot 300. On 9.1 that helper takes only two arguments, so the test would have died with a "wrong # args" error. I dropped the 300 from both calls, which means the wait is 10 s instead of upstream's 30 s.
  • src/db.c, src/server.h, src/commands.def, src/commands/msetex.json: no edits needed.

The result is 156 insertions and 1 deletion, against 154 and 1 upstream. The differences are the three wrapper lines in misc.tcl and the two wait_for_migration calls.

Verification

I built and tested in a scratch copy outside the repo, since deleted, so the working tree has no build artefacts.

  • Build: compiles cleanly, and regenerating commands.def from 9.1's JSON reproduces the cherry-picked file byte for byte.
  • unit/cluster/misc: 14 passed, 0 failed.
  • unit/cluster/cluster-migrateslots: 115 passed, 0 failed. The new migration test takes about 3.5 s.
  • With the fix removed: both new tests fail on 9.1 as expected. The non-owner node executes the write instead of returning MOVED, and the migration target keeps the old value.

... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit 73839b7fa9f8.

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: dc6a4249-b6ee-4fc4-8a69-dece0d2e38c7

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

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.96992% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.80%. Comparing base (8efb5bb) to head (5592ff6).

Files with missing lines Patch % Lines
src/module.c 0.00% 22 Missing ⚠️
src/scripting_engine.c 55.55% 8 Missing ⚠️
src/debug.c 63.15% 7 Missing ⚠️
src/rdb.c 16.66% 5 Missing ⚠️
src/cluster_migrateslots.c 57.14% 3 Missing ⚠️
src/cluster_legacy.c 95.34% 2 Missing ⚠️
src/defrag.c 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              9.1    #5499      +/-   ##
==========================================
+ Coverage   77.58%   77.80%   +0.22%     
==========================================
  Files         166      168       +2     
  Lines       82864    83168     +304     
==========================================
+ Hits        64288    64711     +423     
+ Misses      18576    18457     -119     
Files with missing lines Coverage Δ
src/aof.c 82.03% <100.00%> (+1.61%) ⬆️
src/bitops.c 95.93% <100.00%> (-0.29%) ⬇️
src/cluster.c 92.99% <100.00%> (+<0.01%) ⬆️
src/commands.def 100.00% <ø> (ø)
src/config.c 79.66% <100.00%> (+0.08%) ⬆️
src/db.c 95.34% <100.00%> (+0.36%) ⬆️
src/functions.c 96.57% <100.00%> (ø)
src/geohash_helper.c 99.44% <100.00%> (+<0.01%) ⬆️
src/hashtable.c 97.51% <100.00%> (ø)
src/hyperloglog.c 95.43% <100.00%> (ø)
... and 22 more

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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 markers remain in either file. Nothing was staged or committed, and only the two listed files were edited. The result is +171/−1 against upstream's +173/−2.

Two adaptations go beyond the conflict markers and are worth a reviewer's attention:

  1. Abort path in dualChannelSyncSuccess() — I changed replicationUnsetPrimary() to freeClientAsync(server.primary), which is what upstream has there (from Streaming Compression support for Replication #3853, not this PR). With 9.1's original line, both new tests failed with "Replica didn't resync". The replica log showed it turning itself into a standalone primary with a new replication ID. That is worse than 9.1 today, where the replica finishes the replay and then reconnects normally. Before this backport that branch was effectively unreachable, so the change only affects the new broken-link case.

  2. Second test block — upstream wraps it in foreach compression {no lz4} and sets repl-compression, a config that does not exist on 9.1. I removed the wrapper and the two config lines, de-indented the block, and dropped the compression wording from the test name and one comment. The first test block is unchanged from upstream.

The conflict itself: the single conflict was inside streamReplDataBufToDb(). Upstream's side is built on the Streaming Compression feature (#3853), which 9.1 does not have. I kept 9.1's loop and added the PR's check after the existing progress callback, using the same condition as upstream: if (!server.pending_repl_data.blocks || primaryConnBrokenWhileStreaming(c)). The primaryConnBrokenWhileStreaming() helper auto-merged unchanged.

Verification (built and run in scratch copies outside the repo, since removed):

  • Build: no warnings; clang-format 18.1.8 wants no changes in the modified regions.
  • New tests: both pass, stable over repeated runs, with the replica staying a replica, caching the primary and resyncing.
  • AddressSanitizer build: both new tests
    ... 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 ee02df3fd225.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #4785

Deflake COPY Preserves TTLs test under libc malloc

1 AI-edited file

Claude Summary

The conflict in tests/unit/hashexpire.tcl is resolved by taking #4785's version of the hunk, and no conflict markers remain. Nothing is staged or committed, and no other file is touched.

Decision for review: this replaces 9.1's own earlier fix for the same flake in the COPY test. Commit 5a2dd4aef (from the previous sweep, #5074) had switched this assertion to the memory_usage helper, which skips the comparison under libc malloc. Its message says #4785 was deliberately not ported because a reviewer rejected the tolerance approach. I checked that against the public PR discussion and it does not hold up:

So I ported it rather than keeping 9.1's variant. If you would rather keep the helper version, skip this cherry-pick instead; it would otherwise be empty.

What changed

  • The edit is at tests/unit/hashexpire.tcl:1669, inside test {COPY Preserves TTLs} in the second start_server {tags {"hashexpire"}} block.
  • The test body is now byte-identical to unstable and 9.0.
  • The diff against 9.1 is +3/−3, versus upstream's +4/−1, because 9.1 already had the encoding assertion and a comment.
  • assert_range exists on 9.1.
  • The RENAME/RESTORE test just above still uses memory_usage; that is not part of Deflake COPY Preserves TTLs test under libc malloc #4785.

Verification (9.1 plus this resolution, built with MALLOC=libc in a scratch copy outside the repo, since deleted)

  • RENAME, RESTORE and COPY tests pass through runtest.
  • Running the block's preceding tests and then COPY, 500 loops: the resolved lines passed 500/500. The old exact assertion failed 81/500 with Expected '288' to be equal to '304', the CI signature.
  • Across 8,040 recorded runs of that sequence, the copy differed by ±16 bytes in 14.5% and never by more.

Caveats

  • On 9.1 this hash is
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 19cffcc4e2c1.

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, and the result is verified by build and test. Only the three conflicted files were edited; nothing was staged or committed, so they still show as unmerged until you git add them.

Resolution

The resolved diff is 44 insertions and 1 deletion, the same size as the upstream PR, and differs from it by one word.

One adaptation: the test's btree became skiplist. 9.1 has no B+tree zset encoding, and the upstream literal fails there with Expected 'btree' to be equal to 'skiplist'. This keeps the intent of covering both zset encodings.

Verification

All builds and runs were done in a scratch copy outside the repo, since removed.

  • Build and test: the server and test module compile with gcc, and unit/moduleapi/zset passes 8/8, including both new cases.
  • Regression: 189 tests pass across the module API suites that use key handles (list, stream, hash, scan, basics and others).
  • The fix does something on 9.1: valgrind isn't installed, so I used clang's MemorySanitizer and ran the new test with and without the one-line fix.
module.c Result
Resolved (zcalloc) 8 passed, 0 sanitizer reports
9.1 HEAD (zmalloc) 2 use-of-uninitialized-value reports in VM_ZsetRangeStop, one per encoding

The reports trace back to the zmalloc in VM_OpenKey, which is the bug the PR describes.

The MSan build needed `-DVALKEY_THREAD_SANI
... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit ef997316f571.

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

1 AI-edited file

Claude Summary

First real error (the only one in the log):

cluster_legacy.c:3598:24: error: 'return' with a value, in function returning void

Cause: the cherry-picked self-forget guard does freeClusterLink(link); return 0; inside clusterProcessPingExtensions, but on 9.1 that function still returns void and its caller ignores the result. The source PR relies on an int-returning version whose 0 tells clusterProcessPacket the link was freed.

Fix applied, all in src/cluster_legacy.c:

  • clusterProcessPingExtensions now returns int: 1 if the link is still valid, 0 if it was freed. I added return 1; at the end and a note in its doc comment.
  • Its single call site in clusterProcessPacket is now if (!clusterProcessPingExtensions(msg, link)) return 0;. This matches how that function already reports a freed link, so the read handler does not touch it afterwards.

The function has no prototype elsewhere and no other callers, so nothing outside the listed files needed changing. tests/unit/cluster/packet.tcl is untouched; the helpers the new test uses already exist on 9.1 with matching signatures.

Nothing was built or run here, per the constraints, so the fix is unverified until validation is re-run.

AI-edited files requiring review

Full backport commit diff: commit f434c3b377aa.

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

1 AI-edited file

Claude Summary

The conflict in src/debug.c is resolved and no conflict markers remain in any of the three files. I did not run git add or git commit, so src/debug.c still shows as UU and the cherry-pick is still in progress.

Resolution

Both conflict regions were inside debugCommand() and had the same cause. The incoming side carried BIO-DRAIN lines as surrounding context from a different upstream PR (#2555), which is not on 9.1 — BIO_CLUSTER_SAVE does not exist there, so those lines would not compile.

  • Help array (src/debug.c:539): kept only the two SET-CLOSE-AFTER-REPLY &lt;id&gt; help lines, placed just before NULL};.
  • Subcommand chain (src/debug.c:1118): kept only the set-close-after-reply branch, placed just before the final handleDebugClusterCommand fallthrough.

src/networking.c and tests/unit/protocol.tcl needed no adaptation. The resulting diff against 9.1 matches the upstream PR's size exactly: 13/0, 4/1 and 41/0 lines.

Verification

I built and tested in a temporary copy outside the repo, since removed, because running make in the working tree could trigger the Makefile's distclean. src/debug.c is the only file changed in the repo.

  • Symbols: every function, flag, config and Tcl helper the change uses exists on 9.1.
  • Build: compiles cleanly with the tree's existing settings (-Werror, TLS, libc malloc), and both C files are clang-format clean.
  • New test: passes in plain and --tls modes; the whole unit/protocol file passes, 36 of 36.
  • Control: with only the networking.c fix reverted, the new test crashes the server with the PR's assertion, server.c:4341 'c-&gt;read_flags &amp; READ_FLAGS_COMMAND_NOT_FOUND' is not true. So the bug exists on 9.1 and the test reproduces it.
  • Related suites under --io-threads: 608 passed, 0 failed, across protocol, io-threads, wait, pause, querybuf, multi, quit, networking, shutdown, introspection and type/list.
  • Subcommand by hand: unknown id, non-integer i
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit f0b595e1774f.

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 conflicts are resolved, and the backport builds and passes its tests on 9.1. Nothing was staged or committed.

What the conflicts were

The upstream PR was written against a tree that has IFNE, DELEX and INCREX. None of those exist on 9.1, so most conflict regions were upstream context, not PR content. I kept the fix and dropped everything that depends on those features.

File Resolution
src/server.c Added int *compare_idx to 9.1's 9-argument parseExtendedCommandArgumentsOrReply (not upstream's 13-argument form). Kept the IFEQ branch's index assignment; dropped the IFNE branch.
src/server.h Prototype updated to match.
src/t_hash.c HSETEX / HGETEX call sites pass NULL for the new argument.
src/t_string.c SET, GETEX, MSETEX call sites adapted. Took 9.1's (empty) side for delexCommand and increxCommand.
tests/unit/type/string.tcl Kept only the PR's one new test, minus its ifne line. Dropped the three older IFNE tests that appeared as context.

Adaptations beyond the conflict markers

  • tests/unit/moduleapi/misc.tcl (auto-merged): the loop {IFEQ GET IFNE other} became {IFEQ GET}. The IFNE iteration is a syntax error on 9.1 and would fail.
  • Comments: changed "IFEQ/IFNE" to "IFEQ" in server.c, t_string.c, tests/modules/misc.c and the new test's name, so the branch doesn't reference an option it lacks. This is optional; revert it if you prefer upstream's wording verbatim.

Verification

I built in a scratch copy outside the repo (since removed), using CI's SERVER_CFLAGS='-Werror'.

  • Build: clean under -Werror; clang-format 18 reports no diff on the four src/ files.
  • Tests on the resolved tree: all pass.
    • unit/type/string: 117 passed
    • unit/moduleapi/misc: 66 passed
    • unit/hashexpire, unit/expire, unit/type/hash: 611 passed
  • Control run: with 9.1's unfixed source plus the new tests, exactly the two new tests fa
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 7095b0775f5e.

Please review these AI resolutions for correctness before merging.

sarthakaggarwal97 added a commit to sarthakaggarwal97/valkey-ci-agent that referenced this pull request Dec 1, 2026
The agent's commits were made as valkeyrie-bot[bot], a name with no
GitHub account behind it, and most had no DCO sign-off. Its own fixes
and repair commits had none, and a backport kept only what its upstream
commit carried: sometimes nothing, sometimes a sign-off under another
email than its author's. The DCO check therefore fails on the sweep pull
requests (valkey-io/valkey#5619, valkey-io/valkey#5499), on the CI-sweep
pull requests (valkey-io/valkey#5441) and on the fixes opened into
unstable (valkey-io/valkey#5437, valkey-io/valkey#5440,
valkey-io/valkey#5443), and a maintainer has to override it.

Every commit the agent makes is now committed and signed off by
valkeyrie-ops[bot], the App that opens its pull requests. The identity
and the sign-off line are in scripts/common/identity.py, and
proc.set_commit_identity gives them to a clone.

- A commit the agent writes (a CI fix, a sweep's repair commit, a
  revert, a release cut) has the App as its author.
- A commit it cherry-picks (a backport, an upstream fix ported to a
  backport branch) keeps its author and its own sign-off, and gets the
  App's as its committer. The DCO check takes a sign-off from a
  commit's author or its committer.
- An open sweep branch from before this is signed off once, the next
  time it is rebased. Other open pull requests keep their commits.

The pull requests the CI-fix bot opens now say that their commit
carries the bot's sign-off and that a maintainer adds their own before
merging. Nothing checks for the maintainer's.

The registry edit that onboards a release branch is unchanged: it is
github-actions[bot]'s commit and is already signed off.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
@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

2 AI-edited files

Claude Summary

Both conflicts are resolved and no conflict markers remain. The resolved tree builds cleanly with the existing -Werror settings and the new tests pass on 9.1. Nothing was staged or committed, so the two files still show as UU.

Conflict resolutions

One adaptation in auto-merged code

The new foreach mode {swapdb on-empty-db disabled} test block merged cleanly into the right scope, but it called test_config_set, which does not exist on 9.1 (it comes from upstream #4871). I replaced it with the save/set/restore pattern the neighbouring test already uses:

set old_diskless_load [lindex [R 3 CONFIG GET repl-diskless-load] 1]
R 3 CONFIG SET repl-diskless-load $mode
...
assert_equal "OK" [R 3 CONFIG SET repl-diskless-load $old_diskless_load]

Unlike upstream's helper, the restore is skipped if the test fails partway. That matches the other tests in this file.

src/cluster_migrateslots.h, src/rdb.c and src/replication.c needed no changes.

Verification

I ran everything in a scratch copy outside the repo, since removed.

  • New tests: all six pass on the resolved build.
  • Regression check: against the pre-cherry-pick binary, the two swapdb variants fail. With 500 keys the replica aborts on the kvstore.c:958 assertion (the crash the PR describes); with 0 keys the job is failed instead of occurring-on-primary.
  • Full test file: unit/cluster/cluster-migrateslots gives 121 passed, 0 failed.
  • **Related su
    ... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit 2bf51848db5b.

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

Limit the Lua debugger to the client that runs the session

2 AI-edited files

Claude Summary

The conflict in tests/unit/scripting.tcl is resolved and no conflict markers remain. On a scratch build of 9.1 with the cherry-pick, unit/scripting passed 677/0 and unit/moduleapi/scriptingengine passed 42/0.

Where the conflict was: one region inside the if {$is_eval eq 1 &amp;&amp; $script_compatibility_api == "redis"} scope, between the Test scripting debug smoke and Test scripting debug protocol parsing start_server blocks. The PR's new start_server block with its five tests now sits there as a sibling, the same placement as upstream.

Decisions made:

  • Dropped a foreign test block. The incoming side also carried Forked scripting debug session does not suspend save points. That test belongs to Do not let forked script debug sessions postpone automatic saves #5153, which is not on 9.1 (neither is its src/server.c fix), so it is not part of this backport.
  • Replaced test_defer / test_defer_fail. These helpers come from [Test] Add automatic per-test cleanup to the Tcl test framework #4871, which is not on 9.1, so the tests would have errored on an unknown command. I replaced them with an explicit close at the end of each test body, which is the existing convention in this file.
  • Edited one auto-merged file for the same reason. tests/unit/moduleapi/scriptingengine.tcl used the same helpers and got the same substitution.
  • Left the C changes alone. The four other auto-merged files are identical to upstream, and every symbol they use exists on 9.1.

One behavioural difference from upstream: if one of these tests fails partway, its extra clients are not closed, as with every other test on this branch.

Further checks:

  • With the C fix reverted in the scratch copy, all five new scripting.tcl tests fail with the expected symptoms and the module API run crashes the server with SIGSEGV. So the adapted tests do exercise the fix on this branch.
  • The resolved change is 257 insertions / 7 deletions against upstream's 264 / 7; the gap is the dropped helper lines.
  • The scratch build lived outside the repo and has been removed; the repo has no untracked
    ... summary truncated.

AI-edited files requiring review

  • tests/unit/scripting.tcl — view diff
  • tests/unit/moduleapi/scriptingengine.tcl — view diff

Full backport commit diff: commit 359a05ffd4e5.

Please review these AI resolutions for correctness before merging.

sarthakaggarwal97 added a commit to valkey-io/valkey-ci-agent that referenced this pull request Dec 1, 2026
* Sign off every commit the agent makes as valkeyrie-ops

The agent's commits were made as valkeyrie-bot[bot], a name with no
GitHub account behind it, and most had no DCO sign-off. Its own fixes
and repair commits had none, and a backport kept only what its upstream
commit carried: sometimes nothing, sometimes a sign-off under another
email than its author's. The DCO check therefore fails on the sweep pull
requests (valkey-io/valkey#5619, valkey-io/valkey#5499), on the CI-sweep
pull requests (valkey-io/valkey#5441) and on the fixes opened into
unstable (valkey-io/valkey#5437, valkey-io/valkey#5440,
valkey-io/valkey#5443), and a maintainer has to override it.

Every commit the agent makes is now committed and signed off by
valkeyrie-ops[bot], the App that opens its pull requests. The identity
and the sign-off line are in scripts/common/identity.py, and
proc.set_commit_identity gives them to a clone.

- A commit the agent writes (a CI fix, a sweep's repair commit, a
  revert, a release cut) has the App as its author.
- A commit it cherry-picks (a backport, an upstream fix ported to a
  backport branch) keeps its author and its own sign-off, and gets the
  App's as its committer. The DCO check takes a sign-off from a
  commit's author or its committer.
- An open sweep branch from before this is signed off once, the next
  time it is rebased. Other open pull requests keep their commits.

The pull requests the CI-fix bot opens now say that their commit
carries the bot's sign-off and that a maintainer adds their own before
merging. Nothing checks for the maintainer's.

The registry edit that onboards a release branch is unchanged: it is
github-actions[bot]'s commit and is already signed off.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>

* Pass the App's identity with each commit command

A sweep commits in the clone its validation builds and tests in, and
git took the committer, and the name `commit -s` signs with, from that
clone's config, set once after cloning. A test that rewrote the config
changed whose commit and sign-off the next one was.

Every git command that commits now gets the identity in its environment
(proc.commit_env), which git reads before any config, and a clone is no
longer given one. A cherry-pick, a rebase and an amend still keep the
commit's author.

A CI fix written before the sign-offs keeps its unsigned commit when its
CI-sweep branch is rebuilt. The docs now say so.

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>

---------

Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
@valkeyrie-ops

valkeyrie-ops Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

#5684 fixes test-ubuntu-32bit (run). Backport it to 9.1.

It also fixes test-alpine-32bit.

@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-no-malloc-usable-size-test (run). Backport it to 9.1.

It also fixes test-valgrind-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 #5702 into unstable with a fix for test-sanitizer-address (gcc) (run). Backport it to 9.1 once it merges.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Automatic follow-up on this backport's CI.

A fix for reply-schemas-validator (run) could not be run here, so it was not pushed.

Proposed patch
diff --git a/tests/unit/memefficiency.tcl b/tests/unit/memefficiency.tcl
index 18b4eccc3..079c17138 100644
--- a/tests/unit/memefficiency.tcl
+++ b/tests/unit/memefficiency.tcl
@@ -716,7 +716,7 @@ run_solo {defrag} {
             assert_equal [list unsubscribe $chan 0] [$listener read]
             assert_equal [list $chan 0] [r pubsub numsub $chan]
             $listener close
-        }
+        } {0} {logreqres:skip} ;# The req-res log cannot parse copy-avoidance encoded reply buffers
     }
 
     proc test_tracking_table {type} {

bhuvanprakash and others added 10 commits December 2, 2026 09:05
Fixes #4936

`MSETEX` has a valid key spec, but had no `getkeys_proc` callback. So
`getKeysFromCommand()` ends up returning zero keys.

This broke two things. Cluster routing skips the `MOVED` and
`CROSSSLOT` checks, and atomic slot migration doesn't forward MSETEX
writes made after the snapshot. The command returns success, but the
target can end up with the old value.

The fix: Added `msetexGetKeys()` using the existing
`genericGetKeys(0, 1, 2, 2, ...)` helper.

That's enough to fix both paths. No changes to the cluster routing or
migration code itself.

Signed-off-by: Bhuvan Prakash <bhuvanstark6@gmail.com>
Backport-Source-PR: 4951
Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
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>
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304.

The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact.

Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings.

This PR is co-authored with Claude Opus 5.5.

Fixes #4149.

---------

Signed-off-by: Roy Chen <63842058+chky1386@users.noreply.github.com>
Backport-Source-PR: 4785
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()`.

### Cause

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.

### Fix

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
#2441. This is the same kind of stale-claim handling as #2811, and the
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.

### Tests

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.

### Open questions

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>
eliblight and others added 6 commits December 3, 2026 20:54
…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>
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 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5153

Do not let forked script debug sessions postpone automatic saves

2 AI-edited files

Claude Summary

Both conflicts are resolved, with no conflict markers left and nothing staged or committed. The resolved change is the same size as the upstream PR (8 added / 2 removed in src/server.c, 20 added in tests/unit/scripting.tcl).

Resolution

src/server.c (inside serverCron())

  • The PR's restructuring is kept: debugging children are still reaped, but the save-point and automatic AOF rewrite checks no longer sit in the else of that branch.
  • One adaptation: upstream's condition calls hasActiveSaveOrChild(), which doesn't exist on 9.1. It came in with Forkless Save (Forkless Save #4460), which is not on this branch. I used hasActiveChildProcess() instead, which is equivalent on 9.1 and is what the neighbouring checks in serverCron() already use.
  • The condition is now if (!had_child &amp;&amp; !hasActiveChildProcess()).

tests/unit/scripting.tcl

  • 9.1 already has a start_server {tags {"scripting external:skip tls:skip"}} block with five debugger tests at the spot where the PR adds its own block with the same opening line. Git merged the two opening lines into one and conflicted the bodies.
  • I kept them as two separate blocks: the PR's new test in its own server first, then the existing five tests untouched. This matches the layout on current unstable.

Verification

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

  • Build: compiles cleanly; only server.o is rebuilt.
  • New test: Forked scripting debug session does not suspend save points passes on the resolved code.
  • Negative control: the same test fails against unpatched 9.1 server.c ("Save point did not fire while a forked debug session was open"), so the bug is present on 9.1 and the adapted fix addresses it.
  • Regressions: full unit/scripting passes (678 passed, 0 failed). integration/rdb, integration/aof, integration/aof-multi-part, unit/other and unit/shutdown pass (160 passed, 0 failed).

Things to know

  • Upstream later changed this test in
    ... summary truncated.

AI-edited files requiring review

Full backport commit diff: commit 31aba53025a1.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5359

Reset slot migration snapshot pipes when the snapshot fork fails

1 AI-edited file

Claude Summary

The conflict is resolved, but the backport ends up as the 3-line C fix only: the PR's regression test could not be carried over to 9.1.

Why the test is dropped

  • Missing feature: the new test sits inside a start_cluster block that enables forkless-infrastructure-enabled / forkless-policy and asserts on rdb_current_bgsave_type. Those come from "Forkless Full-Sync (Forkless Full-Sync #4797)", which is on unstable and 9.2 but not on 9.1, so the test servers would not even start.
  • No way to trigger the path: on 9.1 the export waits for any active child before it tries to fork, so the fork-failure path is only reachable when fork() itself fails. The test suite has no way to inject that.
  • Unrelated block: the other block in the conflict region (the swapdb full-sync FINISH test) belongs to Ignore SYNCSLOTS FINISH for an already finished import job #5367, which is also not on 9.1.

So I kept the 9.1 side: tests/unit/cluster/cluster-migrateslots.tcl is byte-identical to 9.1 HEAD and will show no diff once staged. The commit will be +3 lines against upstream's +34.

The C fix
src/cluster_migrateslots.c is exactly as auto-merged; every identifier it uses exists on 9.1.

Verification

  • No conflict markers remain in either file.
  • The fix builds and links under the tree's -Werror settings, in a scratch copy outside the repo.
  • I forced a real fork() failure on a 2-node cluster (via RLIMIT_NPROC) and then retried the migration:
Binary Pipe fds after failed attempt Second migration
9.1 before the fix 4 → 5 (one leaked) source crashes on the assertion at cluster_migrateslots.c:1643
9.1 with the fix 4 → 4 succeeds, all 50 keys moved, source still answers PING

This was a one-off manual check; nothing from it was added to the repo and the scratch directory is removed. I did not run the Tcl suite, since the test file is unchanged from 9.1.

I did not run git add or git commit, so the test file still shows as unmerged (UU) and the cherry-pick is still in progress.

AI-edited files requiring review

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

Full backport commit diff: commit b6ec18691e38.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5369

Sanitize FUNCTION LIST error replies

1 AI-edited file

Claude Summary

First real error: ./runtest --single unit/functions aborted with [exception]: Executing test client: invalid command name "test_defer" in the new test FUNCTION - sanitize function list errors. The build itself succeeded.

Cause: the test from #5369 uses the test_defer helper, which does not exist in the 9.1 test framework.

Fix, in tests/unit/functions.tcl only: I removed the test_defer {$rd close} line and added an explicit $rd close at the end of the test body, matching how other 9.1 tests clean up valkey_client connections (e.g. tests/unit/tls.tcl). The test's assertions are unchanged.

src/functions.c needed no change: addReplyErrorSdsSafe already exists on 9.1.

Not re-run here; the fix is unverified until the caller's validation pass.

AI-edited files requiring review

Full backport commit diff: commit 0803519c48a1.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #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 repaired in tests/integration/valkey-check-rdb.tcl only; nothing was run, so the fix is unverified until the caller re-runs validation.

First real error: [exception]: Executing test client: invalid command name "write_binary_file". The three new tests call a helper that does not exist anywhere under tests/ on 9.1.

Two adaptations, both in the test file:

  1. Missing helper: I replaced the three write_binary_file calls with the inline open / fconfigure -translation binary / puts -nonewline / close sequence that the neighbouring 9.1 test in the same file already uses.

  2. Hardcoded stats limit (not in the log, found by reading the target): the "DB ID at the stats limit" test assumes OBJ_TYPE_MAX is 8, but on 9.1 it is 7 (src/server.h:752). With the original DB ID 268435455, the --stats run would pass the new check on 9.1 and try to allocate roughly 1.9 billion stats entries instead of erroring. I changed the DB ID to 306783378 (INT_MAX / 7, bytes fe8012492492) and the expected message to DB ID 306783378 is too large for --stats (max 306783377).

src/valkey-check-rdb.c is unchanged: the build passed and its check is written in terms of OBJ_TYPE_MAX, so it is already correct on 9.1.

AI-edited files requiring review

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

Full backport commit diff: commit 483d73ba8690.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #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: no markers remain, the file parses as complete Tcl, and nothing was staged or committed. The test passes natively on the 9.1 build, but I could not run it under valgrind, which is the case the PR actually fixes, because valgrind isn't installed here.

Structure. Both conflict regions sit in the last top-level start_server block. The first is in the primary setup, the second inside the body of the test "Replica aborts streaming when the primary link breaks mid-stream". Upstream wraps this block in foreach compression {no lz4} { ... }, but 9.1 has no repl-compression config, so I kept 9.1's un-wrapped structure and left the wrapper, the two config set repl-compression lines and the title suffix out.

What was applied. All of the PR's executable changes are carried over verbatim, at 9.1's indentation:

  • Set size: bigset_members is 1000 under valgrind and 10000 natively, in the primary setup.
  • Key-name length: pad is 64000 under valgrind and 4000 natively, in the test body.
  • Command count: n is 150 under valgrind and 3000 natively, in the test body.

$::valgrind already exists on 9.1 and is used elsewhere in this file. The diff against HEAD is +13/−7, against upstream's +13/−8.

One adaptation. Upstream's new comment explains the longer valgrind key name in terms of lz4 ("a link check runs once per 1 MB decoded"), which doesn't exist on 9.1. I reworded those sentences to describe 9.1's mechanism: the buffer streams in blocks, each followed by a link check, and the longer name spreads each union over several blocks. The stale "~16 MB" figure is gone and the first comment is verbatim upstream. This follows how the earlier #5417 backport stripped lz4 wording from the same comment.

Verification.

  • Native runs: the edited block passed 4 of 4 isolated runs (about 17 s each), and the whole file passed end to end (45 ok, 0 errors, 155 s).
  • **Valgrind
    ... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit dd3662afa9b2.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5556

Refuse to load a replicaof cycle from nodes.conf

1 AI-edited file

Claude Summary

The first real error is a test-harness failure, not a build failure: the build succeeded and the first two tests in unit/cluster/replicaof-cycle passed, then the new test aborted with

[exception]: Executing test client: invalid command name "cluster_nodes_conf_path"

The backported test calls cluster_nodes_conf_path, read_file and write_file, which 9.1 has no shared definitions for. On 9.1 each cluster test file that needs them defines them locally (noflags-role-recovery.tcl, availability-zone.tcl, packet.tcl).

I added those three procs to tests/unit/cluster/replicaof-cycle.tcl, just before the first start_cluster block, copied from the definitions in tests/unit/cluster/noflags-role-recovery.tcl. Nothing else changed: src/cluster_legacy.c is untouched and no file outside the listed paths was edited.

I did not run anything, so the fix is unverified until validation re-runs. The other helpers the new test uses (tmpdir, assert_no_match, $::VALKEY_SERVER_BIN) exist on 9.1, as does the "corrupted cluster config file" panic text it waits for.

AI-edited files requiring review

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

Full backport commit diff: commit b4b1c50c52ea.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5584

Fix double free of the key iterator on AOF rewrite write error

1 AI-edited file

Claude Summary

The validation failure was a compile error in src/unit/test_aof.cpp; I've adapted the test to 9.1, but nothing has been rebuilt or re-run here, so the fix is unverified until validation runs again.

First real error (make -C src test-unit, log line 673):

test_aof.cpp:35:15: error: 'createStringObjectWithKeyAndExpire' was not declared in this scope
test_aof.cpp:47:12: error: 'struct valkeyServer' has no member named 'created_db_ids'
(+ created_db_count, created_db_capacity)

The server build itself passed; only the new unit test failed to compile.

Changes, all in src/unit/test_aof.cpp:

  • Key creation: createStringObjectWithKeyAndExpire is static in object.c on 9.1. The test now uses objectSetKeyAndExpire(createStringObject(...), keysds, -1), the same pattern test_object.cpp uses on this branch.
  • Database setup: the server.created_db_ids, created_db_count and created_db_capacity lines are removed. Those fields don't exist on 9.1, where dbHasNoKeys() only looks at server.dbnum and server.db[], which the test already sets.
  • Engine manager init (not in the log): I added scriptingEngineManagerInit() before functionsInit(). On 9.1, functionsInit() iterates the scripting engine dict, which is NULL until the manager is initialised, so the test would have segfaulted at runtime once it compiled. It is declared in scripting_engine.h, already pulled in through functions.h.

src/aof.c is untouched: the kvs_it = NULL; fix from #5584 applied cleanly and is correct for 9.1. No files outside the listed paths were edited.

AI-edited files requiring review

Full backport commit diff: commit 02a761f8670f.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5644

Prevent size_t underflow in used_memory_dataset calculation

1 AI-edited file

Claude Summary

Validation should now get past the failure, but I couldn't run anything, so the adapted test is unverified until the re-run.

First real error: tests/unit/info.tcl:583 failed with invalid command name "test_defer". That helper does not exist anywhere under tests/ on 9.1.

Swapping the helper alone would not have been enough. The new test waits for used_memory_overhead to exceed used_memory by having 12 clients subscribe to one large channel, relying on pubsubMemOverhead() charging the channel size to each client. On 9.1, pubsubMemOverhead() only counts the per-client hashtable structure, so that condition is never reached and the test would time out with "used_memory_overhead never exceeded used_memory".

What I changed (tests/unit/info.tcl only; src/object.c is untouched):

  • Kept: the test name and its three assertions (used_memory_dataset, dataset.bytes and keys.bytes-per-key all equal 0).
  • Replaced: the setup that produces overhead > used_memory. It now uses the stale incremental client-memory tracking that the fix's own comment names as a cause:
    1. A second client queues 32 x 256KB SET commands inside MULTI.
    2. The test waits until mem_clients_normal reflects them.
    3. It runs debug pause-cron 1, then DISCARD, which frees the memory while the tracked value stays stale.
    4. It snapshots info memory and memory stats, unpauses the cron and closes the client before asserting.
  • Helpers: everything used already exists on 9.1 (valkey_client, debug pause-cron, wait_for_condition, getInfoProperty, assert_morethan).

From reading the code, the stale over-count should be about 8MB, and without the object.c clamp the dataset value would underflow, so it still works as a regression test for the fix.

The test body now differs from the source PR's, so it deserves a reviewer's look. If you would rather not carry a diverged test on 9.1, the alternative is to drop it and keep only the object.c fix.

AI-edited files requiring review

Full backport commit diff: commit e688195c3a23.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5682

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

1 AI-edited file

Claude Summary

First real error: the new test in tests/integration/dual-channel-replication.tcl aborted with invalid command name "test_defer". That helper does not exist in the 9.1 test framework, and the exception left the run to time out.

Fix: in tests/integration/dual-channel-replication.tcl I replaced the test_defer call with a try { ... } finally { catch {exec kill -9 $pid} } around the rest of the test body. The fake primary is still killed when the test ends, pass or fail, which is what the source PR intended. try/finally is already used on 9.1 in tests/unit/tls.tcl.

Nothing was run here, so the fix is untested until validation is re-run.

The other two files are unchanged: src/replication.c compiled, and the other helpers and log messages the test relies on all exist on 9.1.

AI-edited files requiring review

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

Full backport commit diff: commit 29e1a74e2389.

Please review these AI resolutions for correctness before merging.

quanyeyang and others added 7 commits December 3, 2026 23:01
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>
A replica that still cannot reach its primary can get that primary voted
out after a partition heals, even though every other primary reaches it
again. This needs a first election that failed while the primary was cut
off, followed by a retry. The primary becomes a replica of the winner
and loses the writes the winner had not received.

Voters refuse a replica whose primary they see as up, unless the vote
request carries FORCEACK, a flag that skips that check. #2227 added it
so the best ranked replica can start its first election before the FAIL (failed)
mark reaches the voters, but the replica also sends it on every retry.
The other primaries clear the mark once it is older than twice the
cluster node timeout and they reach the primary again. The replica
cannot, so its retry, at least four node timeouts after the first
election, wins their votes.

Now the replica sends FORCEACK only while its FAIL mark is no older than
twice the cluster node timeout, the age at which primaries clear it. The
age restarts whenever the replica flags the primary again. The first
election after a FAIL and manual failover are unchanged. A retry after
an expired election always starts later than that, whatever the node
timeout, so the primaries judge it by their own view. Only the replica
knows how old its FAIL is, so the check lives there.

Fixes #5403

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Backport-Source-PR: 5446
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>
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>
…5713)

## Fix crash in `VM_GetClientInfoById` for a client without a connection

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

### Fix
`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.

### Testing
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>
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 3, 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 conflict in src/t_stream.c is resolved and no conflict markers remain; nothing was staged or committed (the file still shows as UU, as instructed).

The conflict: there was one marker region, in the doc comment above xclaimCommand (the 4. FORCE: paragraph). 9.1 had older wording of the two lines the PR replaces, so I took the PR's new text. The code hunks inside the claiming loop of xclaimCommand had already auto-merged correctly.

Result: the diff against HEAD matches the upstream commit exactly — +9/−10 in src/t_stream.c and +25 in tests/unit/type/stream-cgroups.tcl. The test file needed no adaptation; the new test landed in the same appendonly yes server block as upstream.

Target-branch checks:

  • mustObeyClient and streamEntryExists both exist on 9.1, and mustObeyClient covers the AOF client, primary, and slot-import clients.
  • AOF rewrite on 9.1 emits PEL entries as XCLAIM … JUSTID FORCE (rioWriteStreamPendingEntry in src/aof.c), so the fix applies as intended.

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

  • It compiles, with no warnings from t_stream.c.
  • unit/type/stream-cgroups passes in full: 73 passed, 0 failed, including the new AOF rewrite keeps PEL entries whose stream entry was deleted test.
  • With 9.1's unfixed t_stream.c, the new test fails (Expected '2' to be equal to '1'), so the bug is present on 9.1 and this backport fixes it.

I only ran that one test suite, not the full test run.

AI-edited files requiring review

Full backport commit diff: commit c68e04655946.

Please review these AI resolutions for correctness before merging.

@valkeyrie-ops

valkeyrie-ops Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

AI backport resolution: source PR #5446

Don't let a retried election demote a primary others see as up

1 AI-edited file

Claude Summary

The validation failure was in the new test, not the C change, and I adapted the test to 9.1; nothing was run, so the fix is unverified until the caller re-runs validation.

First real error: tests/unit/cluster/failover-force-ack.tcl failed with invalid command name "cluster_all_see_flag". That helper does not exist in 9.1's test support. The build itself succeeded, so src/cluster_legacy.c is untouched.

Two changes, both in tests/unit/cluster/failover-force-ack.tcl:

  1. The cluster_all_see_flag {1 2 3} ... call is replaced with three explicit cluster_has_flag [cluster_get_node_by_id N $R0_nodeid] fail checks, the same form the test already uses further down.

  2. The wait for R3's Failover auth ACK from &lt;R1&gt; ... (ACKs 1, quorum 2) log line is replaced with a wait on R1's log for Failover auth granted to &lt;R3 id&gt;. 9.1 never emits the ACK line, so this would have timed out as the next failure once the first was fixed. To support it, the test now captures R1's log position before pausing R0 and looks up R3's node id instead of R1's.

One difference in what the test checks: it now confirms R1 granted the vote, rather than that R3 received exactly one ACK. That R2 did not vote is still covered by the existing wait for R2's dropped auth-req packet.

The other debug commands, helpers and log messages the test uses are all present on 9.1.

AI-edited files requiring review

  • tests/unit/cluster/failover-force-ack.tcl — view diff

Full backport commit diff: commit 2b0b8f6d8779.

Please review these AI resolutions for correctness before merging.

madolson and others added 2 commits December 5, 2026 01:55
…#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>
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

1 AI-edited file

Claude Summary

The validation failure is fixed in the test file; nothing has been re-run, so the fix is untested until the caller re-validates.

First real error: the build passed, and ./runtest --single unit/cluster/manual-takeover failed with invalid command name "test_config_set". The new test from #5144 uses a test_config_set helper that does not exist on 9.1.

Fix: in tests/unit/cluster/manual-takeover.tcl, the two test_config_set {R 1} ... calls are now plain R 1 config set ... calls, the form other 9.1 tests use for these two configs:

  • R 1 config set key-load-delay 50
  • R 1 config set loading-process-events-interval-bytes 1024

I assumed the missing helper only adds restore-on-exit, which I could not check since it is absent from this branch. Nothing is restored after the test here, but this is the only test in its start_cluster block and the servers are torn down when it ends. The test already resets key-load-delay to 0 itself.

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

The run aborted at the first test_config_set call, so the rest of the new test has never executed on 9.1. The other helpers, configs and debug subcommand it uses all exist on this branch, but whether the takeover actually lands mid-load here is only known after the re-run.

AI-edited files requiring review

  • tests/unit/cluster/manual-takeover.tcl — view diff

Full backport commit diff: commit cf5a8f3d3c84.

Please review these AI resolutions for correctness before merging.

Baraa-Hasheesh and others added 2 commits December 5, 2026 05:12
…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: tests/integration/dual-channel-replication.tcl has no markers left, and the backport is the same size as upstream (2 files, +5/−4). I ran the full integration/dual-channel-replication unit on a scratch build of the resolved tree: 46 passed, 0 failed.

What the conflict was. Git put the incoming hunk in the wrong test. Upstream wraps the mid-stream test in a foreach compression {no lz4} loop, which 9.1 doesn't have (there is no repl-compression there), so the indentation differs by four spaces. 9.1 also ends with a fake-primary test from #5682 that upstream didn't yet have at #5558. Git anchored the hunk onto the tail of that fake-primary test, inside its try block, where $syncs and $primary don't even exist.

How I resolved it.

  • Conflict region: kept the 9.1 side as is, so the fake-primary test is unchanged from 9.1, and dropped the misplaced incoming lines.
  • The PR's actual change: applied it where it belongs on 9.1, inside test "Replica aborts streaming when the primary link breaks mid-stream". The call is now wait_for_ofs_sync $primary $replica 300 100 with the explanatory comment above it, at the local 12-space indent. I did not bring in the compression loop.
  • tests/support/util.tcl: the auto-merge was correct and needed no adaptation. It contains the only definition of wait_for_ofs_sync, and every existing caller passes two arguments, so the unchanged defaults keep them working.

Other checks.

  • The changed lines match the upstream commit exactly, apart from indentation.
  • The modified test and the fake-primary test passed on three further focused runs.
  • On 9.1 the helper honours custom maxtries/delay, keeps the 5 s default for two-argument calls, and prints both offsets on failure.

Running the modified test alone with --only on this file fails in an unrelated earlier block (around line 829), where setup code between tests depends on a skipped test. The full unit is the way to re
... summary truncated.

AI-edited files requiring review

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

Full backport commit diff: commit bee47e5d3a81.

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.