Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ddf984d0
Commit
ddf984d0
authored
Feb 20, 2023
by
Madelyn Olson
Committed by
Oran Agra
Feb 28, 2023
Browse files
Prevent Redis from crashing from key tracking invalidations (#11814)
parent
feb796d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/tracking.c
View file @
ddf984d0
...
...
@@ -393,10 +393,10 @@ void trackingInvalidateKey(client *c, robj *keyobj, int bcast) {
continue
;
}
/* If target is current client, we need schedule key invalidation.
/* If target is current client
and it's executing a command
, we need schedule key invalidation.
* As the invalidation messages may be interleaved with command
* response and should after command response */
if
(
target
==
server
.
current_client
)
{
* response and should after command response
.
*/
if
(
target
==
server
.
current_client
&&
server
.
fixed_time_expire
)
{
incrRefCount
(
keyobj
);
listAddNodeTail
(
server
.
tracking_pending_keys
,
keyobj
);
}
else
{
...
...
tests/unit/tracking.tcl
View file @
ddf984d0
...
...
@@ -739,6 +739,44 @@ start_server {tags {"tracking network"}} {
assert_equal
{}
$prefixes
}
test
{
Regression test for #11715
}
{
# This issue manifests when a client invalidates keys through the max key
# limit, which invalidates keys to get Redis below the limit, but no command is
# then executed. This can occur in several ways but the simplest is through
# multi-exec which queues commands.
clean_all
r config set tracking-table-max-keys 2
# The cron will invalidate keys if we're above the limit, so disable it.
r debug pause-cron 1
# Set up a client that has listened to 2 keys and start a multi, this
# sets up the crash for later.
$rd HELLO 3
$rd read
$rd CLIENT TRACKING on
assert_match
"OK"
[
$rd
read
]
$rd mget
"1{tag}"
"2{tag}"
assert_match
"{} {}"
[
$rd
read
]
$rd multi
assert_match
"OK"
[
$rd
read
]
# Reduce the tracking table keys to 1, this doesn't immediately take affect, but
# instead will apply on the next command.
r config set tracking-table-max-keys 1
# This command will get queued, so make sure this command doesn't crash.
$rd ping
$rd exec
# Validate we got some invalidation message and then the command was queued.
assert_match
"invalidate *{tag}"
[
$rd
read
]
assert_match
"QUEUED"
[
$rd
read
]
assert_match
"PONG"
[
$rd
read
]
r debug pause-cron 0
}
{
OK
}
{
needs:debug
}
$rd_redirection close
$rd close
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment