Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6f0f7c58
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看板
提交
6f0f7c58
编写于
12月 18, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 build create vnode msg
上级
8bba00f2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
76 deletion
+80
-76
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+2
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-6
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+70
-64
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+4
-4
未找到文件。
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
6f0f7c58
...
@@ -30,8 +30,8 @@ void mndTransDrop(STrans *pTrans);
...
@@ -30,8 +30,8 @@ void mndTransDrop(STrans *pTrans);
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransApply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
STransMsg
*
pMsg
,
int32_t
code
);
void
mndTransApply
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
,
STransMsg
*
pMsg
,
int32_t
code
);
char
*
mndTransStageStr
(
ETrnStage
stage
);
char
*
mndTransStageStr
(
ETrnStage
stage
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
6f0f7c58
...
@@ -303,9 +303,8 @@ static int32_t mndSetRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SV
...
@@ -303,9 +303,8 @@ static int32_t mndSetRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SV
return
-
1
;
return
-
1
;
}
}
SRpcMsg
rpcMsg
=
{.
msgType
=
TSDB_MSG_TYPE_ALTER_VNODE_IN
,
.
pCont
=
pMsg
,
.
contLen
=
sizeof
(
SCreateVnodeMsg
)};
if
(
mndTransAppendRedoAction
(
pTrans
,
&
epset
,
TSDB_MSG_TYPE_ALTER_VNODE_IN
,
sizeof
(
SCreateVnodeMsg
),
pMsg
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
epset
,
&
rpcMsg
)
!=
0
)
{
free
(
pMsg
);
rpcFreeCont
(
pMsg
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -333,9 +332,8 @@ static int32_t mndSetUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SV
...
@@ -333,9 +332,8 @@ static int32_t mndSetUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SV
return
-
1
;
return
-
1
;
}
}
SRpcMsg
rpcMsg
=
{.
msgType
=
TSDB_MSG_TYPE_DROP_VNODE_IN
,
.
pCont
=
pMsg
,
.
contLen
=
sizeof
(
SDropVnodeMsg
)};
if
(
mndTransAppendUndoAction
(
pTrans
,
&
epset
,
TSDB_MSG_TYPE_DROP_VNODE_IN
,
sizeof
(
SDropVnodeMsg
),
pMsg
)
!=
0
)
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
epset
,
&
rpcMsg
)
!=
0
)
{
free
(
pMsg
);
rpcFreeCont
(
pMsg
);
return
-
1
;
return
-
1
;
}
}
}
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
6f0f7c58
...
@@ -23,7 +23,9 @@
...
@@ -23,7 +23,9 @@
typedef
struct
{
typedef
struct
{
SEpSet
epSet
;
SEpSet
epSet
;
SRpcMsg
msg
;
int8_t
msgType
;
int32_t
contLen
;
void
*
pCont
;
}
STransAction
;
}
STransAction
;
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
...
@@ -35,10 +37,11 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans);
...
@@ -35,10 +37,11 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans);
static
void
mndTransSetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
);
static
void
mndTransSetRpcHandle
(
STrans
*
pTrans
,
void
*
rpcHandle
);
static
void
mndTransSendRpcRsp
(
STrans
*
pTrans
,
int32_t
code
);
static
void
mndTransSendRpcRsp
(
STrans
*
pTrans
,
int32_t
code
);
static
int32_t
mndTransAppendLog
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
);
static
int32_t
mndTransAppendLog
(
SArray
*
pArray
,
SSdbRaw
*
pRaw
);
static
int32_t
mndTransAppendAction
(
SArray
*
pArray
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
static
int32_t
mndTransAppendAction
(
SArray
*
pArray
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
);
static
void
mndTransDropLog
(
SArray
*
pArray
);
static
void
mndTransDropLogs
(
SArray
*
pArray
);
static
void
mndTransDropAction
(
SArray
*
pArray
);
static
void
mndTransDropActions
(
SArray
*
pArray
);
static
int32_t
mndTransExecuteArray
(
SMnode
*
pMnode
,
SArray
*
pArray
);
static
int32_t
mndTransExecuteLogs
(
SMnode
*
pMnode
,
SArray
*
pArray
);
static
int32_t
mndTransExecuteActions
(
SMnode
*
pMnode
,
SArray
*
pArray
);
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
...
@@ -89,12 +92,12 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -89,12 +92,12 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
redoActions
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
redoActions
,
i
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
msg
.
contLen
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
}
}
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
undoActions
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
undoActions
,
i
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
msg
.
contLen
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
}
}
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TRANS
,
TSDB_TRANS_VER
,
rawDataLen
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TRANS
,
TSDB_TRANS_VER
,
rawDataLen
);
...
@@ -136,17 +139,17 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -136,17 +139,17 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
redoActions
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
redoActions
,
i
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
));
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
));
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msg
.
msg
Type
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgType
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
msg
.
contLen
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
msg
.
pCont
,
pAction
->
msg
.
contLen
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pAction
->
pCont
,
pAction
->
contLen
);
}
}
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
undoActions
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
undoActions
,
i
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
));
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
&
pAction
->
epSet
,
sizeof
(
SEpSet
));
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msg
.
msg
Type
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pAction
->
msgType
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
msg
.
contLen
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pAction
->
contLen
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
msg
.
pCont
,
pAction
->
msg
.
contLen
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pCont
,
pAction
->
contLen
);
}
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_TRN_RESERVE_SIZE
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_TRN_RESERVE_SIZE
)
...
@@ -247,14 +250,14 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -247,14 +250,14 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
redoActionNum
;
++
i
)
{
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
));
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
));
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msg
.
msg
Type
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msgType
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msg
.
contLen
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
action
.
contLen
)
action
.
msg
.
pCont
=
rpcMallocCont
(
action
.
msg
.
contLen
);
action
.
pCont
=
malloc
(
action
.
contLen
);
if
(
action
.
msg
.
pCont
==
NULL
)
{
if
(
action
.
pCont
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TRANS_DECODE_OVER
;
goto
TRANS_DECODE_OVER
;
}
}
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
action
.
msg
.
pCont
,
action
.
msg
.
contLen
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
action
.
pCont
,
action
.
contLen
);
void
*
ret
=
taosArrayPush
(
pTrans
->
redoActions
,
&
action
);
void
*
ret
=
taosArrayPush
(
pTrans
->
redoActions
,
&
action
);
if
(
ret
==
NULL
)
{
if
(
ret
==
NULL
)
{
...
@@ -266,14 +269,14 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -266,14 +269,14 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
undoActionNum
;
++
i
)
{
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
));
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
(
void
*
)
&
action
.
epSet
,
sizeof
(
SEpSet
));
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msg
.
msg
Type
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msgType
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
action
.
msg
.
contLen
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
action
.
contLen
)
action
.
msg
.
pCont
=
rpcMallocCont
(
action
.
msg
.
contLen
);
action
.
pCont
=
malloc
(
action
.
contLen
);
if
(
action
.
msg
.
pCont
==
NULL
)
{
if
(
action
.
pCont
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TRANS_DECODE_OVER
;
goto
TRANS_DECODE_OVER
;
}
}
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
action
.
msg
.
pCont
,
action
.
msg
.
contLen
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
action
.
pCont
,
action
.
contLen
);
void
*
ret
=
taosArrayPush
(
pTrans
->
undoActions
,
&
action
);
void
*
ret
=
taosArrayPush
(
pTrans
->
undoActions
,
&
action
);
if
(
ret
==
NULL
)
{
if
(
ret
==
NULL
)
{
...
@@ -305,11 +308,11 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
...
@@ -305,11 +308,11 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
mTrace
(
"trans:%d, perform delete action, stage:%s"
,
pTrans
->
id
,
mndTransStageStr
(
pTrans
->
stage
));
mTrace
(
"trans:%d, perform delete action, stage:%s"
,
pTrans
->
id
,
mndTransStageStr
(
pTrans
->
stage
));
mndTransDropLog
(
pTrans
->
redoLogs
);
mndTransDropLog
s
(
pTrans
->
redoLogs
);
mndTransDropLog
(
pTrans
->
undoLogs
);
mndTransDropLog
s
(
pTrans
->
undoLogs
);
mndTransDropLog
(
pTrans
->
commitLogs
);
mndTransDropLog
s
(
pTrans
->
commitLogs
);
mndTransDropAction
(
pTrans
->
redoActions
);
mndTransDropAction
s
(
pTrans
->
redoActions
);
mndTransDropAction
(
pTrans
->
undoActions
);
mndTransDropAction
s
(
pTrans
->
undoActions
);
return
0
;
return
0
;
}
}
...
@@ -389,7 +392,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
...
@@ -389,7 +392,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
return
pTrans
;
return
pTrans
;
}
}
static
void
mndTransDropLog
(
SArray
*
pArray
)
{
static
void
mndTransDropLog
s
(
SArray
*
pArray
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
tfree
(
pRaw
);
tfree
(
pRaw
);
...
@@ -398,21 +401,21 @@ static void mndTransDropLog(SArray *pArray) {
...
@@ -398,21 +401,21 @@ static void mndTransDropLog(SArray *pArray) {
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
}
}
static
void
mndTransDropAction
(
SArray
*
pArray
)
{
static
void
mndTransDropAction
s
(
SArray
*
pArray
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pArray
->
size
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
rpcFreeCont
(
pAction
->
msg
.
pCont
);
free
(
pAction
->
pCont
);
}
}
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
}
}
void
mndTransDrop
(
STrans
*
pTrans
)
{
void
mndTransDrop
(
STrans
*
pTrans
)
{
mndTransDropLog
(
pTrans
->
redoLogs
);
mndTransDropLog
s
(
pTrans
->
redoLogs
);
mndTransDropLog
(
pTrans
->
undoLogs
);
mndTransDropLog
s
(
pTrans
->
undoLogs
);
mndTransDropLog
(
pTrans
->
commitLogs
);
mndTransDropLog
s
(
pTrans
->
commitLogs
);
mndTransDropAction
(
pTrans
->
redoActions
);
mndTransDropAction
s
(
pTrans
->
redoActions
);
mndTransDropAction
(
pTrans
->
undoActions
);
mndTransDropAction
s
(
pTrans
->
undoActions
);
mDebug
(
"trans:%d, data:%p is dropped"
,
pTrans
->
id
,
pTrans
);
mDebug
(
"trans:%d, data:%p is dropped"
,
pTrans
->
id
,
pTrans
);
tfree
(
pTrans
);
tfree
(
pTrans
);
...
@@ -456,8 +459,8 @@ int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
...
@@ -456,8 +459,8 @@ int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
return
code
;
return
code
;
}
}
static
int32_t
mndTransAppendAction
(
SArray
*
pArray
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
static
int32_t
mndTransAppendAction
(
SArray
*
pArray
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
)
{
STransAction
action
=
{.
epSet
=
*
pEpSet
,
.
msg
=
*
pMsg
};
STransAction
action
=
{.
epSet
=
*
pEpSet
,
.
msg
Type
=
msgType
,
.
contLen
=
contLen
,
.
pCont
=
pCont
};
void
*
ptr
=
taosArrayPush
(
pArray
,
&
action
);
void
*
ptr
=
taosArrayPush
(
pArray
,
&
action
);
if
(
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
...
@@ -468,15 +471,15 @@ static int32_t mndTransAppendAction(SArray *pArray, SEpSet *pEpSet, SRpcMsg *pMs
...
@@ -468,15 +471,15 @@ static int32_t mndTransAppendAction(SArray *pArray, SEpSet *pEpSet, SRpcMsg *pMs
return
0
;
return
0
;
}
}
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
)
{
int32_t
code
=
mndTransAppendAction
(
pTrans
->
redoActions
,
pEpSet
,
pMsg
);
int32_t
code
=
mndTransAppendAction
(
pTrans
->
redoActions
,
pEpSet
,
msgType
,
contLen
,
pCont
);
mTrace
(
"trans:%d, msg:%
p append to redo actions"
,
pTrans
->
id
,
pMsg
);
mTrace
(
"trans:%d, msg:%
s len:%d append to redo actions"
,
pTrans
->
id
,
taosMsg
[
msgType
],
contLen
);
return
code
;
return
code
;
}
}
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
SEpSet
*
pEpSet
,
int8_t
msgType
,
int32_t
contLen
,
void
*
pCont
)
{
int32_t
code
=
mndTransAppendAction
(
pTrans
->
undoActions
,
pEpSet
,
pMsg
);
int32_t
code
=
mndTransAppendAction
(
pTrans
->
undoActions
,
pEpSet
,
msgType
,
contLen
,
pCont
);
mTrace
(
"trans:%d, msg:%
p append to undo actions"
,
pTrans
->
id
,
pMsg
);
mTrace
(
"trans:%d, msg:%
s len:%d append to undo actions"
,
pTrans
->
id
,
taosMsg
[
msgType
],
contLen
);
return
code
;
return
code
;
}
}
...
@@ -593,7 +596,7 @@ void mndTransApply(SMnode *pMnode, SSdbRaw *pRaw, STransMsg *pMsg, int32_t code)
...
@@ -593,7 +596,7 @@ void mndTransApply(SMnode *pMnode, SSdbRaw *pRaw, STransMsg *pMsg, int32_t code)
// todo
// todo
}
}
static
int32_t
mndTransExecute
Array
(
SMnode
*
pMnode
,
SArray
*
pArray
)
{
static
int32_t
mndTransExecute
Logs
(
SMnode
*
pMnode
,
SArray
*
pArray
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
...
@@ -611,7 +614,7 @@ static int32_t mndTransExecuteArray(SMnode *pMnode, SArray *pArray) {
...
@@ -611,7 +614,7 @@ static int32_t mndTransExecuteArray(SMnode *pMnode, SArray *pArray) {
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
redoLogs
)
!=
0
)
{
if
(
taosArrayGetSize
(
pTrans
->
redoLogs
)
!=
0
)
{
code
=
mndTransExecute
Array
(
pMnode
,
pTrans
->
redoLogs
);
code
=
mndTransExecute
Logs
(
pMnode
,
pTrans
->
redoLogs
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute redo logs since %s"
,
pTrans
->
id
,
terrstr
())
mError
(
"trans:%d, failed to execute redo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
}
else
{
...
@@ -625,7 +628,7 @@ static int32_t mndTransExecuteRedoLogs(SMnode *pMnode, STrans *pTrans) {
...
@@ -625,7 +628,7 @@ static int32_t mndTransExecuteRedoLogs(SMnode *pMnode, STrans *pTrans) {
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
undoLogs
)
!=
0
)
{
if
(
taosArrayGetSize
(
pTrans
->
undoLogs
)
!=
0
)
{
code
=
mndTransExecute
Array
(
pMnode
,
pTrans
->
undoLogs
);
code
=
mndTransExecute
Logs
(
pMnode
,
pTrans
->
undoLogs
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute undo logs since %s"
,
pTrans
->
id
,
terrstr
())
mError
(
"trans:%d, failed to execute undo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
}
else
{
...
@@ -639,7 +642,7 @@ static int32_t mndTransExecuteUndoLogs(SMnode *pMnode, STrans *pTrans) {
...
@@ -639,7 +642,7 @@ static int32_t mndTransExecuteUndoLogs(SMnode *pMnode, STrans *pTrans) {
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
code
=
mndTransExecute
Array
(
pMnode
,
pTrans
->
commitLogs
);
code
=
mndTransExecute
Logs
(
pMnode
,
pTrans
->
commitLogs
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute commit logs since %s"
,
pTrans
->
id
,
terrstr
())
mError
(
"trans:%d, failed to execute commit logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
}
else
{
...
@@ -651,36 +654,39 @@ static int32_t mndTransExecuteCommitLogs(SMnode *pMnode, STrans *pTrans) {
...
@@ -651,36 +654,39 @@ static int32_t mndTransExecuteCommitLogs(SMnode *pMnode, STrans *pTrans) {
}
}
static
int32_t
mndTransExecuteActions
(
SMnode
*
pMnode
,
SArray
*
pArray
)
{
static
int32_t
mndTransExecuteActions
(
SMnode
*
pMnode
,
SArray
*
pArray
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
#if 0
int32_t arraySize = taosArrayGetSize(pArray);
int32_t arraySize = taosArrayGetSize(pArray);
for (int32_t i = 0; i < arraySize; ++i) {
for (int32_t i = 0; i < arraySize; ++i) {
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
STransAction *pAction = taosArrayGet(pArray, i);
int32_t
code
=
sdbWriteNotFree
(
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
SRpcMsg rpcMsg = {.msgType = pAction->msgType, .contLen = pAction->contLen};
return
code
;
rpcMsg.pCont = rpcMallocCont(pAction->contLen);
if (rpcMsg.pCont == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
}
memcpy(rpcMsg.pCont, pAction->pCont, pAction->contLen);
mndSendMsgToDnode(pMnode, &pAction->epSet, &rpcMsg);
}
}
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
#else
return
0
;
return
0
;
#endif
}
}
static
int32_t
mndTransExecuteRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
redoActions
)
<=
0
)
return
0
;
if
(
taosArrayGetSize
(
pTrans
->
redoActions
)
!=
0
)
{
mTrace
(
"trans:%d, execute redo actions finished"
,
pTrans
->
id
);
}
return
code
;
mTrace
(
"trans:%d, start to execute redo actions"
,
pTrans
->
id
);
return
mndTransExecuteActions
(
pMnode
,
pTrans
->
redoActions
);
}
}
static
int32_t
mndTransExecuteUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
undoActions
)
<=
0
)
return
0
;
if
(
taosArrayGetSize
(
pTrans
->
undoActions
)
!=
0
)
{
mTrace
(
"trans:%d, execute undo actions finished"
,
pTrans
->
id
);
}
return
code
;
mTrace
(
"trans:%d, start to execute undo actions"
,
pTrans
->
id
);
return
mndTransExecuteActions
(
pMnode
,
pTrans
->
undoActions
);
}
}
static
int32_t
mndTransPerformPrepareStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransPerformPrepareStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
6f0f7c58
...
@@ -158,7 +158,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup) {
...
@@ -158,7 +158,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup) {
}
}
SCreateVnodeMsg
*
mndBuildCreateVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SCreateVnodeMsg
*
mndBuildCreateVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SCreateVnodeMsg
*
pCreate
=
rpcMallocCont
(
sizeof
(
SCreateVnodeMsg
));
SCreateVnodeMsg
*
pCreate
=
malloc
(
sizeof
(
SCreateVnodeMsg
));
if
(
pCreate
==
NULL
)
{
if
(
pCreate
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
...
@@ -192,7 +192,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
...
@@ -192,7 +192,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
v
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
v
];
SDnodeObj
*
pVgidDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
SDnodeObj
*
pVgidDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pVgidDnode
==
NULL
)
{
if
(
pVgidDnode
==
NULL
)
{
rpcFreeCont
(
pCreate
);
free
(
pCreate
);
terrno
=
TSDB_CODE_MND_APP_ERROR
;
terrno
=
TSDB_CODE_MND_APP_ERROR
;
return
NULL
;
return
NULL
;
}
}
...
@@ -208,7 +208,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
...
@@ -208,7 +208,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
}
}
if
(
pCreate
->
selfIndex
==
-
1
)
{
if
(
pCreate
->
selfIndex
==
-
1
)
{
rpcFreeCont
(
pCreate
);
free
(
pCreate
);
terrno
=
TSDB_CODE_MND_APP_ERROR
;
terrno
=
TSDB_CODE_MND_APP_ERROR
;
return
NULL
;
return
NULL
;
}
}
...
@@ -217,7 +217,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
...
@@ -217,7 +217,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
}
}
SDropVnodeMsg
*
mndBuildDropVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SDropVnodeMsg
*
mndBuildDropVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SDropVnodeMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SDropVnodeMsg
));
SDropVnodeMsg
*
pDrop
=
malloc
(
sizeof
(
SDropVnodeMsg
));
if
(
pDrop
==
NULL
)
{
if
(
pDrop
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录