Skip to content

fix(miss-tracking): enable arbitrary-command miss tracking on cluster shard connections - #477

Merged
fcostaoliveira merged 1 commit into
masterfrom
fix/issue-476-cluster-misstracking
Jun 17, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
fix/issue-476-cluster-misstracking

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jun 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #476. Follow-up to the RED-200840 miss-tracking work (#469, #472).

Problem

Arbitrary-command per-element miss tracking (set_track_elem_misses) was applied in setup_client() only to the connections that exist at setup time. In OSS cluster mode the per-shard connections are created later, during cluster-slots discovery (cluster_client::create_shard_connection), and the shard_connection ctor clones its protocol via clone() — which resets runtime flags to defaults. Those late-created connections started with miss tracking cleared, so only requests routed to the seed connection's shard were accounted (~1/num_shards coverage); the rest were silently dropped from the per-key miss stats.

Fix

Factor the tracking-flag decision into client::apply_arbitrary_tracking_flags() plus a cached m_arbitrary_needs_elem_tracking flag computed once in setup_client(). Apply it to each connection in setup_client() and, crucially, to every shard connection created in cluster_client::create_shard_connection().

Verification

Against a live 3-shard OSS cluster (--cluster-mode, HMGET with 4 fields, 800 ops):

positions accounted coverage
before fix 1,200 38% (seed shard only)
after fix 3,200 100%

Per-position hit/miss semantics unchanged (f0/f1/f2 present → hits; absent field → 100% miss in its bucket). Standalone is unaffected (its single connection always carried the flag).

Adds test_arbitrary_hmget_full_coverage_cluster_and_standalone, which does not skipOnCluster and asserts full per-position coverage in both topologies — it fails on cluster before this fix and passes after.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 [email protected]


Note

Medium Risk
Changes cluster connection setup and protocol flags for miss accounting; behavior is localized and covered by a cluster+standalone regression test, but incorrect flag application would skew benchmark miss metrics.

Overview
Fixes issue #476: in OSS cluster mode, per-element arbitrary-command miss tracking (set_track_elem_misses) was only applied to connections that existed during setup_client(). Shard connections created later via cluster_client::create_shard_connection() get a fresh protocol from clone(), so the tracking flag stayed off and ~1/num_shards of HMGET/MGET-style traffic was missing from per-key miss stats.

The PR caches whether any configured command needs ArrayPerElementNulls tracking in m_arbitrary_needs_elem_tracking, centralizes application in apply_arbitrary_tracking_flags(), and calls it from setup_client() and create_shard_connection() so every shard connection gets the flag.

Adds test_arbitrary_hmget_full_coverage_cluster_and_standalone, which runs in cluster and standalone and asserts total hits+misses equals requests × clients × fields (fails on cluster before the fix).

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fdcf987. Configure here.

Comment thread tests/test_arbitrary_command_misses.py Resolved
@jit-ci

jit-ci Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@fcostaoliveira
fcostaoliveira force-pushed the fix/issue-476-cluster-misstracking branch from fdcf987 to 9800297 Compare June 17, 2026 01:20
… shard connections

Arbitrary-command per-element miss tracking (set_track_elem_misses) was applied
in setup_client() only to the connections that exist at setup time. In OSS
cluster mode the per-shard connections are created later, during cluster-slots
discovery (cluster_client::create_shard_connection), and the shard_connection
ctor clones its protocol via clone(), which resets runtime flags to defaults.
Those late-created connections therefore started with miss tracking cleared, so
only requests routed to the seed connection's shard were accounted -- roughly
1/num_shards coverage -- and the rest were silently dropped from the per-key
miss stats. (issue #476, follow-up to RED-200840.)

Factor the tracking-flag decision into client::apply_arbitrary_tracking_flags()
and a cached m_arbitrary_needs_elem_tracking flag, computed once in
setup_client(). Apply it to each connection in setup_client() and, crucially,
to every shard connection created in cluster_client::create_shard_connection().

Verified against a live 3-shard OSS cluster (HMGET, 4 fields): before, only ~38%
of reply positions were accounted (the seed shard's share); after, 100% are
accounted, with per-position hit/miss semantics unchanged. Standalone is
unaffected (single connection always carried the flag).

Adds test_arbitrary_hmget_full_coverage_cluster_and_standalone, which does not
skipOnCluster and asserts full per-position coverage in both topologies; it
fails on cluster before this fix and passes after.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@fcostaoliveira
fcostaoliveira force-pushed the fix/issue-476-cluster-misstracking branch from 9800297 to 320e07b Compare June 17, 2026 01:41
@fcostaoliveira
fcostaoliveira merged commit 41371a5 into master Jun 17, 2026
159 of 160 checks passed
@fcostaoliveira
fcostaoliveira deleted the fix/issue-476-cluster-misstracking branch June 17, 2026 02:17
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.

Arbitrary-command miss-tracking silently inactive in OSS cluster mode

1 participant