Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
41932327
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
41932327
编写于
11月 11, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
e9bfd8a4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
34 deletion
+99
-34
source/dnode/mnode/transaction/src/trnInt.c
source/dnode/mnode/transaction/src/trnInt.c
+2
-0
source/dnode/mnode/transaction/src/trnMain.c
source/dnode/mnode/transaction/src/trnMain.c
+97
-34
未找到文件。
source/dnode/mnode/transaction/src/trnInt.c
浏览文件 @
41932327
...
...
@@ -191,6 +191,8 @@ void trnDrop(STrans *pTrans) {
tfree
(
pTrans
);
}
void
trnSetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
)
{
pTrans
->
rpcHandle
=
rpcHandle
;
}
static
int32_t
trnAppendArray
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
)
{
if
(
pArray
==
NULL
||
pRaw
==
NULL
)
{
terrno
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
...
source/dnode/mnode/transaction/src/trnMain.c
浏览文件 @
41932327
...
...
@@ -17,13 +17,6 @@
#include "trnInt.h"
#include "trpc.h"
void
trnSetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
)
{
if
(
pTrans
!=
NULL
)
{
pTrans
->
rpcHandle
=
rpcHandle
;
}
}
int32_t
trnPrepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
))
{
if
(
syncfp
==
NULL
)
return
-
1
;
...
...
@@ -69,58 +62,128 @@ int32_t trnApply(SSdbRaw *pRaw, void *pData, int32_t code) {
return
0
;
}
int32_t
trnExecuteRedoLogs
(
STrans
*
pTrans
)
{
return
0
;}
int32_t
trnExecuteUndoLogs
(
STrans
*
pTrans
)
{
return
0
;}
int32_t
trnExecuteCommitLogs
(
STrans
*
pTrans
)
{
return
0
;}
int32_t
trnExecuteRedoActions
(
STrans
*
pTrans
)
{
return
0
;}
int32_t
trnExecuteUndoActions
(
STrans
*
pTrans
)
{
return
0
;}
static
int32_t
trnPerfomRollbackStage
(
STrans
*
pTrans
)
{
return
0
;
}
static
int32_t
trnExecuteArray
(
SArray
*
pArray
)
{
for
(
int32_t
index
=
0
;
index
<
pArray
->
size
;
++
index
)
{
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
index
);
if
(
sdbWrite
(
pRaw
)
!=
0
)
{
return
-
1
;
}
}
return
0
;
}
static
int32_t
trnExecuteRedoLogs
(
STrans
*
pTrans
)
{
return
trnExecuteArray
(
pTrans
->
redoLogs
);
}
static
int32_t
trnExecuteUndoLogs
(
STrans
*
pTrans
)
{
return
trnExecuteArray
(
pTrans
->
undoLogs
);
}
static
int32_t
trnExecuteCommitLogs
(
STrans
*
pTrans
)
{
return
trnExecuteArray
(
pTrans
->
commitLogs
);
}
static
int32_t
trnExecuteRedoActions
(
STrans
*
pTrans
)
{
return
trnExecuteArray
(
pTrans
->
redoActions
);
}
static
int32_t
trnExecuteUndoActions
(
STrans
*
pTrans
)
{
return
trnExecuteArray
(
pTrans
->
undoActions
);
}
static
int32_t
trnPerformPrepareStage
(
STrans
*
pTrans
)
{
if
(
trnExecuteRedoLogs
(
pTrans
)
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_EXECUTE
;
return
0
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
return
-
1
;
}
}
static
int32_t
trnPerformExecuteStage
(
STrans
*
pTrans
)
{
int32_t
code
=
trnExecuteRedoActions
(
pTrans
);
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_COMMIT
;
return
0
;
}
else
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
return
-
1
;
}
else
{
if
(
pTrans
->
policy
==
TRN_POLICY_RETRY
)
{
pTrans
->
stage
=
TRN_STAGE_RETRY
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
}
return
0
;
}
}
static
int32_t
trnPerformCommitStage
(
STrans
*
pTrans
)
{
if
(
trnExecuteCommitLogs
(
pTrans
)
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_EXECUTE
;
return
0
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
return
-
1
;
}
}
static
int32_t
trnPerformRollbackStage
(
STrans
*
pTrans
)
{
if
(
trnExecuteCommitLogs
(
pTrans
)
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_EXECUTE
;
return
0
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
return
-
1
;
}
}
static
int32_t
trnPerformRetryStage
(
STrans
*
pTrans
)
{
if
(
trnExecuteCommitLogs
(
pTrans
)
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_EXECUTE
;
return
0
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
return
-
1
;
}
}
int32_t
trnExecute
(
int32_t
tranId
)
{
int32_t
code
=
0
;
STrans
*
pTrans
=
sdbAcquire
(
SDB_TRANS
,
&
tranId
);
if
(
pTrans
==
NULL
)
{
code
=
terrno
;
return
code
;
return
-
1
;
}
if
(
pTrans
->
stage
==
TRN_STAGE_PREPARE
)
{
code
=
trnExecuteRedoLogs
(
pTrans
);
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_EXECUTE
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
if
(
trnPerformPrepareStage
(
pTrans
)
!=
0
)
{
sdbRelease
(
pTrans
);
return
-
1
;
}
}
if
(
pTrans
->
stage
==
TRN_STAGE_EXECUTE
)
{
code
=
trnExecuteRedoActions
(
pTrans
);
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_COMMIT
;
}
else
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
// do nothing
}
else
{
if
(
pTrans
->
policy
==
TRN_POLICY_RETRY
)
{
pTrans
->
stage
=
TRN_STAGE_RETRY
;
}
else
{
pTrans
->
stage
=
TRN_STAGE_ROLLBACK
;
}
if
(
trnPerformExecuteStage
(
pTrans
)
!=
0
)
{
sdbRelease
(
pTrans
);
return
-
1
;
}
}
if
(
pTrans
->
stage
==
TRN_STAGE_COMMIT
)
{
code
=
trnExecuteCommitLogs
(
pTrans
);
if
(
code
==
0
)
{
trnDrop
(
pTrans
)
;
if
(
trnPerformCommitStage
(
pTrans
)
!=
0
)
{
sdbRelease
(
pTrans
);
return
-
1
;
}
}
if
(
pTrans
->
stage
==
TRN_STAGE_ROLLBACK
)
{
if
(
trnPerformRollbackStage
(
pTrans
)
!=
0
)
{
sdbRelease
(
pTrans
);
return
-
1
;
}
}
if
(
pTrans
->
stage
==
TRN_STAGE_RETRY
)
{
if
(
trnPerformRetryStage
(
pTrans
)
!=
0
)
{
sdbRelease
(
pTrans
);
return
-
1
;
}
}
sdbRelease
(
pTrans
);
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录