Add new OBJ_GCRA type#14905
Conversation
|
@sundb we had talked with @oranagra about this and generally agreed that a new data type sounds reasonable, instead of abusing a string object. That said the amount of new code for that specific use case seems an overkill to me. Another thing that came up while writing it - if we feel very strongly that a new type should be introduced - maybe it could be more generic one. GCRA stores a unix timestamp (in this case in microseconds). The new data type could be OBJ_TIMESTAMP or something like this. Not sure how useful would that be though. WDYT? |
I think long long * is sufficient. OBJ_TIMESTAMP is theoretically impossible to be used elsewhere in the future. |
oranagra
left a comment
There was a problem hiding this comment.
i skimmed over the file (except for gcra.c and gcra.tcl).
is is a lot of changes, and maybe we can find a way to make some of them in a way that the next time we add a simple type we'll have a little less (few of them may be more generic?).
anyway, despite being a lot of changes, if we do want WRONGTYPE error when people mix keys, then it is what it is.. there's no way around it.
|
@minchopaskal, as Oran wrote, let's try to see if we can make some of the changes more generic. |
It is modified with the new type already. |
🤖 Augment PR SummarySummary: Introduces a dedicated Redis object type ( Changes:
Technical notes: Uses pointer-int storage on 64-bit ( 🤖 Was this summary useful? React with 👍 or 👎 |
984f06d to
0f3be25
Compare
rename the utililty command gcrarecord to gcraSetTAT
Co-authored-by: debing.sun <[email protected]>
Co-authored-by: debing.sun <[email protected]>
Co-authored-by: debing.sun <[email protected]>
|
i don't see GCRASETVALUE was mentioned in the top comment, pls udpate the top comment, and check if anything missed. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 17b1f70. Configure here.
|
Hi @minchopaskal why do we exclude |
backwards compatibility? I rmbr I did the same for OVERWRITTEN/TYPE_CHANGED KSN, i.e if you upgrade redis you dont get some unexpected new notification type. But TBH I didn't give it much thought. |
I don't know the exact reason either, but I think you're right about that. |
i think that for KEYMISS, CHANGED, OVERWRITTEN it's a different story, because adding these notifications will affect users after upgrade even if they didn't change the app code. |
|
Ok makes sense. I reasoned you may upgrade to newer redis version but still not expect the new KSN. @oranagra so we add GCRA to NOTIFY_ALL? |
|
IMHO yes. |
After introducing GCRA algorithm into redis #14826 and subsequent introduction of new RATE_LIMIT object type - #14905. It was internally decided not to introduce GCRA into the new release. As still no decision is made on whether it will be kept or not in the future, this PR only makes the code related to GCRA dead - commands are inaccessible and AOF/RDB load+save is disabled. --------- Co-authored-by: debing.sun <[email protected]>

PR introduced a new rate limiting command which stores its internal implementation-detail data into a string key.
Since this will prevent a client from detecting type errors or accidental overwrites or value invalidations, f.e via SET or INCR this PR introduces a new data type - OBJ_GCRA specifically created for that new command.
OBJ_GCRA name subject to change.
Note
High Risk
Adds a new core object type with new RDB encoding and AOF/replication rewrite behavior, which can impact persistence compatibility and data consistency if mishandled. Touches multiple critical subsystems (object lifecycle, copy/defrag, modules, keyspace notifications, command table).
Overview
Introduces a dedicated
OBJ_GCRAvalue type for theGCRArate-limiting command, replacing the previous string-backed storage so type errors/overwrites are detectable and handled consistently.Adds full core support for the new type across persistence and runtime internals: RDB save/load via new
RDB_TYPE_GCRA, AOF rewrite support, dataset copy/dup, memory sizing, defrag, andDEBUG DIGESThandling. Replication/AOF propagation forGCRAis changed to rewrite into a new internal commandGCRASETVALUE, which also gets command-table/JSON docs, its own ACL category/group (rate_limit), and new keyspace notification classr(NOTIFY_RATE_LIMIT).Updates tests to cover RDB reload, DUMP/RESTORE, AOF rewrite, digest stability, and replication behavior for
GCRAkeys.Reviewed by Cursor Bugbot for commit 17b1f70. Bugbot is set up for automated code reviews on this repo. Configure here.