Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
536627ed
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看板
提交
536627ed
编写于
2月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
parallel exec trans
上级
ebd862de
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
91 addition
and
5 deletion
+91
-5
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+7
-5
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+82
-0
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
536627ed
...
...
@@ -247,6 +247,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0)
#define TSDB_CODE_MND_TRANS_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D1)
#define TSDB_CODE_MND_TRANS_INVALID_STAGE TAOS_DEF_ERROR_CODE(0, 0x03D2)
#define TSDB_CODE_MND_TRANS_CANT_PARALLEL TAOS_DEF_ERROR_CODE(0, 0x03D4)
// mnode-mq
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
536627ed
...
...
@@ -132,12 +132,14 @@ typedef enum {
TRN_TYPE_CREATE_DB
=
3001
,
TRN_TYPE_ALTER_DB
=
3002
,
TRN_TYPE_DROP_DB
=
3003
,
TRN_TYPE_CREATE_STB
=
3004
,
TRN_TYPE_ALTER_STB
=
3005
,
TRN_TYPE_DROP_STB
=
3006
,
TRN_TYPE_SPLIT_VGROUP
=
3007
,
TRN_TYPE_MERGE_VGROUP
=
3018
,
TRN_TYPE_SPLIT_VGROUP
=
3004
,
TRN_TYPE_MERGE_VGROUP
=
3015
,
TRN_TYPE_DB_SCOPE_END
,
TRN_TYPE_STB_SCOPE
=
4000
,
TRN_TYPE_CREATE_STB
=
4001
,
TRN_TYPE_ALTER_STB
=
4002
,
TRN_TYPE_DROP_STB
=
4003
,
TRN_TYPE_STB_SCOPE_END
,
}
ETrnType
;
typedef
enum
{
TRN_POLICY_ROLLBACK
=
0
,
TRN_POLICY_RETRY
=
1
}
ETrnPolicy
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
536627ed
...
...
@@ -546,7 +546,89 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
return
0
;
}
static
bool
mndIsBasicTrans
(
STrans
*
pTrans
)
{
return
pTrans
->
stage
>
TRN_TYPE_BASIC_SCOPE
&&
pTrans
->
stage
<
TRN_TYPE_BASIC_SCOPE_END
;
}
static
bool
mndIsGlobalTrans
(
STrans
*
pTrans
)
{
return
pTrans
->
stage
>
TRN_TYPE_GLOBAL_SCOPE
&&
pTrans
->
stage
<
TRN_TYPE_GLOBAL_SCOPE_END
;
}
static
bool
mndIsDbTrans
(
STrans
*
pTrans
)
{
return
pTrans
->
stage
>
TRN_TYPE_DB_SCOPE
&&
pTrans
->
stage
<
TRN_TYPE_DB_SCOPE_END
;
}
static
bool
mndIsStbTrans
(
STrans
*
pTrans
)
{
return
pTrans
->
stage
>
TRN_TYPE_STB_SCOPE
&&
pTrans
->
stage
<
TRN_TYPE_STB_SCOPE_END
;
}
static
int32_t
mndCheckTransCanBeStartedInParallel
(
SMnode
*
pMnode
,
STrans
*
pNewTrans
)
{
if
(
mndIsBasicTrans
(
pNewTrans
))
return
0
;
STrans
*
pTrans
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
code
=
0
;
while
(
1
)
{
pIter
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_TRANS
,
pIter
,
(
void
**
)
&
pTrans
);
if
(
pIter
==
NULL
)
break
;
if
(
mndIsGlobalTrans
(
pNewTrans
))
{
if
(
mndIsDbTrans
(
pTrans
)
||
mndIsStbTrans
(
pTrans
))
{
mError
(
"trans:%d, can't execute since trans:%d in progress db:%s"
,
pNewTrans
->
id
,
pTrans
->
id
,
pTrans
->
dbname
);
code
=
-
1
;
break
;
}
}
if
(
mndIsDbTrans
(
pNewTrans
))
{
if
(
mndIsBasicTrans
(
pTrans
))
continue
;
if
(
mndIsGlobalTrans
(
pTrans
))
{
mError
(
"trans:%d, can't execute since trans:%d in progress"
,
pNewTrans
->
id
,
pTrans
->
id
);
code
=
-
1
;
break
;
}
if
(
mndIsDbTrans
(
pTrans
)
||
mndIsStbTrans
(
pTrans
))
{
if
(
pNewTrans
->
dbUid
==
pTrans
->
dbUid
)
{
mError
(
"trans:%d, can't execute since trans:%d in progress db:%s"
,
pNewTrans
->
id
,
pTrans
->
id
,
pTrans
->
dbname
);
code
=
-
1
;
break
;
}
}
}
if
(
mndIsStbTrans
(
pNewTrans
))
{
if
(
mndIsBasicTrans
(
pTrans
))
continue
;
if
(
mndIsGlobalTrans
(
pTrans
))
{
mError
(
"trans:%d, can't execute since trans:%d in progress"
,
pNewTrans
->
id
,
pTrans
->
id
);
code
=
-
1
;
break
;
}
if
(
mndIsDbTrans
(
pTrans
))
{
if
(
pNewTrans
->
dbUid
==
pTrans
->
dbUid
)
{
mError
(
"trans:%d, can't execute since trans:%d in progress db:%s"
,
pNewTrans
->
id
,
pTrans
->
id
,
pTrans
->
dbname
);
code
=
-
1
;
break
;
}
}
if
(
mndIsStbTrans
(
pTrans
))
continue
;
}
sdbRelease
(
pMnode
->
pSdb
,
pTrans
);
}
sdbCancelFetch
(
pMnode
->
pSdb
,
pIter
);
sdbRelease
(
pMnode
->
pSdb
,
pTrans
);
return
code
;
}
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
mndCheckTransCanBeStartedInParallel
(
pMnode
,
pTrans
)
!=
0
)
{
terrno
=
TSDB_CODE_MND_TRANS_CANT_PARALLEL
;
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, prepare transaction"
,
pTrans
->
id
);
if
(
mndTransSync
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
...
...
source/util/src/terror.c
浏览文件 @
536627ed
...
...
@@ -257,6 +257,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_FUNC_RETRIEVE, "Invalid func retriev
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_ALREADY_EXIST
,
"Transaction already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_NOT_EXIST
,
"Transaction not exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_INVALID_STAGE
,
"Invalid stage to kill"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_CANT_PARALLEL
,
"Invalid stage to kill"
)
// mnode-topic
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_UNSUPPORTED_TOPIC
,
"Topic with STable not supported yet"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录