Repository navigation
[backport] Backport sweep for 9.1 - #5499
valkeyrie-ops[bot] wants to merge 60 commits into
Conversation
AI backport resolution: source PR #4951Fix MSETEX key discovery in cluster mode 2 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit 73839b7fa9f8.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
AI backport resolution: source PR #5417Abort dual-channel sync if the primary link breaks while streaming 2 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit ee02df3fd225.
|
AI backport resolution: source PR #4785Deflake COPY Preserves TTLs test under libc malloc 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 19cffcc4e2c1.
|
AI backport resolution: source PR #5358Zero the module key handle so CloseKey is safe after a Call changes the key's type 3 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit ef997316f571.
|
AI backport resolution: source PR #4675Fix cluster bus self-forget use-after-free 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit f434c3b377aa.
|
AI backport resolution: source PR #3245Fix assertion crash in processIOThreadsReadDone when DONT_PARSE client has stale argc 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit f0b595e1774f.
|
AI backport resolution: source PR #5090Keep an IFEQ/IFNE value spelled GET when propagating SET GET 7 AI-edited files Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 7095b0775f5e.
|
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>
AI backport resolution: source PR #5143Keep slot imports loaded during a swapdb full sync 2 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit 2bf51848db5b.
|
AI backport resolution: source PR #5596Limit the Lua debugger to the client that runs the session 2 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit 359a05ffd4e5.
|
* 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>
|
Automatic follow-up on this backport's CI. A fix for Proposed patchdiff --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} { |
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>
…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>
AI backport resolution: source PR #5153Do not let forked script debug sessions postpone automatic saves 2 AI-edited files Claude Summary
AI-edited files requiring review Full backport commit diff: commit 31aba53025a1.
|
AI backport resolution: source PR #5359Reset slot migration snapshot pipes when the snapshot fork fails 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit b6ec18691e38.
|
AI backport resolution: source PR #5369Sanitize FUNCTION LIST error replies 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 0803519c48a1.
|
AI backport resolution: source PR #5471Fix valkey-check-rdb --stats crash on keys before SELECTDB and huge DB IDs 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 483d73ba8690.
|
AI backport resolution: source PR #5526Fix flaky dual-channel mid-stream abort test under valgrind 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit dd3662afa9b2.
|
AI backport resolution: source PR #5556Refuse to load a replicaof cycle from nodes.conf 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit b4b1c50c52ea.
|
AI backport resolution: source PR #5584Fix double free of the key iterator on AOF rewrite write error 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 02a761f8670f.
|
AI backport resolution: source PR #5644Prevent size_t underflow in used_memory_dataset calculation 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit e688195c3a23.
|
AI backport resolution: source PR #5682Abort dual channel sync cleanly when main link write fails after $ENDOFF 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 29e1a74e2389.
|
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>
AI backport resolution: source PR #4973Fix AOF/slot-migration dropping deleted stream PEL entries 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit c68e04655946.
|
AI backport resolution: source PR #5446Don't let a retried election demote a primary others see as up 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit 2b0b8f6d8779.
|
…#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>
AI backport resolution: source PR #5144Don't finalize a full sync that was cancelled while loading from disk 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit cf5a8f3d3c84.
|
…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>
AI backport resolution: source PR #5558Extend offset-sync wait after mid-stream abort in dual-channel test 1 AI-edited file Claude Summary
AI-edited files requiring review
Full backport commit diff: commit bee47e5d3a81.
|
Backport sweep for 9.1
Automated cherry-picks from PRs marked "To be backported".
Applied
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)
Generated by valkey-ci-agent using Claude Code.