Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
856104c4
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
856104c4
编写于
12月 25, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
455006cc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
106 deletion
+73
-106
source/dnode/mnode/impl/inc/mndTopic.h
source/dnode/mnode/impl/inc/mndTopic.h
+1
-1
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-2
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+28
-28
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+41
-74
未找到文件。
source/dnode/mnode/impl/inc/mndTopic.h
浏览文件 @
856104c4
...
...
@@ -26,7 +26,7 @@ int32_t mndInitTopic(SMnode *pMnode);
void
mndCleanupTopic
(
SMnode
*
pMnode
);
STopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
);
void
mndReleaseTopic
(
SMnode
*
pMnode
,
STopicObj
*
pTopic
);
void
mndReleaseTopic
(
SMnode
*
pMnode
,
STopicObj
*
pTopic
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
856104c4
...
...
@@ -441,7 +441,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int16_t le
}
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
bytes
=
len
>
0
?
(
int
)(
len
-
VARSTR_HEADER_SIZE
)
:
len
;
int32_t
bytes
=
len
>
0
?
(
int
32_t
)(
len
-
VARSTR_HEADER_SIZE
)
:
len
;
snprintf
(
buf
,
buflen
-
1
,
"%s(%d)"
,
tDataTypes
[
type
].
name
,
type
==
TSDB_DATA_TYPE_NCHAR
?
bytes
/
4
:
bytes
);
buf
[
buflen
-
1
]
=
0
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
856104c4
...
...
@@ -834,8 +834,8 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM
}
static
void
mndExtractTableName
(
char
*
tableId
,
char
*
name
)
{
int
pos
=
-
1
;
int
num
=
0
;
int
32_t
pos
=
-
1
;
int
32_t
num
=
0
;
for
(
pos
=
0
;
tableId
[
pos
]
!=
0
;
++
pos
)
{
if
(
tableId
[
pos
]
==
'.'
)
num
++
;
if
(
num
==
2
)
break
;
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
856104c4
...
...
@@ -14,18 +14,18 @@
*/
#define _DEFAULT_SOURCE
#include "mndStb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndStb.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "tname.h"
#define
TSDB
_TOPIC_VER_NUMBER 1
#define
TSDB
_TOPIC_RESERVE_SIZE 64
#define
MND
_TOPIC_VER_NUMBER 1
#define
MND
_TOPIC_RESERVE_SIZE 64
static
SSdbRaw
*
mndTopicActionEncode
(
STopicObj
*
pTopic
);
static
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -73,8 +73,8 @@ int32_t mndInitTopic(SMnode *pMnode) {
void
mndCleanupTopic
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndTopicActionEncode
(
STopicObj
*
pTopic
)
{
int32_t
size
=
sizeof
(
STopicObj
)
+
TSDB
_TOPIC_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
TSDB
_TOPIC_VER_NUMBER
,
size
);
int32_t
size
=
sizeof
(
STopicObj
)
+
MND
_TOPIC_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
MND
_TOPIC_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
...
...
@@ -90,7 +90,7 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB
_TOPIC_RESERVE_SIZE
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND
_TOPIC_RESERVE_SIZE
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
return
pRaw
;
...
...
@@ -100,14 +100,14 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_TOPIC_VER_NUMBER
)
{
mError
(
"failed to decode stable since %s"
,
terrstr
());
if
(
sver
!=
MND_TOPIC_VER_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
mError
(
"failed to decode topic since %s"
,
terrstr
());
return
NULL
;
}
int32_t
size
=
sizeof
(
STopicObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
int32_t
size
=
sizeof
(
STopicObj
)
+
TSDB_MAX_COLUMNS
*
sizeof
(
SSchema
);
SSdbRow
*
pRow
=
sdbAllocRow
(
size
);
STopicObj
*
pTopic
=
sdbGetRowObj
(
pRow
);
if
(
pTopic
==
NULL
)
return
NULL
;
...
...
@@ -124,7 +124,7 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pTopic
->
sqlLen
);
SDB_GET_BINARY
(
pRaw
,
pRow
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
);
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB
_TOPIC_RESERVE_SIZE
);
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
MND
_TOPIC_RESERVE_SIZE
);
return
pRow
;
}
...
...
@@ -168,7 +168,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pOldTopic, STopicObj
}
STopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
STopicObj
*
pTopic
=
sdbAcquire
(
pSdb
,
SDB_TOPIC
,
topicName
);
if
(
pTopic
==
NULL
)
{
terrno
=
TSDB_CODE_MND_TOPIC_NOT_EXIST
;
...
...
@@ -208,7 +208,7 @@ static SCreateTopicInternalMsg *mndBuildCreateTopicMsg(SMnode *pMnode, SVgObj *p
pCreate
->
sverson
=
htonl
(
pTopic
->
version
);
pCreate
->
sql
=
malloc
(
pTopic
->
sqlLen
);
if
(
pCreate
->
sql
==
NULL
)
{
if
(
pCreate
->
sql
==
NULL
)
{
free
(
pCreate
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
...
...
@@ -216,7 +216,7 @@ static SCreateTopicInternalMsg *mndBuildCreateTopicMsg(SMnode *pMnode, SVgObj *p
memcpy
(
pCreate
->
sql
,
pTopic
->
sql
,
pTopic
->
sqlLen
);
pCreate
->
executor
=
malloc
(
pTopic
->
execLen
);
if
(
pCreate
->
executor
==
NULL
)
{
if
(
pCreate
->
executor
==
NULL
)
{
free
(
pCreate
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
...
...
@@ -244,7 +244,7 @@ static SDropTopicInternalMsg *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgro
}
static
int32_t
mndCheckCreateTopicMsg
(
SCreateTopicMsg
*
pCreate
)
{
//deserialize and other stuff
//
deserialize and other stuff
return
0
;
}
...
...
@@ -413,7 +413,7 @@ CREATE_TOPIC_OVER:
}
static
int32_t
mndProcessCreateTopicMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SCreateTopicMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"topic:%s, start to create"
,
pCreate
->
name
);
...
...
@@ -436,7 +436,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
}
}
//topic should have different name with stb
//
topic should have different name with stb
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pCreate
->
name
);
if
(
pStb
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStb
);
...
...
@@ -492,7 +492,7 @@ static int32_t mndCheckAlterTopicMsg(SAlterTopicMsg *pAlter) {
static
int32_t
mndUpdateTopic
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
STopicObj
*
pOldTopic
,
STopicObj
*
pNewTopic
)
{
return
0
;
}
static
int32_t
mndProcessAlterTopicMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SAlterTopicMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"topic:%s, start to alter"
,
pAlter
->
name
);
...
...
@@ -606,7 +606,7 @@ DROP_TOPIC_OVER:
}
static
int32_t
mndProcessDropTopicMsg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SDropTopicMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"topic:%s, start to drop"
,
pDrop
->
name
);
...
...
@@ -705,7 +705,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
return
0
;
}
static
int32_t
mndProcessCreateTopicInRsp
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mndProcessCreateTopicInRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransHandleActionRsp
(
pMsg
);
return
0
;
}
...
...
@@ -788,8 +788,8 @@ static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
}
static
void
mndExtractTableName
(
char
*
tableId
,
char
*
name
)
{
int
pos
=
-
1
;
int
num
=
0
;
int
32_t
pos
=
-
1
;
int
32_t
num
=
0
;
for
(
pos
=
0
;
tableId
[
pos
]
!=
0
;
++
pos
)
{
if
(
tableId
[
pos
]
==
'.'
)
num
++
;
if
(
num
==
2
)
break
;
...
...
@@ -801,13 +801,13 @@ static void mndExtractTableName(char *tableId, char *name) {
}
static
int32_t
mndRetrieveTopic
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
STopicObj
*
pTopic
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
int32_t
cols
=
0
;
char
*
pWrite
;
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pShow
->
db
,
64
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
856104c4
...
...
@@ -17,9 +17,9 @@
#include "mndTrans.h"
#include "mndSync.h"
#define
TSDB
_TRANS_VER_NUMBER 1
#define
TSDB_TRN
_ARRAY_SIZE 8
#define
TSDB_TRN
_RESERVE_SIZE 64
#define
MND
_TRANS_VER_NUMBER 1
#define
MND_TRANS
_ARRAY_SIZE 8
#define
MND_TRANS
_RESERVE_SIZE 64
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRow
*
mndTransActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -61,7 +61,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
void
mndCleanupTrans
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
)
{
int32_t
rawDataLen
=
sizeof
(
STrans
)
+
TSDB_TRN
_RESERVE_SIZE
;
int32_t
rawDataLen
=
sizeof
(
STrans
)
+
MND_TRANS
_RESERVE_SIZE
;
int32_t
redoLogNum
=
taosArrayGetSize
(
pTrans
->
redoLogs
);
int32_t
undoLogNum
=
taosArrayGetSize
(
pTrans
->
undoLogs
);
int32_t
commitLogNum
=
taosArrayGetSize
(
pTrans
->
commitLogs
);
...
...
@@ -93,7 +93,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
}
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TRANS
,
TSDB
_TRANS_VER_NUMBER
,
rawDataLen
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TRANS
,
MND
_TRANS_VER_NUMBER
,
rawDataLen
);
if
(
pRaw
==
NULL
)
{
mError
(
"trans:%d, failed to alloc raw since %s"
,
pTrans
->
id
,
terrstr
());
return
NULL
;
...
...
@@ -145,7 +145,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
(
void
*
)
pAction
->
pCont
,
pAction
->
contLen
);
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_TRN
_RESERVE_SIZE
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TRANS
_RESERVE_SIZE
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
mTrace
(
"trans:%d, encode to raw:%p, len:%d"
,
pTrans
->
id
,
pRaw
,
dataPos
);
return
pRaw
;
...
...
@@ -155,12 +155,9 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
int32_t
code
=
0
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
{
mError
(
"failed to get soft ver from raw:%p since %s"
,
pRaw
,
terrstr
());
return
NULL
;
}
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB
_TRANS_VER_NUMBER
)
{
if
(
sver
!=
MND
_TRANS_VER_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
mError
(
"failed to get check soft ver from raw:%p since %s"
,
pRaw
,
terrstr
());
return
NULL
;
...
...
@@ -173,11 +170,11 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
return
NULL
;
}
pTrans
->
redoLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
undoLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
commitLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
redoActions
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
undoActions
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
redoLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
undoLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
commitLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
redoActions
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
undoActions
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
STransAction
));
if
(
pTrans
->
redoLogs
==
NULL
||
pTrans
->
undoLogs
==
NULL
||
pTrans
->
commitLogs
==
NULL
||
pTrans
->
redoActions
==
NULL
||
pTrans
->
undoActions
==
NULL
)
{
...
...
@@ -278,7 +275,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
}
}
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB_TRN
_RESERVE_SIZE
)
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
MND_TRANS
_RESERVE_SIZE
)
TRANS_DECODE_OVER:
if
(
code
!=
0
)
{
...
...
@@ -370,11 +367,11 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
pTrans
->
policy
=
policy
;
pTrans
->
rpcHandle
=
rpcHandle
;
pTrans
->
redoLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
undoLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
commitLogs
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
redoActions
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
undoActions
=
taosArrayInit
(
TSDB_TRN
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
redoLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
undoLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
commitLogs
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
redoActions
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
STransAction
));
pTrans
->
undoActions
=
taosArrayInit
(
MND_TRANS
_ARRAY_SIZE
,
sizeof
(
STransAction
));
if
(
pTrans
->
redoLogs
==
NULL
||
pTrans
->
undoLogs
==
NULL
||
pTrans
->
commitLogs
==
NULL
||
pTrans
->
redoActions
==
NULL
||
pTrans
->
undoActions
==
NULL
)
{
...
...
@@ -504,7 +501,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
STrans
*
pNewTrans
=
mndAcquireTrans
(
pMnode
,
pTrans
->
id
);
if
(
pNewTrans
==
NULL
)
{
mError
(
"trans:%d, failed to read
y
from sdb since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to read from sdb since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
}
...
...
@@ -526,19 +523,17 @@ int32_t mndTransCommit(SMnode *pMnode, STrans *pTrans) {
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
mTrace
(
"trans:%d, sync to other nodes"
,
pTrans
->
id
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
);
if
(
code
!=
0
)
{
if
(
mndSyncPropose
(
pMnode
,
pRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to sync since %s"
,
pTrans
->
id
,
terrstr
());
sdbFreeRaw
(
pRaw
);
return
-
1
;
}
mTrace
(
"trans:%d, sync finished"
,
pTrans
->
id
);
code
=
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to write sdb since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
}
}
if
(
sdbWrite
(
pMnode
->
pSdb
,
pRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to write sdb since %s"
,
pTrans
->
id
,
terrstr
())
;
return
-
1
;
}
mDebug
(
"trans:%d, commit finished"
,
pTrans
->
id
);
...
...
@@ -614,7 +609,7 @@ void mndTransHandleActionRsp(SMnodeMsg *pMsg) {
}
int32_t
actionNum
=
taosArrayGetSize
(
pTrans
->
redoActions
);
if
(
action
<
0
||
action
>
actionNum
)
{
if
(
action
<
0
||
action
>
=
actionNum
)
{
mError
(
"trans:%d, invalid action:%d"
,
transId
,
action
);
goto
HANDLE_ACTION_RSP_OVER
;
}
...
...
@@ -636,6 +631,8 @@ static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) {
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
arraySize
=
taosArrayGetSize
(
pArray
);
if
(
arraySize
==
0
)
return
0
;
for
(
int32_t
i
=
0
;
i
<
arraySize
;
++
i
)
{
SSdbRaw
*
pRaw
=
taosArrayGetP
(
pArray
,
i
);
int32_t
code
=
sdbWriteNotFree
(
pSdb
,
pRaw
);
...
...
@@ -648,45 +645,15 @@ static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) {
}
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
redoLogs
)
!=
0
)
{
code
=
mndTransExecuteLogs
(
pMnode
,
pTrans
->
redoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute redo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mDebug
(
"trans:%d, execute redo logs finished"
,
pTrans
->
id
)
}
}
return
code
;
return
mndTransExecuteLogs
(
pMnode
,
pTrans
->
redoLogs
);
}
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
undoLogs
)
!=
0
)
{
code
=
mndTransExecuteLogs
(
pMnode
,
pTrans
->
undoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute undo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mDebug
(
"trans:%d, execute undo logs finished"
,
pTrans
->
id
)
}
}
return
code
;
return
mndTransExecuteLogs
(
pMnode
,
pTrans
->
undoLogs
);
}
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
code
=
mndTransExecuteLogs
(
pMnode
,
pTrans
->
commitLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute commit logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mDebug
(
"trans:%d, execute commit logs finished"
,
pTrans
->
id
)
}
}
return
code
;
return
mndTransExecuteLogs
(
pMnode
,
pTrans
->
commitLogs
);
}
static
int32_t
mndTransExecuteActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SArray
*
pArray
)
{
...
...
@@ -719,25 +686,25 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
mndSendMsgToDnode
(
pMnode
,
&
pAction
->
epSet
,
&
rpcMsg
);
}
int32_t
numOfReceived
Msgs
=
0
;
int32_t
err
or
Code
=
0
;
int32_t
numOfReceived
=
0
;
int32_t
errCode
=
0
;
for
(
int32_t
action
=
0
;
action
<
numOfActions
;
++
action
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
action
);
if
(
pAction
==
NULL
)
continue
;
if
(
pAction
->
msgSent
&&
pAction
->
msgReceived
)
{
numOfReceived
Msgs
++
;
numOfReceived
++
;
if
(
pAction
->
errCode
!=
0
)
{
err
or
Code
=
pAction
->
errCode
;
errCode
=
pAction
->
errCode
;
}
}
}
if
(
numOfReceived
Msgs
==
numOfActions
)
{
mDebug
(
"trans:%d, all %d actions executed, code:0x%x"
,
pTrans
->
id
,
numOfActions
,
err
or
Code
);
terrno
=
err
or
Code
;
return
err
or
Code
;
if
(
numOfReceived
==
numOfActions
)
{
mDebug
(
"trans:%d, all %d actions executed, code:0x%x"
,
pTrans
->
id
,
numOfActions
,
errCode
);
terrno
=
errCode
;
return
errCode
;
}
else
{
mDebug
(
"trans:%d, %d of %d actions executed, code:0x%x"
,
pTrans
->
id
,
numOfReceived
Msgs
,
numOfActions
,
erro
rCode
);
mDebug
(
"trans:%d, %d of %d actions executed, code:0x%x"
,
pTrans
->
id
,
numOfReceived
,
numOfActions
,
er
rCode
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录