Skip to content

MOD-16600 Bump LibMR to master: fix the mr.c:939 assertion on 8.8 - #2139

Merged
gabsow merged 1 commit into
RedisTimeSeries:8.8from
gabsow:tom.gabsow/bump-libmr-mod16600
Aug 9, 2026
Merged

gabsow merged 1 commit into
RedisTimeSeries:8.8from
gabsow:tom.gabsow/bump-libmr-mod16600

Conversation

@gabsow

@gabsow gabsow commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

What

deps/LibMR a37b672 → c6a5ed62 (master), plus topologyEvents=false at the MR_Init call site — two lines total.

Why

The assertion LibMR #116 fixes is still reproducing on the RE8.8 nightly, because this branch has never carried #116. Build 100.0.20-7660 (2026-08-05), released TS 80802, shard redis-119:

21:22:23.033  <timeseries> cluster topology changed        (x5 within 4ms)
21:22:23.037  <timeseries> Got cluster set command (long form)
21:22:23.037  === REDIS BUG REPORT START
21:22:23.037  # ==> /workspace/deps/LibMR/src/mr.c:939 'false' is not true

Long-form CLUSTERSET → MR_SetClusterData → MR_ClusterFree() transiently reports a one-shard topology → a concurrent execution takes ExecutionFlag_Local → its StepType_InternalCommand reaches the worker path → assert. #116 holds the Redis lock across the free/rebuild so that state is never observable. It landed on LibMR master on 2026-07-26; a37b672 predates it.

Consequence today: MOD-16600 sits in verification against a lane that structurally cannot verify it. Liran has re-reported it on essentially every nightly.

Why bump to master instead of backporting

MR_Init is the only LibMR API that changed between the two pins. Of the 39 MR_* symbols this branch references, 32 are declared in LibMR headers, and MR_Init is the single one whose declaration differs — nothing was removed:

CHANGED MR_Init      changed: 1   removed: 0

So one extra argument is the entire compatibility cost — cheaper than a LibMR maintenance branch plus a cherry-pick for every future fix. (I opened both alternatives as RedisGears/LibMR#120 and #121 and closed them in favour of this.)

Why topologyEvents=false is correct, not just conservative

Redis on this line never emits the topology-change notification — the Enterprise cluster plugin says so at startup:

ClusterPlugin: Failed to load symbol: "clusterNotifyTopologyChanged",
               assuming this an old redis version w/out ASM

So the topology-event paths are unreachable here, not merely disabled. And MR_ClusterInit's entire diff between the two pins is clusterCtx.topologyEvents = topologyEvents; — no conditional registration, no behaviour branch — so false reproduces a37b672's behaviour exactly.

What else arrives with the bump

commit effect on 8.8
#104 skip rebuild on unchanged CLUSTERSET (MOD-16399) wanted
#108 fix execution leak on aborted initiator execution wanted
#111 / #115 gate inter-shard TLS on tls-cluster for native-cluster-view paths (MOD-16951) wanted — long-form CLUSTERSET keeps the historical tls-port fallback, and this branch shows the symptom they fix: 97 × execution max idle reached on redis-119 in the 7660 package
#117 / #119 topology-event adjustments inert with the flag off

Verification

  • Builds clean for linux-arm64 in rockylinux:9 + gcc-toolset-13 — the toolchain behind the shipped rhel9-arm64 artifact. Module links.
  • API check against pristine LibMR master: the 4-arg call compiles with 0 errors; the current 3-arg call fails with too few arguments to function call, expected 4, have 3, confirming the one-liner is both necessary and sufficient.
  • Flow suite not run locally — leaving that to CI, which is the real gate here.

Not fixed by this

MOD-16600's scenario has a second defect that this does not touch: the MOD-15896 Enterprise/OSS misdetection. The same 7660 packages show Detected redis oss (cluster-enabled=yes) on the ASM shards (×14 / ×24, versus ×180 correct enterprise (cluster-enabled=no) on non-cluster DBs), producing 1309 rejected timeseries.HELLO, 722 message was not sent because status is not connected, and 97 execution max idle reached on one shard. So expect the crash to stop and the scale-under-traffic scenario to possibly still fail until that is fixed separately.

8.6 / 8.4 pin the same a37b672 and can take the identical two-line change if wanted.


Note

Medium Risk
Touches cluster coordination and inter-shard execution (LibMR) at module init and during CLUSTERSET; wrong topologyEvents or regressions in the bump could affect MRANGE/MGET across shards, though false is chosen to preserve legacy behavior on 8.8.

Overview
Fixes MOD-16600 by moving deps/LibMR to current master so LibMR #116 is included: cluster topology rebuild during long-form CLUSTERSET no longer exposes a transient one-shard view that could trip the mr.c:939 assert on concurrent internal-command execution.

The only Timeseries call-site change is in register_mr: MR_Init now takes a fourth argument, false, because this Redis line does not emit topology-change notifications (ASM/clusterNotifyTopologyChanged is absent). That matches prior behavior on the old pin and keeps topology-event paths inactive.

The bump also pulls in unrelated LibMR fixes on this branch (e.g. skip redundant CLUSTERSET rebuild, execution leak fix, inter-shard TLS gating). A separate Enterprise/OSS cluster misdetection issue noted in MOD-16600 is not addressed here.

Reviewed by Cursor Bugbot for commit f0b9319. Bugbot is set up for automated code reviews on this repo. Configure here.

deps/LibMR a37b672 -> c6a5ed62, and pass topologyEvents=false at the MR_Init
call site.

Why: the assertion LibMR RedisTimeSeries#116 fixes is still reproducing on the RE8.8 nightly.
Build 100.0.20-7660 (2026-08-05), released TS 80802, shard redis-119:

    21:22:23.033  <timeseries> cluster topology changed        (x5 in 4ms)
    21:22:23.037  <timeseries> Got cluster set command (long form)
    21:22:23.037  === REDIS BUG REPORT START
    21:22:23.037  # ==> /workspace/deps/LibMR/src/mr.c:939 'false' is not true

Long-form CLUSTERSET -> MR_SetClusterData -> MR_ClusterFree() transiently
reports a one-shard topology -> a concurrent execution takes
ExecutionFlag_Local -> its StepType_InternalCommand reaches the worker path
-> assert. RedisTimeSeries#116 holds the Redis lock across the free/rebuild so that state is
never observable. It landed on LibMR master 2026-07-26; 8.8 pinned a37b672,
which predates it, so MOD-16600 could not be verified on that lane at all.

Why bump to master rather than backport: MR_Init is the only LibMR API that
changed between the two pins. Of the 39 MR_* symbols this branch references, 32
are declared in LibMR headers and MR_Init is the single one whose declaration
differs; nothing was removed. So one argument at the call site is the whole
compatibility cost, which is cheaper than a maintenance branch plus a
cherry-pick per fix.

topologyEvents=false is correct here, not merely conservative: redis on this
line never emits the topology-change notification -- the Enterprise cluster
plugin reports "Failed to load symbol: clusterNotifyTopologyChanged, assuming
this an old redis version w/out ASM" -- so those paths are unreachable, and
MR_ClusterInit's entire diff between the pins is
`clusterCtx.topologyEvents = topologyEvents;`, i.e. false reproduces the old
behaviour exactly.

Also arriving with this bump:
- RedisTimeSeries#104 skip the rebuild when CLUSTERSET carries an unchanged topology (MOD-16399)
- RedisTimeSeries#108 fix the execution leak when an initiator execution is aborted
- RedisTimeSeries#111/RedisTimeSeries#115 gate inter-shard TLS on tls-cluster for native-cluster-view paths
  (MOD-16951). Long-form CLUSTERSET keeps the historical tls-port fallback, and
  this branch shows the symptom they fix -- 97 "execution max idle reached" on
  redis-119 in the 7660 package.
- RedisTimeSeries#117/RedisTimeSeries#119 topology-event adjustments, inert with the flag off.

Verified: builds clean for linux-arm64 in rockylinux:9 + gcc-toolset-13 (the
toolchain behind the shipped rhel9-arm64 artifact). Flow suite not run locally
-- leaving that to CI.
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@gabsow
gabsow merged commit 594ca34 into RedisTimeSeries:8.8 Aug 9, 2026
15 of 56 checks passed
@gabsow

gabsow commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

Two corrections and one follow-up on this bump, from a per-commit audit of everything 8.8 inherited.

1. The TLS claim in the PR body is wrong. I wrote that #111/#115 "keep the historical tls-port fallback" for long-form CLUSTERSET. They do not. #115 deletes #111's carve-out verbatim — #111 contributes zero surviving lines — so the net delta a37b672 → c6a5ed62 is:

// a37b672
if (!clusterTls || strcmp(clusterTls,"yes")) { tlsPort = getConfigValue(...,"tls-port");
                                               if (!tlsPort || !strcmp(tlsPort,"0")) { ret=0; goto done; } }
// c6a5ed62 (src/cluster.c:548-558)
bool clusterTlsEnabled = clusterTls && !strcmp(clusterTls,"yes");
if (!clusterTlsEnabled) { ret = 0; goto done; }

i.e. inter-shard TLS is now strictly tls-cluster == yes for every topology form, long form included. One truth-table cell changes: tls-port != 0 with tls-cluster not yes went from TLS to plaintext — and it fails open, not closed: checkTLS returns 0, MR_OnConnectCallback falls through to SendAuthCommandIfNeeded (cluster.c:700 → :416) and AUTH <internal password> goes out in cleartext.

Unreachable in RE steady state — CNM writes tls-port and tls-cluster in the same branch (cnm/ops/redis/__init__.py:803-811, 1660-1670 are the only tls-port writers) — but reachable during the four separate CONFIG SET round-trips of a live internode-encryption enable, and permanently for any non-RE consumer using long-form CLUSTERSET with TLS endpoints. Release notes should state that tls-cluster yes is now required for inter-shard TLS. No release branch has a TLS leg, so neither the original bug nor a regression is catchable in CI.

2. 8.8 is now exposed to a fail-open → fail-closed change on short-form CLUSTERSET that I did not flag. #105 added two rejections to MR_BuildCluster that do not exist at a37b672 — duplicate slot claim (cluster.c:1155-1163) and coveredSlots != 16384 (1179-1186) — while keeping the pre-existing continue when RedisModule_GetClusterNodeInfo fails for a node. So a view that previously installed a degraded-but-multi-shard topology now returns NULL → REDISMODULE_ERR → clusterCtx stays at MR_ClusterFree's values (CurrCluster NULL, clusterSize 1, cluster.c:824) → MR_ClusterIsInClusterMode() false → IsMRCluster() false → TS.MRANGE / TS.MGET / TS.QUERYINDEX answer from the local shard only, with no error, until the next successful CLUSTERSET or REFRESHCLUSTER.

short_form_clusterset is in pack/ramp.yml here and tests/flow/test_asm.py is env.skip(), so only real Enterprise exercises it. Mitigating: #116's GIL hold makes the cluster-API reads a consistent snapshot, so it needs a genuinely forming/degraded view rather than routine resharding. Worth an explicit ASM soak with these log greps as the pass condition — zero hits for rejecting topology, Cluster topology covers %zu of, is claimed by two master nodes — paired with a cardinality assertion on multi-shard reads, since a local-only reply is a correct-looking success that an existence check will not catch.

3. Also inherited, worth knowing: #117 changed timeseries.INFOCLUSTER from a fixed 18-element node array to 14 + 4*ranges. Byte-identical for single-range nodes, but tests/flow/includes.py:75 and test_ts_libmr_failiure.py:29 read n[17] positionally — and so does origin/master:tests/flow/includes.py:89, so the consumer half of #117's own n[17]→n[-1] fix was never ported. It breaks on a multi-range or slotless master (a hang in verifyClusterInitialized, not a clean failure). Worth fixing on every branch that carries #117, master included.

None of this argues the bump was wrong — 8.8 is the only line where the mr.c:939 assert is reachable (6 MR_ExecutionBuilderInternalCommand call sites here versus 0 on 8.4/8.6), and it needs #108 and #104 too. It just needs the release note corrected and the soak run.

gabsow added a commit that referenced this pull request Aug 9, 2026
deps/LibMR a37b672 -> c6a5ed62, pass topologyEvents=false at MR_Init
(src/libmr_integration.c:795), and read INFOCLUSTER's status positionally from
the end instead of index 17.

The mr.c:939 assertion that motivated the 8.8 bump (#2139) cannot fire on this
line -- there are no MR_ExecutionBuilderInternalCommand call sites here, so no
execution contains a StepType_InternalCommand step. What this line does have is
the silent half of the same race: MR_ClusterFree sets clusterCtx.clusterSize = 1
while MR_CreateExecution reads it on the main thread, and an execution wrongly
flagged ExecutionFlag_Local skips the cross-shard collect, so TS.MRANGE /
TS.MGET / TS.QUERYINDEX answer from the local shard with no error. #116 closes
that by holding the Redis lock across the free/rebuild.

Taking master rather than cherry-picking #116 alone also brings #104
(MOD-16399, skip the rebuild for an unchanged CLUSTERSET), #108 (execution leak
on an aborted initiator execution), #111+#115 (MOD-16951, inter-shard TLS), and
the #117 INFOCLUSTER fix that removes a live assert here
(a37b672 src/cluster.c:1530, RedisModule_Assert(n->slotRanges->len == 1),
trippable by a multi-range or slotless master).

topologyEvents=false is correct rather than merely conservative: redis on this
line never emits the topology-change notification, and MR_ClusterInit's whole
diff between the two pins is 'clusterCtx.topologyEvents = topologyEvents;'.
MR_TopologyEventSeen has exactly one setter, MR_UpdateClusterTopology(), which
no release branch calls, so the gated branches are provably inert.

The test change is required by #117, which turns INFOCLUSTER's per-node reply
from a fixed 18 elements into 14 + 4*ranges. status is the last element in both
layouts, so n[-1] is correct before and after the bump; n[17] silently reads a
slot-range value once a node has more than one range and hangs
verifyClusterInitialized.

Two behaviour changes worth naming in the release notes:
- Inter-shard TLS now requires tls-cluster=yes. #115 deletes #111's long-form
  carve-out, so the tls-port fallback is gone for every topology form.
- Short-form CLUSTERSET is now fail-closed: MR_BuildCluster rejects a topology
  with a duplicate slot claim or coverage != 16384 instead of installing a
  degraded one. Rejection leaves the shard answering locally until the next
  successful CLUSTERSET, so watch for 'rejecting topology' in shard logs.

Verified: builds clean for linux-arm64 in rockylinux:9 + gcc-toolset-13. Flow
suite left to CI.
gabsow added a commit that referenced this pull request Aug 9, 2026
deps/LibMR a37b672 -> c6a5ed62, pass topologyEvents=false at MR_Init
(src/libmr_integration.c:796), and read INFOCLUSTER's status positionally from
the end instead of index 17.

The mr.c:939 assertion that motivated the 8.8 bump (#2139) cannot fire on this
line -- there are no MR_ExecutionBuilderInternalCommand call sites here, so no
execution contains a StepType_InternalCommand step. What this line does have is
the silent half of the same race: MR_ClusterFree sets clusterCtx.clusterSize = 1
while MR_CreateExecution reads it on the main thread, and an execution wrongly
flagged ExecutionFlag_Local skips the cross-shard collect, so TS.MRANGE /
TS.MGET / TS.QUERYINDEX answer from the local shard with no error. #116 closes
that by holding the Redis lock across the free/rebuild.

Taking master rather than cherry-picking #116 alone also brings #104
(MOD-16399, skip the rebuild for an unchanged CLUSTERSET), #108 (execution leak
on an aborted initiator execution), #111+#115 (MOD-16951, inter-shard TLS), and
the #117 INFOCLUSTER fix that removes a live assert here
(a37b672 src/cluster.c:1530, RedisModule_Assert(n->slotRanges->len == 1),
trippable by a multi-range or slotless master).

topologyEvents=false is correct rather than merely conservative: redis on this
line never emits the topology-change notification, and MR_ClusterInit's whole
diff between the two pins is 'clusterCtx.topologyEvents = topologyEvents;'.
MR_TopologyEventSeen has exactly one setter, MR_UpdateClusterTopology(), which
no release branch calls, so the gated branches are provably inert.

The test change is required by #117, which turns INFOCLUSTER's per-node reply
from a fixed 18 elements into 14 + 4*ranges. status is the last element in both
layouts, so n[-1] is correct before and after the bump; n[17] silently reads a
slot-range value once a node has more than one range and hangs
verifyClusterInitialized.

Two behaviour changes worth naming in the release notes:
- Inter-shard TLS now requires tls-cluster=yes. #115 deletes #111's long-form
  carve-out, so the tls-port fallback is gone for every topology form.
- Short-form CLUSTERSET is now fail-closed: MR_BuildCluster rejects a topology
  with a duplicate slot claim or coverage != 16384 instead of installing a
  degraded one. Rejection leaves the shard answering locally until the next
  successful CLUSTERSET, so watch for 'rejecting topology' in shard logs.

Verified: builds clean for linux-arm64 in rockylinux:9 + gcc-toolset-13. Flow
suite left to CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants