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
af5c1187
Unverified
Commit
af5c1187
authored
Apr 06, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
Apr 06, 2020
Browse files
Merge pull request #6797 from patpatbear/issue_#6565_memory_borderline
Check OOM at script start to get stable lua OOM state.
parents
4bc4d2c7
38f6207f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
af5c1187
...
@@ -657,12 +657,11 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
...
@@ -657,12 +657,11 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
!
server
.
loading
&&
/* Don't care about mem if loading. */
!
server
.
loading
&&
/* Don't care about mem if loading. */
!
server
.
masterhost
&&
/* Slave must execute the script. */
!
server
.
masterhost
&&
/* Slave must execute the script. */
server
.
lua_write_dirty
==
0
&&
/* Script had no side effects so far. */
server
.
lua_write_dirty
==
0
&&
/* Script had no side effects so far. */
server
.
lua_oom
&&
/* Detected OOM when script start. */
(
cmd
->
flags
&
CMD_DENYOOM
))
(
cmd
->
flags
&
CMD_DENYOOM
))
{
{
if
(
getMaxmemoryState
(
NULL
,
NULL
,
NULL
,
NULL
)
!=
C_OK
)
{
luaPushError
(
lua
,
shared
.
oomerr
->
ptr
);
luaPushError
(
lua
,
shared
.
oomerr
->
ptr
);
goto
cleanup
;
goto
cleanup
;
}
}
}
if
(
cmd
->
flags
&
CMD_RANDOM
)
server
.
lua_random_dirty
=
1
;
if
(
cmd
->
flags
&
CMD_RANDOM
)
server
.
lua_random_dirty
=
1
;
...
...
src/server.c
View file @
af5c1187
...
@@ -3441,6 +3441,13 @@ int processCommand(client *c) {
...
@@ -3441,6 +3441,13 @@ int processCommand(client *c) {
addReply
(
c
,
shared
.
oomerr
);
addReply
(
c
,
shared
.
oomerr
);
return
C_OK
;
return
C_OK
;
}
}
/* Save out_of_memory result at script start, otherwise if we check OOM
* untill first write within script, memory used by lua stack and
* arguments might interfere. */
if
(
c
->
cmd
->
proc
==
evalCommand
||
c
->
cmd
->
proc
==
evalShaCommand
)
{
server
.
lua_oom
=
out_of_memory
;
}
}
}
/* Make sure to use a reasonable amount of memory for client side
/* Make sure to use a reasonable amount of memory for client side
...
...
src/server.h
View file @
af5c1187
...
@@ -1392,6 +1392,7 @@ struct redisServer {
...
@@ -1392,6 +1392,7 @@ struct redisServer {
execution. */
execution. */
int
lua_kill
;
/* Kill the script if true. */
int
lua_kill
;
/* Kill the script if true. */
int
lua_always_replicate_commands
;
/* Default replication type. */
int
lua_always_replicate_commands
;
/* Default replication type. */
int
lua_oom
;
/* OOM detected when script start? */
/* Lazy free */
/* Lazy free */
int
lazyfree_lazy_eviction
;
int
lazyfree_lazy_eviction
;
int
lazyfree_lazy_expire
;
int
lazyfree_lazy_expire
;
...
...
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