Skip to content

[JOB-FAILURE] Sanitizer error: ERROR: AddressSanitizer: unknown-crash at memcpy < memcpy < memtest_preserving_test in Daily #5439

Closed

Description

@valkeyrie-ops

Summary

The Daily CI job test-sanitizer-force-defrag failed without recording a test failure.

  • Failed step: test
  • CI link(s):
    • test-sanitizer-force-defrag: job log

Failure summary from the job log

[err]: Sanitizer error: ERROR: AddressSanitizer: unknown-crash at memcpy < memcpy < memtest_preserving_test

Auto-created by Test Failure Detector

Activity

  1. added
    test-failure
    on Nov 16, 2026
  2. valkeyrie-ops commented on Nov 16, 2026

    @valkeyrie-ops
    Author

    A tentative fix, prepared and checked in that job. Nothing was pushed and no PR was opened: a maintainer applies it, or not.

    What failed: test-sanitizer-force-defrag: server pid 61962 aborted on assertion cluster_legacy.c:8444 'primary->replicaof == NULL' in clusterNodeGetPrimary (reported as a Sanitizer error) during tests/unit/cluster/slave-selection.tcl, test 'New Master down consecutively'

    Root cause: The test pauses five primaries of one shard in turn and the harness resumes them all when the test ends. Node R3 (pid 61962) woke up and read about 30 seconds of buffered packets. At 00:28:26.483 it accepted an old packet from R12 saying R12 is a replica of R15. At 26.590 it received a packet from R15, which was itself catching up, saying R15 is a replica of R12. The 'Primary node changed for this replica?' block in clusterProcessPacket set R15->replicaof = R12 while R12->replicaof was still R15. The following updateShardId call walked the chain in clusterNodeGetPrimary and hit debugServerAssert(primary->replicaof == NULL). The crash report's memory test then tripped AddressSanitizer inside memtest_preserving_test, which is the report the job printed. The existing stale-packet check and the promotion of a claimed primary that is still a replica only run when the sender was last seen as a primary, so a sender last seen as a replica has no protection. The failure is flaky.

    The fix: The sender's packet is first hand information about whom it replicates from, so a node it follows cannot still be its replica. When our view says it is, the patch calls clusterSetNodeAsPrimary on the claimed primary before linking the sender, which is what the existing branch for a sender last seen as a primary already does. The view then converges through the nodes' next packets as before. A test change would not be right: the test body passed, and the crash comes from the server's handling of packets that any node frozen and resumed in production would also read. Keeping paused nodes stopped or killing them at cleanup would only hide the cycle that the debug assertion exists to catch.

    What the bot checked

    • No merged change that looks like a fix was found.

    • Code could not tell from the log which test failed, so it ran the one the author named: New Master down consecutively in tests/unit/cluster/slave-selection.tcl. Check against the log that it is the test that failed.

    • With the fix, this command passed 40 loops:

      make -j"$(getconf _NPROCESSORS_ONLN)" all-with-unit-tests OPT=-O3 SANITIZER=address DEBUG_FORCE_DEFRAG=yes USE_JEMALLOC=no SERVER_CFLAGS='-Werror' USE_LIBBACKTRACE=yes && ./runtest --accurate --verbose --dump-logs --single unit/cluster/slave-selection --only 'New Master down consecutively' --fastfail --loops 40 --timeout 600
    • Review: The diagnosis matches the log and the code. The only error in the job is the abort of pid 61962 (R3), and its log shows 'New Master down consecutively' in slave-selection.tcl as the last test started, which the harness reported as ok just as the paused nodes were resumed. R3's own lines show R12 recorded as a replica of R15 at 26.483 from an old packet, R15 demoted under R6 at 26.589 through the protected branch for a sender last seen as a primary, and then R15 linked under R12 at 26.590 through the unguarded 'Primary node changed' block, leaving R15 and R12 pointing at each other. The next updateShardId call then hit the debug assertion in clusterNodeGetPrimary (line 8444 in the job's tree, with the stack at 1492 and 4696). The failover order in the log (R0, R3, R15, R9, R6, R12) means R15's claim was the current one and R12's was stale, so promoting R12 with the existing clusterSetNodeAsPrimary helper gives the correct view, mirrors what the sibling branch already does, and only fires where a cycle would otherwise form. A test or harness change would only hide a cycle that any frozen and resumed node could build, so a small change in src is the right place. The author is open about the limits: a longer cycle and the myself case are not covered, no deterministic test is added, and the 40 passing loops do not prove much for such a rare interleaving. I did not build or run anything myself.

    The agent's own notes

    Nothing was compiled or run, and the change was not passed through clang-format-18. The log establishes the exact packet order and the two-node cycle (R15 and R12) from R3's own log lines, and the assertion and stack match lines 8444, 1492 and 4696 of the working tree. The harness printed [ok] for the test; the abort was picked up from the server's stderr, and the test named is the last one the crashed server's log shows starting. Limits of the patch: it handles only a direct two-node cycle, which is what the log shows. A longer cycle through an intermediate replica is not covered, because walking the chain safely would need more code than this failure justifies. The case where the claimed primary is myself is deliberately left alone, since a node should not promote itself on a peer's claim; the existing guard 'myself->replicaof->replicaof != myself' shows that state was already anticipated. The patch does not copy the claimed config epoch onto the promoted node, unlike the sibling branch, because there is no staleness check on this path; the node's own next packet as a primary updates it. The AddressSanitizer report in memtest_preserving_test during the crash report is a consequence of the assertion and is not addressed. No new test is added because reproducing this needs a specific interleaving of buffered packets from several paused nodes.

    Proposed patch:

    diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c
    index 01875b455..04eebd42f 100644
    --- a/src/cluster_legacy.c
    +++ b/src/cluster_legacy.c
    @@ -4651,6 +4651,14 @@ int clusterProcessPacket(clusterLink *link) {
     
                     /* Primary node changed for this replica? */
                     if (sender_claimed_primary && sender->replicaof != sender_claimed_primary) {
    +                    /* `sender_claimed_primary` can still be a replica of `sender` in our view when
    +                     * `sender` announces its new primary before that node's own role change reaches
    +                     * us. `sender` replicates from it, so it is a primary; reconfigure it, otherwise
    +                     * the two nodes would form a primary-replica cycle. */
    +                    if (sender_claimed_primary != myself && sender_claimed_primary->replicaof == sender) {
    +                        clusterSetNodeAsPrimary(sender_claimed_primary);
    +                    }
    +
                         if (sender->replicaof) clusterNodeRemoveReplica(sender->replicaof, sender);
                         serverLog(LL_NOTICE, "Node %.40s (%s) is now a replica of node %.40s (%s) in shard %.40s",
                                   sender->name, humanNodename(sender), sender_claimed_primary->name,

    From run 43779215305, job test-sanitizer-force-defrag.

  3. added a commit that references this issue on Nov 23, 2026
    28ef86b
  4. added 5 commits that reference this issue on Nov 25, 2026
    22a89ca
    98d831a
    bc2f291
    7f7311a
    6c70b2c
  5. added a commit that references this issue on Nov 25, 2026
    8820d0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    test-failure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions