Repository navigation
MOD-17398 CMS Extention - #1063
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1063 +/- ##
==========================================
+ Coverage 83.03% 83.70% +0.66%
==========================================
Files 21 21
Lines 3360 3455 +95
==========================================
+ Hits 2790 2892 +102
+ Misses 570 563 -7 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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 4e16351. Configure here.
| self.assertEqual([5], self.cmd('cms.incrby', 'cms2', 'a', '5')) | ||
| self.assertEqual([5], self.cmd('cms.query', 'cms2', 'a')) | ||
| self.assertEqual(['width', 2000, 'depth', 7, 'count', 5], | ||
| self.assertEqual(['width', 2000, 'depth', 7, 'count', 5, 'cell size', 4], |
There was a problem hiding this comment.
Stale CMS memory usage assertion
Low Severity
test_simple still expects MEMORY USAGE of 856/840 for a default 20x5 sketch, but CMSketch gained a cellSize field and grew from 32 to 40 bytes on 64-bit. CMSMemUsage reports sizeof *cms plus the array, so the command result increases by 8 and this exact equality fails.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4e16351. Configure here.
| static const RedisModuleCommandInfo CMS_INCRBY_INFO = { | ||
| .version = REDISMODULE_COMMAND_INFO_VERSION, | ||
| .summary = "Increases the count of one or more items by increment", | ||
| .summary = "Changes the count of one or more items by increment, which may be negative", |
There was a problem hiding this comment.
this is a weird summary
Adjusts the count of one or more items by the specified amount, which may be positive or negative.
| RedisModule_ReplyWithSimpleString(ctx, "cell size"); | ||
| RedisModule_ReplyWithLongLong(ctx, cms->cellSize); |
There was a problem hiding this comment.
check if this braking changed well doc
There was a problem hiding this comment.
written in the PR desc + tested
| break; | ||
| } | ||
| } | ||
| RedisModule_ReplicateVerbatim(ctx); |
There was a problem hiding this comment.
do u call replicte even though every incrby might fail
There was a problem hiding this comment.
Yes, as same fo the rest of the commands.
| // First pass validates the whole operation, so that a rejected increment | ||
| // leaves the sketch untouched. | ||
| for (size_t i = 0; i < cms->depth; ++i) { | ||
| uint32_t hash = CMS_HASH(item, itemlen, i); |
There was a problem hiding this comment.
computing hash twice , why not caching it in stucked array ?
| for (size_t i = 0; i < cms->depth; ++i) { | ||
| uint32_t hash = CMS_HASH(item, itemlen, i); | ||
| size_t loc = (hash % cms->width) + (i * cms->width); | ||
| const size_t loc = (i < CMS_LOC_SCRATCH) |
There was a problem hiding this comment.
this fix is not good enough
it is a patch
|
* MOD-17398 CMS Extention (#1063) * MOD-17398 CMS Extention * add test * fixes * incrby summery change * opt - cache some values(capped) to skip calculating hash twice in `CMS_IncrBy` * Undo writes on error instead * move undo incrs to a function * cms info rename cell size key (#1064) * cms info renamke cell size key * fix test * bump versionbump version
* MOD-17398 CMS Extention (#1063) * MOD-17398 CMS Extention * add test * fixes * incrby summery change * opt - cache some values(capped) to skip calculating hash twice in `CMS_IncrBy` * Undo writes on error instead * move undo incrs to a function * cms info rename cell size key (#1064) * cms info renamke cell size key * fix test * MOD-18487 - Reject excessive Bloom filter hash counts during restore (#1067) * Reject excessive Bloom filter hash counts during restore * added test which explicitly checks BLOOM_MAX_HASHES * MOD-18751: waive cluster bus protected mode for the oss-cluster phase (#1068) * MOD-18751: waive cluster bus protected mode for the oss-cluster phase redis/redis#15722 added cluster-bus-port-protected-mode, and on the 8.12 line it defaults to enabled: a node started with cluster-enabled and without tls-cluster then refuses to start, because its cluster bus port would be unauthenticated. That is how the oss-cluster phase is built, so every shard dies at startup and each test fails at connect with "Connection refused". The refusal happens while the configuration is validated, before the server opens its logfile, so the retained logs are empty and say nothing about the cause. Waive it for that phase. The bus ports here are bound to localhost on an ephemeral host, which is the condition the directive documents for waiving, and they were equally unauthenticated before the redis change - which only made running them an explicit choice. The option is not passed blind, because a redis that does not have it rejects the directive and fails to start the same way. RLTest takes it as an option rather than guessing, since nothing it can see distinguishes a build that has the option from one that does not: the 8.12 line reports 8.9.241 in version.h, the same as builds from before the change. CLUSTER_BUS_PROTECTED_MODE= omits it for anyone running the cluster phase against an older redis locally. The tls_cluster phase is left alone, since tls-cluster authenticates the bus, and so is the existing-env phase, where RLTest starts no servers. Requires RLTest with the option (RedisLabsModules/RLTest#255). * Trigger CI to build the image locally, so it installs RLTest 0.7.29 * MOD-18341 - Cap redis-py below 6 so the flow suite keeps a usable client Nothing here pinned the client, and RLTest's own requirement is uncapped (redis = ">=5.0.0"), so pip installs redis-py 8.1.0. From redis-py 6 on, a connection pool carries kwargs that Redis.__init__ does not accept, so the tests that rebuild a raw client out of an existing pool's connection_kwargs fail: raw = redis.Redis(**kwargs) TypeError: Redis.__init__() got an unexpected keyword argument 'himport_registry' That is every build-linux leg on both architectures, on four tests in test_cms and test_overall. Pin the client to the 5.x series, which is what the previous RLTest pin was capping it to in effect. * MOD-18922: drop the bullseye legs from the test matrices (#1069) Debian 11 reached end of LTS on 2026-08-31, and its packages have rotated off deb.debian.org/debian-security. The bullseye legs can therefore no longer build their Docker image whenever the image is built locally rather than pulled (i.e. on any PR carrying the docker-image-changes label): apt install 404s on the pinned Debian 11 package versions, and the leg reports no test result at all. Remove bullseye from the OS lists that drive the test legs only: - flow-linux.yml default lists (x64 and arm64) -> Event CI - event-nightly.yml (x64 and arm64) - flow-random-traffic.yml OS_LIST The release surface is deliberately left as it was: event-tag.yml and push-docker-images.yml keep bullseye, so tagged builds still publish a Debian 11 artifact and image. Dockerfile.bullseye and .install/os/bullseye.sh are kept for the same reason. Co-authored-by: Claude Opus 5 <[email protected]> * MOD-18559 - Fix missing command info for CF.COMPACT (#1071) * MOD-18559 - Fix missing command info for CF.COMPACT Adds CF.COMPACT metadata with arity 2, a single read/write key specification, and argument documentation. This lets RAMP packing consume explicit metadata instead of fallback values. Existing command flags remain unchanged. Adds regression coverage for command metadata, key extraction, argument errors, and successful execution. Validation: local build and both targeted tests passed. Redis Enterprise proxy routing remains unverified. * fix linter issue * MOD-18948: verify every write command replicates to the replica (#1072) * MOD-18948: verify every write command replicates to the replica A write command can be implemented correctly on the primary while its propagation to the replica is wrong or missing, and nothing in the suite catches it. MOD-16050 is the canonical case: CF.LOADCHUNK replicated only its header chunk and never the data chunks. The divergence was silent -- master_link_status:up, matching replication offsets, CF.INFO reporting the full inserted count on both sides -- and only surfaced as total data loss when a failover promoted the replica. Add tests/flow/test_replication.py, a table of one representative invocation per write command (23 of them, covering bf/cf/cms/topk/tdigest). Each row runs on the primary, waits for the replica to ack, then compares the key set, the DUMP payload of every key, and a semantic read-back. The invocation per command is chosen to be the form most likely to diverge rather than the simplest one: autocreate-on-write instead of a pre-reserved key, a scaling BF.INSERT instead of a single add, a full SCANDUMP chunk round-trip instead of a header. No argument permutations. Two details worth noting: - topk.add and topk.incrby are exempt from the DUMP comparison. HeavyKeeper decays counters with an unseeded rand(), so the replica re-executing the same command legitimately ends up with a different internal layout. The key set and the value read-backs are still compared. - A read that returns the type default proves nothing, since both sides match trivially. Every row asserts the primary's read-back is non-default before comparing it, and asserts WAIT actually acked. testEveryWriteCommandIsCovered enumerates write commands from the running server via COMMAND LIST FILTERBY MODULE and fails if any is missing from the table, so a newly added command cannot land without a replication test. Co-Authored-By: Claude Opus 5 <[email protected]> * MOD-18948: skip the replication test on a cluster env tests.sh runs a `--env oss-cluster` variant, where RLTest's getSlaveConnection() is an unconditional `raise Exception('unsupported')`. The test errored there instead of skipping, and since a single failing variant fails the whole job this reddened every OS leg. Verified locally against all four tests.sh variants: general, --use-slaves and --use-aof pass, oss-cluster now skips. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]> * MOD-18948: don't start a replica under --use-aof in test_replication (#1073) Since #1072, arm64 nightly jobs hang in the --use-aof env group until the 360-minute cancel: test_replication reports, and the class that runs next never does. Bloom has no per-test timeout, so the hang leaves no trace, but RedisJSON's identical test hit the same group with a 1800 s per-test timeout, and its traceback shows where it sits: after the test passed, RLTest stopping the test's replica -- redis_std.py stopEnv -> _stopProcess(SLAVE) -> process.communicate() RLTest sends SIGTERM, waits 30 s, then calls communicate() with no timeout. The same hang predates this test (RedisJSON's test_mset_replication_in_aof, another replica running with AOF), but in the --use-aof group no other test starts a replica, so test_replication is what brings one in. - testWriteCommandsReplicate skips under AOF, before it builds the replica env. Replication stays covered by the general and --use-slaves groups. - testEveryWriteCommandIsCovered no longer asks for a replica at all: it only reads the command table, and on RedisJSON it was the test whose teardown hung. Locally, every tests.sh variant passes, and under --use-aof no replica is started any more. Co-authored-by: Claude Opus 5.5 <[email protected]> * MOD-19291: bound RLTest teardown and flow test timeouts (#1074) * MOD-19291: bound RLTest teardown and flow test timeouts Configure shared Env creation to retry shutdown for 20 seconds before SIGKILL, preventing stalled replicas from blocking teardown indefinitely. Add a configurable per-test timeout: 30 minutes by default and 3 hours under Valgrind. * increase timeout to vg * MOD-19365 Use released RLTest 0.7.31 for module tests (#1076) * if redis does not expose the adress - using hardcoded addr (#1075) * update version to 8.11.90 --------- Co-authored-by: Aviv David <[email protected]> Co-authored-by: LiranAbir <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Tom Gabsow <[email protected]>






Features
CELL_SIZE 1|2|4|8—CMS.INITBYDIMandCMS.INITBYPROBaccept an optional trailingCELL_SIZEargument selecting bytes per counter cell, cutting memory up to 4× for low-count workloads (1000×5 sketch: 5072 B atCELL_SIZE1 vs 40072 B at 8).CMS.INCRBY— increments may now be negative, decrementing an item's count when every one of its cells holds at least that magnitude.CMS.INFOreports cell size — the reply grows from 3 to 4 field pairs so clients can discover a sketch's cell width after creation.Behavior changes
UINT32_MAX, advancing the total count, and returning an error.CMS.MERGErequires a matching cell size across destination and all sources, erroring with CMS: cell size is not equal rather than reinterpreting a source's bytes at the wrong stride.INT64_MAXsoCMS.INFOcount cannot exceed what a RESP integer can carry (a row holds width cells each up toINT64_MAX).Fixes
rm_cms.cpreviously inferred overflow from a returned sentinel ofUINT32_MAX, which withCELL_SIZE1 would have reported a legitimate count of 255 as an error;CMS_IncrBynow returns an explicitCMSStatus.LLONG_MINincrements are rejected at the parse boundary with CMS: invalid increment, since its magnitude (2⁶³) exceeds every cell maximum by one and could only ever underflow.Note
Medium Risk
Changes CMS persistence format, overflow semantics (breaking for clients relying on saturation), and core counter arithmetic paths; extensive new tests mitigate regressions.
Overview
Extends Count-Min Sketch with configurable counter width and safer arithmetic, plus several behavior changes clients should know about.
CMS.INITBYDIM/CMS.INITBYPROBaccept optionalCELL_SIZE 1|2|4|8(default remains 4-byte cells). Sketches store counters in variable-width cells viacellGet/cellSet, which reduces memory for low-count workloads.CMS.INFOadds acell sizefield; RDB encoding bumps to version 1 (still loads old dumps as 4-byte cells).CMS.INCRBYnow allows negative increments (decrement) with explicitCMS: INCRBY underflowerrors;LLONG_MINis rejected at parse time. Overflow/underflow handling is all-or-nothing: failed updates roll back partial row writes and leave the totalcountunchanged—replacing the old saturate-to-UINT32_MAXbehavior.CMS_IncrByreturnsCMSStatusinstead of inferring overflow from a sentinel.CMS.MERGErequires matching cell size across sketches.RESTORE/RDB load runsCMS_ValidateLoadedto reject crafted payloads with impossible counters or 8-byte cell values aboveINT64_MAX. Command metadata incommands.jsonandcms_info.cis updated accordingly.Reviewed by Cursor Bugbot for commit 985b375. Bugbot is set up for automated code reviews on this repo. Configure here.