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
1dbe1eae
Commit
1dbe1eae
authored
Jun 04, 2020
by
antirez
Browse files
TCC: block clients on EXEC as well.
parent
ea3f7c6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
1dbe1eae
...
@@ -1869,19 +1869,40 @@ int clientShouldWaitOnLockedKeys(client *c, int queue) {
...
@@ -1869,19 +1869,40 @@ int clientShouldWaitOnLockedKeys(client *c, int queue) {
* so: our threads are just reading from the locked objects. */
* so: our threads are just reading from the locked objects. */
if
(
!
(
c
->
cmd
->
flags
&
CMD_WRITE
)
&&
if
(
!
(
c
->
cmd
->
flags
&
CMD_WRITE
)
&&
c
->
cmd
->
proc
!=
evalCommand
&&
c
->
cmd
->
proc
!=
evalCommand
&&
c
->
cmd
->
proc
!=
evalShaCommand
)
c
->
cmd
->
proc
!=
evalShaCommand
&&
c
->
cmd
->
proc
!=
execCommand
)
{
{
return
0
;
return
0
;
}
}
int
locked
=
0
;
int
locked
=
0
,
numkeys
,
*
keyidx
;
int
numkeys
;
if
(
c
->
flags
&
CLIENT_MULTI
)
{
int
*
keyidx
=
getKeysFromCommand
(
c
->
cmd
,
c
->
argv
,
c
->
argc
,
&
numkeys
);
for
(
int
j
=
0
;
j
<
c
->
mstate
.
count
;
j
++
)
{
for
(
int
j
=
0
;
j
<
numkeys
;
j
++
)
{
struct
redisCommand
*
cmd
=
c
->
mstate
.
commands
[
j
].
cmd
;
if
(
queueClientIfKeyIsLocked
(
c
,
c
->
argv
[
keyidx
[
j
]],
queue
))
locked
++
;
/* Even in the case of transactions, read only commands
* do not require we to sleep for the locked keys. */
if
(
!
(
cmd
->
flags
&
CMD_WRITE
)
&&
cmd
->
proc
!=
evalCommand
&&
cmd
->
proc
!=
evalShaCommand
)
continue
;
keyidx
=
getKeysFromCommand
(
cmd
,
c
->
mstate
.
commands
[
j
].
argv
,
c
->
mstate
.
commands
[
j
].
argc
,
&
numkeys
);
for
(
int
j
=
0
;
j
<
numkeys
;
j
++
)
{
if
(
queueClientIfKeyIsLocked
(
c
,
c
->
argv
[
keyidx
[
j
]],
queue
))
locked
++
;
}
getKeysFreeResult
(
keyidx
);
}
}
else
{
keyidx
=
getKeysFromCommand
(
c
->
cmd
,
c
->
argv
,
c
->
argc
,
&
numkeys
);
for
(
int
j
=
0
;
j
<
numkeys
;
j
++
)
{
if
(
queueClientIfKeyIsLocked
(
c
,
c
->
argv
[
keyidx
[
j
]],
queue
))
locked
++
;
}
getKeysFreeResult
(
keyidx
);
}
}
getKeysFreeResult
(
keyidx
);
/* Lock the client and return if we are waiting for at least one
/* Lock the client and return if we are waiting for at least one
* key. */
* key. */
...
...
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