Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5f74daa5
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看板
提交
5f74daa5
编写于
5月 31, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: display the ertransaction error reason
上级
a15f46d0
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
48 addition
and
35 deletion
+48
-35
include/util/tdef.h
include/util/tdef.h
+1
-2
source/common/src/systable.c
source/common/src/systable.c
+0
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+4
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+42
-13
tests/script/tsim/trans/create_db.sim
tests/script/tsim/trans/create_db.sim
+1
-17
未找到文件。
include/util/tdef.h
浏览文件 @
5f74daa5
...
...
@@ -253,8 +253,7 @@ typedef enum ELogicConditionType {
#define TSDB_TRANS_STAGE_LEN 12
#define TSDB_TRANS_TYPE_LEN 16
#define TSDB_TRANS_ERROR_LEN 64
#define TSDB_TRANS_DESC_LEN 128
#define TSDB_TRANS_ERROR_LEN 512
#define TSDB_STEP_NAME_LEN 32
#define TSDB_STEP_DESC_LEN 128
...
...
source/common/src/systable.c
浏览文件 @
5f74daa5
...
...
@@ -215,7 +215,6 @@ static const SSysDbTableSchema transSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"stage"
,
.
bytes
=
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"type"
,
.
bytes
=
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"failed_times"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"last_exec_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_error"
,
.
bytes
=
(
TSDB_TRANS_ERROR_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
5f74daa5
...
...
@@ -119,9 +119,11 @@ typedef struct {
SArray
*
commitActions
;
int64_t
createdTime
;
int64_t
lastExecTime
;
int32_t
lastErrorAction
;
int32_t
lastErrorNo
;
tmsg_t
lastErrorMsgType
;
SEpSet
lastErrorEpset
;
char
dbname
[
TSDB_DB_FNAME_LEN
];
char
lastError
[
TSDB_TRANS_ERROR_LEN
];
char
desc
[
TSDB_TRANS_DESC_LEN
];
int32_t
startFunc
;
int32_t
stopFunc
;
int32_t
paramLen
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
5f74daa5
...
...
@@ -813,9 +813,6 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
if
(
pAction
!=
NULL
)
{
pAction
->
msgReceived
=
1
;
pAction
->
errCode
=
pRsp
->
code
;
if
(
pAction
->
errCode
!=
0
)
{
tstrncpy
(
pTrans
->
lastError
,
tstrerror
(
pAction
->
errCode
),
TSDB_TRANS_ERROR_LEN
);
}
}
mDebug
(
"trans:%d, %s:%d response is received, code:0x%x, accept:0x%x"
,
transId
,
mndTransStr
(
pAction
->
stage
),
action
,
...
...
@@ -926,22 +923,34 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
int32_t
numOfExecuted
=
0
;
int32_t
errCode
=
0
;
STransAction
*
pErrAction
=
NULL
;
for
(
int32_t
action
=
0
;
action
<
numOfActions
;
++
action
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
action
);
if
(
pAction
->
msgReceived
||
pAction
->
rawWritten
)
{
numOfExecuted
++
;
if
(
pAction
->
errCode
!=
0
&&
pAction
->
errCode
!=
pAction
->
acceptableCode
)
{
errCode
=
pAction
->
errCode
;
pErrAction
=
pAction
;
}
}
}
if
(
numOfExecuted
==
numOfActions
)
{
if
(
errCode
==
0
)
{
pTrans
->
lastErrorAction
=
0
;
pTrans
->
lastErrorNo
=
0
;
pTrans
->
lastErrorMsgType
=
0
;
memset
(
&
pTrans
->
lastErrorEpset
,
0
,
sizeof
(
pTrans
->
lastErrorEpset
));
mDebug
(
"trans:%d, all %d actions execute successfully"
,
pTrans
->
id
,
numOfActions
);
return
0
;
}
else
{
mError
(
"trans:%d, all %d actions executed, code:0x%x"
,
pTrans
->
id
,
numOfActions
,
errCode
&
0XFFFF
);
if
(
pErrAction
!=
NULL
)
{
pTrans
->
lastErrorMsgType
=
pErrAction
->
msgType
;
pTrans
->
lastErrorAction
=
pErrAction
->
id
;
pTrans
->
lastErrorNo
=
pErrAction
->
errCode
;
pTrans
->
lastErrorEpset
=
pErrAction
->
epSet
;
}
mndTransResetActions
(
pMnode
,
pTrans
,
pArray
);
terrno
=
errCode
;
return
errCode
;
...
...
@@ -976,7 +985,7 @@ static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans) {
return
code
;
}
static
int32_t
mndTransExecuteRedoActions
NoParalle
l
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransExecuteRedoActions
Seria
l
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
0
;
int32_t
numOfActions
=
taosArrayGetSize
(
pTrans
->
redoActions
);
if
(
numOfActions
==
0
)
return
code
;
...
...
@@ -1003,6 +1012,18 @@ static int32_t mndTransExecuteRedoActionsNoParallel(SMnode *pMnode, STrans *pTra
}
}
if
(
code
==
0
)
{
pTrans
->
lastErrorAction
=
0
;
pTrans
->
lastErrorNo
=
0
;
pTrans
->
lastErrorMsgType
=
0
;
memset
(
&
pTrans
->
lastErrorEpset
,
0
,
sizeof
(
pTrans
->
lastErrorEpset
));
}
else
{
pTrans
->
lastErrorMsgType
=
pAction
->
msgType
;
pTrans
->
lastErrorAction
=
action
;
pTrans
->
lastErrorNo
=
pAction
->
errCode
;
pTrans
->
lastErrorEpset
=
pAction
->
epSet
;
}
if
(
code
==
0
)
{
pTrans
->
redoActionPos
++
;
mDebug
(
"trans:%d, %s:%d is executed and need sync to other mnodes"
,
pTrans
->
id
,
mndTransStr
(
pAction
->
stage
),
...
...
@@ -1037,7 +1058,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
int32_t
code
=
0
;
if
(
pTrans
->
exec
==
TRN_EXEC_SERIAL
)
{
code
=
mndTransExecuteRedoActions
NoParalle
l
(
pMnode
,
pTrans
);
code
=
mndTransExecuteRedoActions
Seria
l
(
pMnode
,
pTrans
);
}
else
{
code
=
mndTransExecuteRedoActions
(
pMnode
,
pTrans
);
}
...
...
@@ -1347,11 +1368,6 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
dbname
,
false
);
char
type
[
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
type
,
"todo"
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
type
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
failedTimes
,
false
);
...
...
@@ -1359,7 +1375,20 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
lastExecTime
,
false
);
char
lastError
[
TSDB_TRANS_ERROR_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
lastError
,
pTrans
->
lastError
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
char
detail
[
TSDB_TRANS_ERROR_LEN
]
=
{
0
};
if
(
pTrans
->
lastErrorNo
!=
0
)
{
int32_t
len
=
snprintf
(
detail
,
sizeof
(
detail
),
"action:%d errno:0x%x(%s) "
,
pTrans
->
lastErrorAction
,
pTrans
->
lastErrorNo
&
0xFFFF
,
tstrerror
(
pTrans
->
lastErrorNo
));
SEpSet
epset
=
pTrans
->
lastErrorEpset
;
if
(
epset
.
numOfEps
>
0
)
{
len
+=
snprintf
(
detail
+
len
,
sizeof
(
detail
)
-
len
,
"msgType:%s numOfEps:%d inUse:%d "
,
TMSG_INFO
(
pTrans
->
lastErrorMsgType
),
epset
.
numOfEps
,
epset
.
inUse
);
}
for
(
int32_t
i
=
0
;
i
<
pTrans
->
lastErrorEpset
.
numOfEps
;
++
i
)
{
len
+=
snprintf
(
detail
+
len
,
sizeof
(
detail
)
-
len
,
"ep:%d-%s:%u "
,
i
,
epset
.
eps
[
i
].
fqdn
,
epset
.
eps
[
i
].
port
);
}
}
STR_WITH_MAXSIZE_TO_VARSTR
(
lastError
,
detail
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
lastError
,
false
);
...
...
tests/script/tsim/trans/create_db.sim
浏览文件 @
5f74daa5
...
...
@@ -76,14 +76,6 @@ if $data[0][3] != d1 then
return -1
endi
if $data[0][4] != todo then
return -1
endi
if $data[0][7] != @Unable to establish connection@ then
return -1
endi
sql_error create database d1 vgroups 2;
print =============== start dnode2
...
...
@@ -125,15 +117,7 @@ endi
if $data[0][3] != d2 then
return -1
endi
if $data[0][4] != todo then
return -1
endi
if $data[0][7] != @Unable to establish connection@ then
return -1
endi
return
sql_error create database d2 vgroups 2;
print =============== kill transaction
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录