mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Reset command duration for rejected command. (#12247)
In 7.2, After 971b177fa
we make sure (assert) that
the duration has been recorded when resetting the client.
This is not true for rejected commands.
The use case I found is a blocking command that an ACL rule changed before
it was unblocked, and while reprocessing it, the command rejected and triggered the assert.
The PR reset the command duration inside rejectCommand / rejectCommandSds.
Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
parent
2d7d3911da
commit
0bfb6d5582
@ -3714,9 +3714,11 @@ void call(client *c, int flags) {
|
||||
* various pre-execution checks. it returns the appropriate error to the client.
|
||||
* If there's a transaction is flags it as dirty, and if the command is EXEC,
|
||||
* it aborts the transaction.
|
||||
* The duration is reset, since we reject the command, and it did not record.
|
||||
* Note: 'reply' is expected to end with \r\n */
|
||||
void rejectCommand(client *c, robj *reply) {
|
||||
flagTransaction(c);
|
||||
c->duration = 0;
|
||||
if (c->cmd) c->cmd->rejected_calls++;
|
||||
if (c->cmd && c->cmd->proc == execCommand) {
|
||||
execCommandAbort(c, reply->ptr);
|
||||
@ -3728,6 +3730,7 @@ void rejectCommand(client *c, robj *reply) {
|
||||
|
||||
void rejectCommandSds(client *c, sds s) {
|
||||
flagTransaction(c);
|
||||
c->duration = 0;
|
||||
if (c->cmd) c->cmd->rejected_calls++;
|
||||
if (c->cmd && c->cmd->proc == execCommand) {
|
||||
execCommandAbort(c, s);
|
||||
|
@ -323,6 +323,23 @@ start_server {tags {"acl external:skip"}} {
|
||||
$rd close
|
||||
} {0}
|
||||
|
||||
test {blocked command gets rejected when reprocessed after permission change} {
|
||||
r auth default ""
|
||||
r config resetstat
|
||||
set rd [redis_deferring_client]
|
||||
r ACL setuser psuser reset on nopass +@all allkeys
|
||||
$rd AUTH psuser pspass
|
||||
$rd read
|
||||
$rd BLPOP list1 0
|
||||
wait_for_blocked_client
|
||||
r ACL setuser psuser resetkeys
|
||||
r LPUSH list1 foo
|
||||
assert_error {*NOPERM No permissions to access a key*} {$rd read}
|
||||
$rd ping
|
||||
$rd close
|
||||
assert_match {*calls=0,usec=0,*,rejected_calls=1,failed_calls=0} [cmdrstat blpop r]
|
||||
}
|
||||
|
||||
test {Users can be configured to authenticate with any password} {
|
||||
r ACL setuser newuser nopass
|
||||
r AUTH newuser zipzapblabla
|
||||
|
Loading…
Reference in New Issue
Block a user