Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cb5ec76c
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看板
提交
cb5ec76c
编写于
12月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: check conflict before create trans
上级
e6c6de96
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
5 deletion
+40
-5
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-2
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+4
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+3
-0
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+17
-2
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+5
-0
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+7
-1
未找到文件。
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
cb5ec76c
...
...
@@ -557,6 +557,8 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
mInfo
(
"trans:%d, used to create db:%s"
,
pTrans
->
id
,
pCreate
->
db
);
mndTransSetDbName
(
pTrans
,
dbObj
.
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
mndTransSetOper
(
pTrans
,
MND_OPER_CREATE_DB
);
if
(
mndSetCreateDbRedoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbUndoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
...
...
@@ -776,7 +778,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
int32_t
code
=
-
1
;
mndTransSetDbName
(
pTrans
,
pOld
->
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
return
-
1
;
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbRedoLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbCommitLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
...
...
@@ -1038,7 +1040,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
mInfo
(
"trans:%d, used to drop db:%s"
,
pTrans
->
id
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndCheckTopicExist
(
pMnode
,
pDb
)
<
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
cb5ec76c
...
...
@@ -595,6 +595,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB
,
pReq
,
"create-sma"
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
mndTransSetSerial
(
pTrans
);
mInfo
(
"trans:%d, used to create sma:%s stream:%s"
,
pTrans
->
id
,
pCreate
->
name
,
streamObj
.
name
);
...
...
@@ -809,6 +811,8 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
mInfo
(
"trans:%d, used to drop sma:%s"
,
pTrans
->
id
,
pSma
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
mndTransSetSerial
(
pTrans
);
char
streamName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
cb5ec76c
...
...
@@ -823,6 +823,7 @@ _OVER:
int32_t
mndAddStbToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
pStb
->
name
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbUndoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
...
...
@@ -1856,6 +1857,7 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbOb
mInfo
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
pStb
->
name
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
...
...
@@ -2055,6 +2057,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
mInfo
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
pStb
->
name
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
cb5ec76c
...
...
@@ -640,9 +640,11 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
mError
(
"stream:%s, failed to create since %s"
,
createStreamReq
.
name
,
terrstr
());
goto
_OVER
;
}
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
,
streamObj
.
targetDb
);
mInfo
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
createStreamReq
.
name
);
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
,
streamObj
.
targetDb
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
// create stb for stream
if
(
mndCreateStbForStream
(
pMnode
,
pTrans
,
&
streamObj
,
pReq
->
info
.
conn
.
user
)
<
0
)
{
mError
(
"trans:%d, failed to create stb for stream %s since %s"
,
pTrans
->
id
,
createStreamReq
.
name
,
terrstr
());
...
...
@@ -790,6 +792,12 @@ static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) {
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"stream-checkpoint"
);
if
(
pTrans
==
NULL
)
return
-
1
;
mndTransSetDbName
(
pTrans
,
pStream
->
sourceDb
,
pStream
->
targetDb
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
mndReleaseStream
(
pMnode
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
taosRLockLatch
(
&
pStream
->
lock
);
// 1. redo action: broadcast checkpoint source msg for all source vg
int32_t
totLevel
=
taosArrayGetSize
(
pStream
->
tasks
);
...
...
@@ -882,11 +890,11 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pStream
->
targetDb
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"drop-stream"
);
mndTransSetDbName
(
pTrans
,
pStream
->
sourceDb
,
pStream
->
targetDb
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
...
...
@@ -894,6 +902,13 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
}
mInfo
(
"trans:%d, used to drop stream:%s"
,
pTrans
->
id
,
dropReq
.
name
);
mndTransSetDbName
(
pTrans
,
pStream
->
sourceDb
,
pStream
->
targetDb
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
// drop all tasks
if
(
mndDropStreamTasks
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
dropReq
.
name
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
cb5ec76c
...
...
@@ -442,7 +442,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
static
int32_t
mndPersistRebResult
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
const
SMqRebOutputObj
*
pOutput
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pMsg
,
"tmq-reb"
);
if
(
pTrans
==
NULL
)
return
-
1
;
mndTransSetDbName
(
pTrans
,
pOutput
->
pSub
->
dbName
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
mndTransDrop
(
pTrans
);
return
-
1
;
}
// make txn:
// 1. redo action: action to all vg
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
cb5ec76c
...
...
@@ -706,13 +706,19 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
#endif
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"drop-topic"
);
mndTransSetDbName
(
pTrans
,
pTopic
->
db
,
NULL
);
if
(
pTrans
==
NULL
)
{
mError
(
"topic:%s, failed to drop since %s"
,
pTopic
->
name
,
terrstr
());
mndReleaseTopic
(
pMnode
,
pTopic
);
return
-
1
;
}
mndTransSetDbName
(
pTrans
,
pTopic
->
db
,
NULL
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
mndReleaseTopic
(
pMnode
,
pTopic
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
mInfo
(
"trans:%d, used to drop topic:%s"
,
pTrans
->
id
,
pTopic
->
name
);
// TODO check if rebalancing
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录