Repository navigation
8.12 cms - #1066
8.12 cms#1066
Conversation
* 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 renamke cell size key * fix test
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 8.12 #1066 +/- ##
==========================================
+ Coverage 82.97% 83.70% +0.72%
==========================================
Files 21 21
Lines 3360 3455 +95
==========================================
+ Hits 2788 2892 +104
+ Misses 572 563 -9 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 56864ae. Configure here.
| // headroom as INT64_MAX - counter, which wraps if counter is already above it. | ||
| if (cms->counter > (uint64_t)INT64_MAX) { | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
Upgrade rejects large CMS counters
Medium Severity
CMS_ValidateLoaded treats a total counter above INT64_MAX as impossible and refuses the sketch. The previous CMS.INCRBY path still advanced counter after cells saturated at UINT32_MAX, so a few large increments could legally exceed that bound. Loading that RDB (or replicating it) can fail after upgrade, including during full dataset load.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 56864ae. Configure here.





Note
Medium Risk
Changes CMS command semantics (overflow/underflow, new RDB field) and persistence format v1; backward compatible for existing data via encver 0, but clients depending on old saturation behavior will see errors instead.
Overview
This PR extends Count-Min Sketch (CMS) with configurable per-cell width, decrement support, and stricter overflow semantics on the Redis command surface and in persistence.
CMS.INITBYDIM/CMS.INITBYPROBaccept an optionalCELL_SIZEargument (1, 2, 4, or 8 bytes; default 4).CMS.INFOreportscell_size, andCMS.MERGErequires matching width, depth, and cell size. Command metadata (commands.json,cms_info.c) reflects the new arity and docs.CMS.INCRBYallows negative increments; failures returnCMS: INCRBY overfloworCMS: INCRBY underflowinstead of saturating cells atUINT32_MAX. Rejected updates roll back partial row updates and leave the sketch unchanged. Overflow limits depend on cell size and total count (capped atINT64_MAXfor RESP).The sketch implementation stores counts in variable-width cells, bumps RDB encoding to version 1 (persists
cell_size; v0 loads as 4-byte cells), andCMS_ValidateLoadedrejects craftedRESTOREpayloads with impossible counters or cell values. Patch version 8.11.81 and broad flow/unit tests cover cell sizes, decrements, merge rules, and corruption cases.Reviewed by Cursor Bugbot for commit 56864ae. Bugbot is set up for automated code reviews on this repo. Configure here.