Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
d3a9dff6
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d3a9dff6
编写于
12月 19, 2019
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
12月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6615 from soloestoy/wrap-also-propagate-as-multi
Wrap also propagate as multi
上级
9a7b6a9f
6b056d29
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
25 deletion
+39
-25
src/module.c
src/module.c
+6
-4
src/multi.c
src/multi.c
+5
-3
src/scripting.c
src/scripting.c
+1
-5
src/server.c
src/server.c
+19
-0
src/server.h
src/server.h
+3
-1
src/t_list.c
src/t_list.c
+5
-12
未找到文件。
src/module.c
浏览文件 @
d3a9dff6
...
...
@@ -590,11 +590,8 @@ void moduleHandlePropagationAfterCommandCallback(RedisModuleCtx *ctx) {
/* Handle the replication of the final EXEC, since whatever a command
* emits is always wrapped around MULTI/EXEC. */
robj
*
propargv
[
1
];
propargv
[
0
]
=
createStringObject
(
"EXEC"
,
4
);
alsoPropagate
(
server
.
execCommand
,
c
->
db
->
id
,
propargv
,
1
,
alsoPropagate
(
server
.
execCommand
,
c
->
db
->
id
,
&
shared
.
exec
,
1
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
decrRefCount
(
propargv
[
0
]);
/* If this is not a module command context (but is instead a simple
* callback context), we have to handle directly the "also propagate"
...
...
@@ -3300,6 +3297,11 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
* a Lua script in the context of AOF and slaves. */
if
(
replicate
)
moduleReplicateMultiIfNeeded
(
ctx
);
if
(
ctx
->
client
->
flags
&
CLIENT_MULTI
||
ctx
->
flags
&
REDISMODULE_CTX_MULTI_EMITTED
)
{
c
->
flags
|=
CLIENT_MULTI
;
}
/* Run the command */
int
call_flags
=
CMD_CALL_SLOWLOG
|
CMD_CALL_STATS
;
if
(
replicate
)
{
...
...
src/multi.c
浏览文件 @
d3a9dff6
...
...
@@ -106,11 +106,13 @@ void discardCommand(client *c) {
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
* implementation for more information. */
void
execCommandPropagateMulti
(
client
*
c
)
{
robj
*
multistring
=
createStringObject
(
"MULTI"
,
5
);
propagate
(
server
.
multiCommand
,
c
->
db
->
id
,
&
shared
.
multi
,
1
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
}
propagate
(
server
.
multiCommand
,
c
->
db
->
id
,
&
multistring
,
1
,
void
execCommandPropagateExec
(
client
*
c
)
{
propagate
(
server
.
execCommand
,
c
->
db
->
id
,
&
shared
.
exec
,
1
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
decrRefCount
(
multistring
);
}
void
execCommand
(
client
*
c
)
{
...
...
src/scripting.c
浏览文件 @
d3a9dff6
...
...
@@ -1615,11 +1615,7 @@ void evalGenericCommand(client *c, int evalsha) {
if
(
server
.
lua_replicate_commands
)
{
preventCommandPropagation
(
c
);
if
(
server
.
lua_multi_emitted
)
{
robj
*
propargv
[
1
];
propargv
[
0
]
=
createStringObject
(
"EXEC"
,
4
);
alsoPropagate
(
server
.
execCommand
,
c
->
db
->
id
,
propargv
,
1
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
decrRefCount
(
propargv
[
0
]);
execCommandPropagateExec
(
c
);
}
}
...
...
src/server.c
浏览文件 @
d3a9dff6
...
...
@@ -2244,6 +2244,8 @@ void createSharedObjects(void) {
shared
.
rpoplpush
=
createStringObject
(
"RPOPLPUSH"
,
9
);
shared
.
zpopmin
=
createStringObject
(
"ZPOPMIN"
,
7
);
shared
.
zpopmax
=
createStringObject
(
"ZPOPMAX"
,
7
);
shared
.
multi
=
createStringObject
(
"MULTI"
,
5
);
shared
.
exec
=
createStringObject
(
"EXEC"
,
4
);
for
(
j
=
0
;
j
<
OBJ_SHARED_INTEGERS
;
j
++
)
{
shared
.
integers
[
j
]
=
makeObjectShared
(
createObject
(
OBJ_STRING
,(
void
*
)(
long
)
j
));
...
...
@@ -2372,6 +2374,7 @@ void initServerConfig(void) {
server
.
pexpireCommand
=
lookupCommandByCString
(
"pexpire"
);
server
.
xclaimCommand
=
lookupCommandByCString
(
"xclaim"
);
server
.
xgroupCommand
=
lookupCommandByCString
(
"xgroup"
);
server
.
rpoplpushCommand
=
lookupCommandByCString
(
"rpoplpush"
);
/* Debugging */
server
.
assert_failed
=
"<no assertion failed>"
;
...
...
@@ -3272,6 +3275,18 @@ void call(client *c, int flags) {
redisOp
*
rop
;
if
(
flags
&
CMD_CALL_PROPAGATE
)
{
int
multi_emitted
=
0
;
/* Wrap the commands in server.also_propagate array,
* but don't wrap it if we are already in MULIT context,
* in case the nested MULIT/EXEC.
*
* And if the array contains only one command, no need to
* wrap it, since the single command is atomic. */
if
(
server
.
also_propagate
.
numops
>
1
&&
!
(
c
->
flags
&
CLIENT_MULTI
))
{
execCommandPropagateMulti
(
c
);
multi_emitted
=
1
;
}
for
(
j
=
0
;
j
<
server
.
also_propagate
.
numops
;
j
++
)
{
rop
=
&
server
.
also_propagate
.
ops
[
j
];
int
target
=
rop
->
target
;
...
...
@@ -3281,6 +3296,10 @@ void call(client *c, int flags) {
if
(
target
)
propagate
(
rop
->
cmd
,
rop
->
dbid
,
rop
->
argv
,
rop
->
argc
,
target
);
}
if
(
multi_emitted
)
{
execCommandPropagateExec
(
c
);
}
}
redisOpArrayFree
(
&
server
.
also_propagate
);
}
...
...
src/server.h
浏览文件 @
d3a9dff6
...
...
@@ -848,6 +848,7 @@ struct sharedObjectsStruct {
*
busykeyerr
,
*
oomerr
,
*
plus
,
*
messagebulk
,
*
pmessagebulk
,
*
subscribebulk
,
*
unsubscribebulk
,
*
psubscribebulk
,
*
punsubscribebulk
,
*
del
,
*
unlink
,
*
rpop
,
*
lpop
,
*
lpush
,
*
rpoplpush
,
*
zpopmin
,
*
zpopmax
,
*
emptyscan
,
*
multi
,
*
exec
,
*
select
[
PROTO_SHARED_SELECT_CMDS
],
*
integers
[
OBJ_SHARED_INTEGERS
],
*
mbulkhdr
[
OBJ_SHARED_BULKHDR_LEN
],
/* "*<value>\r\n" */
...
...
@@ -1083,7 +1084,7 @@ struct redisServer {
*
lpopCommand
,
*
rpopCommand
,
*
zpopminCommand
,
*
zpopmaxCommand
,
*
sremCommand
,
*
execCommand
,
*
expireCommand
,
*
pexpireCommand
,
*
xclaimCommand
,
*
xgroupCommand
;
*
xgroupCommand
,
*
rpoplpushCommand
;
/* Fields used only for stats */
time_t
stat_starttime
;
/* Server start time */
long
long
stat_numcommands
;
/* Number of processed commands */
...
...
@@ -1680,6 +1681,7 @@ void touchWatchedKeysOnFlush(int dbid);
void
discardTransaction
(
client
*
c
);
void
flagTransaction
(
client
*
c
);
void
execCommandPropagateMulti
(
client
*
c
);
void
execCommandPropagateExec
(
client
*
c
);
/* Redis object implementation */
void
decrRefCount
(
robj
*
o
);
...
...
src/t_list.c
浏览文件 @
d3a9dff6
...
...
@@ -653,20 +653,13 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
if
(
!
(
dstobj
&&
checkType
(
receiver
,
dstobj
,
OBJ_LIST
)))
{
/* Propagate the RPOP operation. */
argv
[
0
]
=
shared
.
rpop
;
argv
[
1
]
=
key
;
propagate
(
server
.
rpopCommand
,
db
->
id
,
argv
,
2
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
rpoplpushHandlePush
(
receiver
,
dstkey
,
dstobj
,
value
);
/* Propagate the LPUSH operation. */
argv
[
0
]
=
shared
.
lpush
;
argv
[
1
]
=
dst
key
;
argv
[
2
]
=
value
;
propagate
(
server
.
lpushCommand
,
/* Propagate the
RPOP
LPUSH operation. */
argv
[
0
]
=
shared
.
rpop
lpush
;
argv
[
1
]
=
key
;
argv
[
2
]
=
dstkey
;
propagate
(
server
.
rpop
lpushCommand
,
db
->
id
,
argv
,
3
,
PROPAGATE_AOF
|
PROPAGATE_REPL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录