Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c7451a99
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
c7451a99
编写于
11月 29, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 rename variables
上级
1bf566a7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
54 deletion
+54
-54
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+14
-14
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+29
-29
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+10
-10
未找到文件。
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
c7451a99
...
...
@@ -25,20 +25,20 @@ extern "C" {
int32_t
mndInitTrans
(
SMnode
*
pMnode
);
void
mndCleanupTrans
(
SMnode
*
pMnode
);
STrans
*
trn
Create
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
void
*
rpcHandle
);
void
trn
Drop
(
STrans
*
pTrans
);
int32_t
trnAppendRedoL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
trnAppendUndoL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
trnAppendCommitL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
trn
AppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
trn
AppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
trn
Prepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
));
int32_t
trn
Apply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
,
int32_t
code
);
int32_t
trn
Execute
(
SSdb
*
pSdb
,
int32_t
tranId
);
SSdbRaw
*
trn
ActionEncode
(
STrans
*
pTrans
);
SSdbRow
*
trn
ActionDecode
(
SSdbRaw
*
pRaw
);
STrans
*
mndTrans
Create
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
void
*
rpcHandle
);
void
mndTrans
Drop
(
STrans
*
pTrans
);
int32_t
mndTransAppendRedol
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndol
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitl
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTrans
AppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
mndTrans
AppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
,
void
*
pMsg
);
int32_t
mndTrans
Prepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
));
int32_t
mndTrans
Apply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
,
int32_t
code
);
int32_t
mndTrans
Execute
(
SSdb
*
pSdb
,
int32_t
tranId
);
SSdbRaw
*
mndTrans
ActionEncode
(
STrans
*
pTrans
);
SSdbRow
*
mndTrans
ActionDecode
(
SSdbRaw
*
pRaw
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
c7451a99
...
...
@@ -22,7 +22,7 @@ int32_t mndInitSync(SMnode *pMnode) { return 0; }
void
mndCleanupSync
(
SMnode
*
pMnode
)
{}
int32_t
mndSyncPropose
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
)
{
trn
Apply
(
pMnode
,
pData
,
pData
,
0
);
mndTrans
Apply
(
pMnode
,
pData
,
pData
,
0
);
free
(
pData
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
c7451a99
...
...
@@ -20,7 +20,7 @@
#define SDB_TRANS_VER 1
#define TRN_DEFAULT_ARRAY_SIZE 8
SSdbRaw
*
trn
ActionEncode
(
STrans
*
pTrans
)
{
SSdbRaw
*
mndTrans
ActionEncode
(
STrans
*
pTrans
)
{
int32_t
rawDataLen
=
10
*
sizeof
(
int32_t
);
int32_t
redoLogNum
=
taosArrayGetSize
(
pTrans
->
redoLogs
);
int32_t
undoLogNum
=
taosArrayGetSize
(
pTrans
->
undoLogs
);
...
...
@@ -84,7 +84,7 @@ SSdbRaw *trnActionEncode(STrans *pTrans) {
return
pRaw
;
}
SSdbRow
*
trn
ActionDecode
(
SSdbRaw
*
pRaw
)
{
SSdbRow
*
mndTrans
ActionDecode
(
SSdbRaw
*
pRaw
)
{
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
{
mError
(
"failed to get soft ver from raw:%p since %s"
,
pRaw
,
terrstr
());
...
...
@@ -150,7 +150,7 @@ SSdbRow *trnActionDecode(SSdbRaw *pRaw) {
if
(
code
!=
0
)
{
terrno
=
code
;
mError
(
"trn:%d, failed to parse from raw:%p since %s"
,
pTrans
->
id
,
pRaw
,
terrstr
());
trn
Drop
(
pTrans
);
mndTrans
Drop
(
pTrans
);
return
NULL
;
}
...
...
@@ -158,7 +158,7 @@ SSdbRow *trnActionDecode(SSdbRaw *pRaw) {
return
pRow
;
}
static
int32_t
trn
ActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
static
int32_t
mndTrans
ActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
SArray
*
pArray
=
pTrans
->
redoLogs
;
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
...
...
@@ -175,7 +175,7 @@ static int32_t trnActionInsert(SSdb *pSdb, STrans *pTrans) {
return
0
;
}
static
int32_t
trn
ActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
static
int32_t
mndTrans
ActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
SArray
*
pArray
=
pTrans
->
redoLogs
;
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
...
...
@@ -192,7 +192,7 @@ static int32_t trnActionDelete(SSdb *pSdb, STrans *pTrans) {
return
0
;
}
static
int32_t
trn
ActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pTrans
,
STrans
*
pDstTrans
)
{
static
int32_t
mndTrans
ActionUpdate
(
SSdb
*
pSdb
,
STrans
*
pTrans
,
STrans
*
pDstTrans
)
{
assert
(
true
);
SArray
*
pArray
=
pTrans
->
redoLogs
;
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
...
...
@@ -213,7 +213,7 @@ static int32_t trnActionUpdate(SSdb *pSdb, STrans *pTrans, STrans *pDstTrans) {
static
int32_t
trnGenerateTransId
()
{
return
1
;
}
STrans
*
trn
Create
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
void
*
rpcHandle
)
{
STrans
*
mndTrans
Create
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
void
*
rpcHandle
)
{
STrans
*
pTrans
=
calloc
(
1
,
sizeof
(
STrans
));
if
(
pTrans
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -251,7 +251,7 @@ static void trnDropArray(SArray *pArray) {
taosArrayDestroy
(
pArray
);
}
void
trn
Drop
(
STrans
*
pTrans
)
{
void
mndTrans
Drop
(
STrans
*
pTrans
)
{
trnDropArray
(
pTrans
->
redoLogs
);
trnDropArray
(
pTrans
->
undoLogs
);
trnDropArray
(
pTrans
->
commitLogs
);
...
...
@@ -262,12 +262,12 @@ void trnDrop(STrans *pTrans) {
tfree
(
pTrans
);
}
void
trn
SetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
)
{
void
mndTrans
SetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
)
{
pTrans
->
rpcHandle
=
rpcHandle
;
mTrace
(
"trn:%d, set rpc handle:%p"
,
pTrans
->
id
,
rpcHandle
);
}
static
int32_t
trn
AppendArray
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
)
{
static
int32_t
mndTrans
AppendArray
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
)
{
if
(
pArray
==
NULL
||
pRaw
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -282,32 +282,32 @@ static int32_t trnAppendArray(SArray *pArray, SSdbRaw *pRaw) {
return
0
;
}
int32_t
trnAppendRedoL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
trn
AppendArray
(
pTrans
->
redoLogs
,
pRaw
);
int32_t
mndTransAppendRedol
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
mndTrans
AppendArray
(
pTrans
->
redoLogs
,
pRaw
);
mTrace
(
"trn:%d, raw:%p append to redo logs, code:%d"
,
pTrans
->
id
,
pRaw
,
code
);
return
code
;
}
int32_t
trnAppendUndoL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
trn
AppendArray
(
pTrans
->
undoLogs
,
pRaw
);
int32_t
mndTransAppendUndol
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
mndTrans
AppendArray
(
pTrans
->
undoLogs
,
pRaw
);
mTrace
(
"trn:%d, raw:%p append to undo logs, code:%d"
,
pTrans
->
id
,
pRaw
,
code
);
return
code
;
}
int32_t
trnAppendCommitL
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
trn
AppendArray
(
pTrans
->
commitLogs
,
pRaw
);
int32_t
mndTransAppendCommitl
og
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
)
{
int32_t
code
=
mndTrans
AppendArray
(
pTrans
->
commitLogs
,
pRaw
);
mTrace
(
"trn:%d, raw:%p append to commit logs, code:%d"
,
pTrans
->
id
,
pRaw
,
code
);
return
code
;
}
int32_t
trn
AppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
void
*
pMsg
)
{
int32_t
code
=
trn
AppendArray
(
pTrans
->
redoActions
,
pMsg
);
int32_t
mndTrans
AppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
void
*
pMsg
)
{
int32_t
code
=
mndTrans
AppendArray
(
pTrans
->
redoActions
,
pMsg
);
mTrace
(
"trn:%d, msg:%p append to redo actions"
,
pTrans
->
id
,
pMsg
);
return
code
;
}
int32_t
trn
AppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
void
*
pMsg
)
{
int32_t
code
=
trn
AppendArray
(
pTrans
->
undoActions
,
pMsg
);
int32_t
mndTrans
AppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
void
*
pMsg
)
{
int32_t
code
=
mndTrans
AppendArray
(
pTrans
->
undoActions
,
pMsg
);
mTrace
(
"trn:%d, msg:%p append to undo actions"
,
pTrans
->
id
,
pMsg
);
return
code
;
}
...
...
@@ -315,11 +315,11 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) {
int32_t
mndInitTrans
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_TRANS
,
.
keyType
=
SDB_KEY_INT32
,
.
encodeFp
=
(
SdbEncodeFp
)
trn
ActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
trn
ActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
trn
ActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
trn
ActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
trn
ActionDelete
};
.
encodeFp
=
(
SdbEncodeFp
)
mndTrans
ActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndTrans
ActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndTrans
ActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndTrans
ActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndTrans
ActionDelete
};
sdbSetTable
(
pMnode
->
pSdb
,
table
);
mInfo
(
"trn module is initialized"
);
...
...
@@ -329,10 +329,10 @@ int32_t mndInitTrans(SMnode *pMnode) {
void
mndCleanupTrans
(
SMnode
*
pMnode
)
{
mInfo
(
"trn module is cleaned up"
);
}
int32_t
trn
Prepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
))
{
int32_t
mndTrans
Prepare
(
STrans
*
pTrans
,
int32_t
(
*
syncfp
)(
SSdbRaw
*
pRaw
,
void
*
pData
))
{
if
(
syncfp
==
NULL
)
return
-
1
;
SSdbRaw
*
pRaw
=
trn
ActionEncode
(
pTrans
);
SSdbRaw
*
pRaw
=
mndTrans
ActionEncode
(
pTrans
);
if
(
pRaw
==
NULL
)
{
mError
(
"trn:%d, failed to decode trans since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
...
...
@@ -359,7 +359,7 @@ static void trnSendRpcRsp(void *rpcHandle, int32_t code) {
}
}
int32_t
trn
Apply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
,
int32_t
code
)
{
int32_t
mndTrans
Apply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
void
*
pData
,
int32_t
code
)
{
if
(
code
!=
0
)
{
trnSendRpcRsp
(
pData
,
terrno
);
return
0
;
...
...
@@ -454,7 +454,7 @@ static int32_t trnPerformRetryStage(STrans *pTrans) {
}
}
int32_t
trn
Execute
(
SSdb
*
pSdb
,
int32_t
tranId
)
{
int32_t
mndTrans
Execute
(
SSdb
*
pSdb
,
int32_t
tranId
)
{
int32_t
code
=
0
;
STrans
*
pTrans
=
sdbAcquire
(
pSdb
,
SDB_TRANS
,
&
tranId
);
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
c7451a99
...
...
@@ -137,39 +137,39 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
rootAuth
=
0
;
STrans
*
pTrans
=
trn
Create
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
STrans
*
pTrans
=
mndTrans
Create
(
pMnode
,
TRN_POLICY_ROLLBACK
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
return
-
1
;
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
if
(
pRedoRaw
==
NULL
||
trnAppendRedoL
og
(
pTrans
,
pRedoRaw
)
!=
0
)
{
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedol
og
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"failed to append redo log since %s"
,
terrstr
());
trn
Drop
(
pTrans
);
mndTrans
Drop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
SSdbRaw
*
pUndoRaw
=
mndUserActionEncode
(
&
userObj
);
if
(
pUndoRaw
==
NULL
||
trnAppendUndoL
og
(
pTrans
,
pUndoRaw
)
!=
0
)
{
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndol
og
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"failed to append undo log since %s"
,
terrstr
());
trn
Drop
(
pTrans
);
mndTrans
Drop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
&
userObj
);
if
(
pCommitRaw
==
NULL
||
trnAppendCommitL
og
(
pTrans
,
pCommitRaw
)
!=
0
)
{
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitl
og
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"failed to append commit log since %s"
,
terrstr
());
trn
Drop
(
pTrans
);
mndTrans
Drop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
if
(
trn
Prepare
(
pTrans
,
mndSyncPropose
)
!=
0
)
{
trn
Drop
(
pTrans
);
if
(
mndTrans
Prepare
(
pTrans
,
mndSyncPropose
)
!=
0
)
{
mndTrans
Drop
(
pTrans
);
return
-
1
;
}
trn
Drop
(
pTrans
);
mndTrans
Drop
(
pTrans
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录