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
30514300
Commit
30514300
authored
Jul 15, 2020
by
Luke Palmer
Committed by
Oran Agra
Jul 20, 2020
Browse files
Send null for invalidate on flush (#7469)
(cherry picked from commit
5f716ea4
)
parent
29b20fd5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tracking.c
View file @
30514300
...
...
@@ -198,9 +198,11 @@ void trackingRememberKeys(client *c) {
*
* In case the 'proto' argument is non zero, the function will assume that
* 'keyname' points to a buffer of 'keylen' bytes already expressed in the
* form of Redis RESP protocol, representing an array of keys to send
* to the client as value of the invalidation. This is used in BCAST mode
* in order to optimized the implementation to use less CPU time. */
* form of Redis RESP protocol. This is used for:
* - In BCAST mode, to send an array of invalidated keys to all
* applicable clients
* - Following a flush command, to send a single RESP NULL to indicate
* that all keys are now invalid. */
void
sendTrackingMessage
(
client
*
c
,
char
*
keyname
,
size_t
keylen
,
int
proto
)
{
int
using_redirection
=
0
;
if
(
c
->
client_tracking_redirection
)
{
...
...
@@ -342,17 +344,19 @@ void trackingInvalidateKey(client *c, robj *keyobj) {
trackingInvalidateKeyRaw
(
c
,
keyobj
->
ptr
,
sdslen
(
keyobj
->
ptr
),
1
);
}
/* This function is called when one or all the Redis databases are flushed
* (dbid == -1 in case of FLUSHALL). Caching keys are not specific for
* each DB but are global: currently what we do is send a special
* notification to clients with tracking enabled, invalidating the caching
* key "", which means, "all the keys", in order to avoid flooding clients
* with many invalidation messages for all the keys they may hold.
/* This function is called when one or all the Redis databases are
* flushed (dbid == -1 in case of FLUSHALL). Caching keys are not
* specific for each DB but are global: currently what we do is send a
* special notification to clients with tracking enabled, sending a
* RESP NULL, which means, "all the keys", in order to avoid flooding
* clients with many invalidation messages for all the keys they may
* hold.
*/
void
freeTrackingRadixTree
(
void
*
rt
)
{
raxFree
(
rt
);
}
/* A RESP NULL is sent to indicate that all keys are invalid */
void
trackingInvalidateKeysOnFlush
(
int
dbid
)
{
if
(
server
.
tracking_clients
)
{
listNode
*
ln
;
...
...
@@ -361,7 +365,7 @@ void trackingInvalidateKeysOnFlush(int dbid) {
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
client
*
c
=
listNodeValue
(
ln
);
if
(
c
->
flags
&
CLIENT_TRACKING
)
{
sendTrackingMessage
(
c
,
""
,
1
,
0
);
sendTrackingMessage
(
c
,
shared
.
null
[
c
->
resp
]
->
ptr
,
sdslen
(
shared
.
null
[
c
->
resp
]
->
ptr
),
1
);
}
}
}
...
...
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