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
dc803d25
Unverified
Commit
dc803d25
authored
Oct 01, 2020
by
Oran Agra
Committed by
GitHub
Oct 01, 2020
Browse files
Fix crash in script timeout during AOF loading (#7870)
parent
b8187d39
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
dc803d25
...
@@ -1547,16 +1547,20 @@ void resetClient(client *c) {
...
@@ -1547,16 +1547,20 @@ void resetClient(client *c) {
* path, it is not really released, but only marked for later release. */
* path, it is not really released, but only marked for later release. */
void
protectClient
(
client
*
c
)
{
void
protectClient
(
client
*
c
)
{
c
->
flags
|=
CLIENT_PROTECTED
;
c
->
flags
|=
CLIENT_PROTECTED
;
connSetReadHandler
(
c
->
conn
,
NULL
);
if
(
c
->
conn
)
{
connSetWriteHandler
(
c
->
conn
,
NULL
);
connSetReadHandler
(
c
->
conn
,
NULL
);
connSetWriteHandler
(
c
->
conn
,
NULL
);
}
}
}
/* This will undo the client protection done by protectClient() */
/* This will undo the client protection done by protectClient() */
void
unprotectClient
(
client
*
c
)
{
void
unprotectClient
(
client
*
c
)
{
if
(
c
->
flags
&
CLIENT_PROTECTED
)
{
if
(
c
->
flags
&
CLIENT_PROTECTED
)
{
c
->
flags
&=
~
CLIENT_PROTECTED
;
c
->
flags
&=
~
CLIENT_PROTECTED
;
connSetReadHandler
(
c
->
conn
,
readQueryFromClient
);
if
(
c
->
conn
)
{
if
(
clientHasPendingReplies
(
c
))
clientInstallWriteHandler
(
c
);
connSetReadHandler
(
c
->
conn
,
readQueryFromClient
);
if
(
clientHasPendingReplies
(
c
))
clientInstallWriteHandler
(
c
);
}
}
}
}
}
...
...
tests/unit/scripting.tcl
View file @
dc803d25
...
@@ -430,6 +430,45 @@ start_server {tags {"scripting"}} {
...
@@ -430,6 +430,45 @@ start_server {tags {"scripting"}} {
set res
set res
}
{
102
}
}
{
102
}
test
{
EVAL timeout from AOF
}
{
# generate a long running script that is propagated to the AOF as script
# make sure that the script times out during loading
r config set appendonly no
r config set aof-use-rdb-preamble no
r config set lua-replicate-commands no
r flushall
r config set appendonly yes
wait_for_condition 50 100
{
[
s aof_rewrite_in_progress
]
== 0
}
else
{
fail
"AOF rewrite can't complete after CONFIG SET appendonly yes."
}
r config set lua-time-limit 1
set rd
[
redis_deferring_client
]
set start
[
clock clicks -milliseconds
]
$rd eval
{
redis.call
(
'set',KEYS
[
1
]
,'y'
);
for i=1,1500000 do redis.call
(
'ping'
)
end return 'ok'
}
1 x
$rd flush
after 100
catch
{
r ping
}
err
assert_match
{
BUSY*
}
$err
$rd read
set elapsed
[
expr
[
clock clicks -milliseconds
]
-$start
]
if
{
$::verbose
}
{
puts
"script took
$elapsed
milliseconds"
}
set start
[
clock clicks -milliseconds
]
$rd debug loadaof
$rd flush
after 100
catch
{
r ping
}
err
assert_match
{
LOADING*
}
$err
$rd read
set elapsed
[
expr
[
clock clicks -milliseconds
]
-$start
]
if
{
$::verbose
}
{
puts
"loading took
$elapsed
milliseconds"
}
$rd close
r get x
}
{
y
}
r config set aof-use-rdb-preamble yes
r config set lua-replicate-commands yes
test
{
We can call scripts rewriting client->argv from Lua
}
{
test
{
We can call scripts rewriting client->argv from Lua
}
{
r del myset
r del myset
r sadd myset a b c
r sadd myset a b c
...
...
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