Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
37c84761
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
37c84761
编写于
2月 17, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trans stage type
上级
67e04c66
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
16 deletion
+44
-16
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+44
-16
未找到文件。
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
37c84761
...
...
@@ -80,17 +80,17 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
for
(
int32_t
i
=
0
;
i
<
redoLogNum
;
++
i
)
{
SSdbRaw
*
pTmp
=
taosArrayGetP
(
pTrans
->
redoLogs
,
i
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
4
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
sizeof
(
int32_t
)
);
}
for
(
int32_t
i
=
0
;
i
<
undoLogNum
;
++
i
)
{
SSdbRaw
*
pTmp
=
taosArrayGetP
(
pTrans
->
undoLogs
,
i
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
4
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
sizeof
(
int32_t
)
);
}
for
(
int32_t
i
=
0
;
i
<
commitLogNum
;
++
i
)
{
SSdbRaw
*
pTmp
=
taosArrayGetP
(
pTrans
->
commitLogs
,
i
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
4
);
rawDataLen
+=
(
sdbGetRawTotalSize
(
pTmp
)
+
sizeof
(
int32_t
)
);
}
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
...
...
@@ -296,9 +296,34 @@ TRANS_DECODE_OVER:
return
pRow
;
}
static
const
char
*
mndTransStr
(
ETrnStage
stage
)
{
switch
(
stage
)
{
case
TRN_STAGE_PREPARE
:
return
"prepare"
;
case
TRN_STAGE_REDO_LOG
:
return
"redoLog"
;
case
TRN_STAGE_REDO_ACTION
:
return
"redoAction"
;
case
TRN_STAGE_COMMIT
:
return
"commit"
;
case
TRN_STAGE_COMMIT_LOG
:
return
"commitLog"
;
case
TRN_STAGE_UNDO_ACTION
:
return
"undoAction"
;
case
TRN_STAGE_UNDO_LOG
:
return
"undoLog"
;
case
TRN_STAGE_ROLLBACK
:
return
"rollback"
;
case
TRN_STAGE_FINISHED
:
return
"finished"
;
default:
return
"invalid"
;
}
}
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
mTrace
(
"trans:%d, perform insert action, row:%p
"
,
pTrans
->
id
,
pTrans
);
//
pTrans->stage = TRN_STAGE_PREPARE;
mTrace
(
"trans:%d, perform insert action, row:%p
stage:%s"
,
pTrans
->
id
,
pTrans
,
mndTransStr
(
pTrans
->
stage
)
);
return
0
;
}
...
...
@@ -316,21 +341,24 @@ static void mndTransDropData(STrans *pTrans) {
}
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
mTrace
(
"trans:%d, perform delete action, row:%p
"
,
pTrans
->
id
,
pTrans
);
mTrace
(
"trans:%d, perform delete action, row:%p
stage:%s"
,
pTrans
->
id
,
pTrans
,
mndTransStr
(
pTrans
->
stage
)
);
mndTransDropData
(
pTrans
);
return
0
;
}
static
int32_t
mndTransActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pOld
,
STrans
*
pNew
)
{
if
(
pNew
->
stage
==
TRN_STAGE_COMMIT
)
pNew
->
stage
=
TRN_STAGE_COMMIT_LOG
;
if
(
pNew
->
stage
==
TRN_STAGE_COMMIT
)
{
pNew
->
stage
=
TRN_STAGE_COMMIT_LOG
;
mTrace
(
"trans:%d, stage from %s to %s"
,
pNew
->
id
,
mndTransStr
(
TRN_STAGE_COMMIT
),
mndTransStr
(
TRN_STAGE_COMMIT_LOG
));
}
mTrace
(
"trans:%d, perform update action, old row:%p stage:%
d, new row:%p stage:%d"
,
pOld
->
id
,
pOld
,
pOld
->
stage
,
pNew
,
pNew
->
stage
);
mTrace
(
"trans:%d, perform update action, old row:%p stage:%
s, new row:%p stage:%s"
,
pOld
->
id
,
pOld
,
mndTransStr
(
pOld
->
stage
),
pNew
,
mndTransStr
(
pNew
->
stage
)
);
pOld
->
stage
=
pNew
->
stage
;
return
0
;
}
STrans
*
mndAcquireTrans
(
SMnode
*
pMnode
,
int32_t
transId
)
{
static
STrans
*
mndAcquireTrans
(
SMnode
*
pMnode
,
int32_t
transId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
STrans
*
pTrans
=
sdbAcquire
(
pSdb
,
SDB_TRANS
,
&
transId
);
if
(
pTrans
==
NULL
)
{
...
...
@@ -339,7 +367,7 @@ STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
return
pTrans
;
}
void
mndReleaseTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
void
mndReleaseTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pTrans
);
}
...
...
@@ -375,8 +403,8 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, const SRpcMsg *pReq) {
}
static
void
mndTransDropLogs
(
SArray
*
pArray
)
{
i
f
(
pArray
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
i
nt32_t
size
=
taosArrayGetSize
(
pArray
)
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
sdbFreeRaw
(
pRaw
);
}
...
...
@@ -385,10 +413,10 @@ static void mndTransDropLogs(SArray *pArray) {
}
static
void
mndTransDropActions
(
SArray
*
pArray
)
{
i
f
(
pArray
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
i
nt32_t
size
=
taosArrayGetSize
(
pArray
)
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
free
(
pAction
->
pCont
);
t
free
(
pAction
->
pCont
);
}
taosArrayDestroy
(
pArray
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录