Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c1addc44
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c1addc44
编写于
6月 11, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
6月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13715 from taosdata/fix/mnode
test: execute trans in follower
上级
f0652ba4
34d7d5fd
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
92 addition
and
26 deletion
+92
-26
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+1
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+6
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+16
-7
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/tsim/mnode/basic2.sim
tests/script/tsim/mnode/basic2.sim
+4
-0
tests/script/tsim/mnode/basic3.sim
tests/script/tsim/mnode/basic3.sim
+64
-18
未找到文件。
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
c1addc44
...
...
@@ -75,6 +75,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
int32_t
mndTransProcessRsp
(
SRpcMsg
*
pRsp
);
void
mndTransPullup
(
SMnode
*
pMnode
);
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransExecute
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
c1addc44
...
...
@@ -61,6 +61,12 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
}
tsem_post
(
&
pMgmt
->
syncSem
);
}
else
{
STrans
*
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
if
(
pTrans
!=
NULL
)
{
mndTransExecute
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
}
if
(
cbMeta
.
index
-
sdbGetApplyIndex
(
pMnode
->
pSdb
)
>
100
)
{
SSnapshotMeta
sMeta
=
{
0
};
if
(
syncGetSnapshotMeta
(
pMnode
->
syncMgmt
.
sync
,
&
sMeta
)
==
0
)
{
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
c1addc44
...
...
@@ -52,8 +52,8 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans);
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerfromFinishedStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndCantExecuteTransAction
(
SMnode
*
pMnode
)
{
return
!
pMnode
->
deploy
&&
!
mndIsMaster
(
pMnode
);
}
static
void
mndTransExecute
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
void
mndTransSendRpcRsp
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndProcessTransReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessKillTransReq
(
SRpcMsg
*
pReq
);
...
...
@@ -517,12 +517,12 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) {
if
(
pOld
->
stage
==
TRN_STAGE_COMMIT
)
{
pOld
->
stage
=
TRN_STAGE_COMMIT_ACTION
;
mTrace
(
"trans:%d, stage from commit to commitAction"
,
pNew
->
id
);
mTrace
(
"trans:%d, stage from commit to commitAction
since perform update action
"
,
pNew
->
id
);
}
if
(
pOld
->
stage
==
TRN_STAGE_ROLLBACK
)
{
pOld
->
stage
=
TRN_STAGE_FINISHED
;
mTrace
(
"trans:%d, stage from rollback to finished"
,
pNew
->
id
);
mTrace
(
"trans:%d, stage from rollback to finished
since perform update action
"
,
pNew
->
id
);
}
return
0
;
}
...
...
@@ -914,7 +914,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
static
int32_t
mndTransSendSingleMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
STransAction
*
pAction
)
{
if
(
pAction
->
msgSent
)
return
0
;
if
(
!
pMnode
->
deploy
&&
!
mndIsMaster
(
pMnode
))
return
-
1
;
if
(
mndCantExecuteTransAction
(
pMnode
))
return
-
1
;
int64_t
signature
=
pTrans
->
id
;
signature
=
(
signature
<<
32
);
...
...
@@ -1114,9 +1114,9 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
pTrans
->
lastEpset
=
pAction
->
epSet
;
}
if
(
code
==
0
)
{
if
(
!
pMnode
->
deploy
&&
!
mndIsMaster
(
pMnode
))
break
;
if
(
mndCantExecuteTransAction
(
pMnode
))
break
;
if
(
code
==
0
)
{
pTrans
->
code
=
0
;
pTrans
->
redoActionPos
++
;
mDebug
(
"trans:%d, %s:%d is executed and need sync to other mnodes"
,
pTrans
->
id
,
mndTransStr
(
pAction
->
stage
),
...
...
@@ -1160,6 +1160,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
code
=
mndTransExecuteRedoActions
(
pMnode
,
pTrans
);
}
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
code
==
0
)
{
pTrans
->
code
=
0
;
pTrans
->
stage
=
TRN_STAGE_COMMIT
;
...
...
@@ -1185,6 +1187,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
}
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
bool
continueExec
=
true
;
int32_t
code
=
mndTransCommit
(
pMnode
,
pTrans
);
...
...
@@ -1233,6 +1237,8 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
bool
continueExec
=
true
;
int32_t
code
=
mndTransExecuteUndoActions
(
pMnode
,
pTrans
);
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
mDebug
(
"trans:%d, stage from undoAction to rollback"
,
pTrans
->
id
);
...
...
@@ -1250,6 +1256,8 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
}
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
bool
continueExec
=
true
;
int32_t
code
=
mndTransRollback
(
pMnode
,
pTrans
);
...
...
@@ -1284,10 +1292,11 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) {
return
continueExec
;
}
static
void
mndTransExecute
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
void
mndTransExecute
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
bool
continueExec
=
true
;
while
(
continueExec
)
{
mDebug
(
"trans:%d, continue to execute, stage:%s"
,
pTrans
->
id
,
mndTransStr
(
pTrans
->
stage
));
pTrans
->
lastExecTime
=
taosGetTimestampMs
();
switch
(
pTrans
->
stage
)
{
case
TRN_STAGE_PREPARE
:
...
...
tests/script/jenkins/basic.txt
浏览文件 @
c1addc44
...
...
@@ -57,7 +57,7 @@
# ---- mnode
./test.sh -f tsim/mnode/basic1.sim
#
./test.sh -f tsim/mnode/basic2.sim
./test.sh -f tsim/mnode/basic2.sim
./test.sh -f tsim/mnode/basic3.sim
./test.sh -f tsim/mnode/basic4.sim
...
...
tests/script/tsim/mnode/basic2.sim
浏览文件 @
c1addc44
...
...
@@ -92,6 +92,8 @@ sql show mnodes
if $rows != 2 then
return -1
endi
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
sql show users
if $rows != 2 then
...
...
@@ -111,6 +113,8 @@ step3:
return -1
endi
sql show dnodes -x step3
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $data(1)[4] != ready then
goto step3
endi
...
...
tests/script/tsim/mnode/basic3.sim
浏览文件 @
c1addc44
...
...
@@ -39,11 +39,9 @@ endi
print =============== step2: create mnode 2
sql create mnode on dnode 2
sql create mnode on dnode 3
return
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
sql_error create mnode on dnode 4
$leaderExist = 0
$x = 0
step2:
$x = $x + 1
...
...
@@ -52,13 +50,20 @@ step2:
return -1
endi
sql show mnodes -x step2
if $data(1)[2] != leader then
goto step2
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $data(1)[2] == leader then
$leaderExist = 1
endi
if $data(2)[2] != follower then
goto step2
if $data(2)[2] == leader then
$leaderExist = 1
endi
if $data(3)[2] == leader then
$leaderExist = 1
endi
if
$data(3)[2] != follower
then
if
$leaderExist != 1
then
goto step2
endi
...
...
@@ -70,10 +75,10 @@ if $rows != 2 then
endi
# wait mnode2 mnode3 recv data finish
sleep 1000
0
sleep 1000
print =============== step4: stop dnode1
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode1 -s stop
-x SIGKILL
$x = 0
step4:
...
...
@@ -92,13 +97,22 @@ if $rows != 2 then
return -1
endi
sleep 1000
sql show dnodes
if $data(2)[4] != ready then
$x = 0
step41:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes -x step41
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $data(2)[4] != ready then
goto step41
endi
if $data(3)[4] != ready then
return -
1
goto step4
1
endi
print =============== step5: stop dnode1
...
...
@@ -117,15 +131,29 @@ print $data(1)[0] $data(1)[1] $data(1)[2]
print $data(2)[0] $data(2)[1] $data(2)[2]
print $data(3)[0] $data(3)[1] $data(3)[2]
if $data(2)[2] != offline then
goto step5
endi
sql show users
if $rows != 2 then
return -1
endi
$x = 0
step51:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes -x step51
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $data(1)[4] != ready then
goto step51
endi
if $data(3)[4] != ready then
goto step51
endi
print =============== step6: stop dnode1
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s stop
...
...
@@ -147,6 +175,24 @@ if $rows != 2 then
return -1
endi
$x = 0
step61:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes -x step61
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $data(1)[4] != ready then
goto step61
endi
if $data(2)[4] != ready then
goto step61
endi
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode3 -s stop
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录