Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
95f696b3
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看板
提交
95f696b3
编写于
8月 10, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(tmq): prevent drop db when topic exists
上级
e5e82f0c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
36 addition
and
23 deletion
+36
-23
examples/rust
examples/rust
+0
-1
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/client/src/tmq.c
source/client/src/tmq.c
+5
-16
source/dnode/mnode/impl/inc/mndTopic.h
source/dnode/mnode/impl/inc/mndTopic.h
+1
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+6
-4
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+1
-1
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+20
-0
source/util/src/terror.c
source/util/src/terror.c
+1
-0
tools/taos-tools
tools/taos-tools
+0
-1
未找到文件。
rust
@
7ed7a977
Subproject commit 7ed7a97715388fa144718764d6bf20f9bfc29a12
include/util/taoserror.h
浏览文件 @
95f696b3
...
...
@@ -284,11 +284,13 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_CONSUMER_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x03EA)
#define TSDB_CODE_MND_TOPIC_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x03EB)
#define TSDB_CODE_MND_CGROUP_USED TAOS_DEF_ERROR_CODE(0, 0x03EC)
#define TSDB_CODE_MND_TOPIC_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03ED)
// mnode-stream
#define TSDB_CODE_MND_STREAM_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F0)
#define TSDB_CODE_MND_STREAM_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F1)
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
#define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3)
// mnode-sma
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
...
...
source/client/src/tmq.c
浏览文件 @
95f696b3
...
...
@@ -204,7 +204,7 @@ typedef struct {
typedef
struct
{
SMqCommitCbParamSet
*
params
;
STqOffset
*
pOffset
;
}
SMqCommitCbParam
2
;
}
SMqCommitCbParam
;
tmq_conf_t
*
tmq_conf_new
()
{
tmq_conf_t
*
conf
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_conf_t
));
...
...
@@ -368,8 +368,8 @@ static int32_t tmqMakeTopicVgKey(char* dst, const char* topicName, int32_t vg) {
return
sprintf
(
dst
,
"%s:%d"
,
topicName
,
vg
);
}
int32_t
tmqCommitCb
2
(
void
*
param
,
SDataBuf
*
pBuf
,
int32_t
code
)
{
SMqCommitCbParam
2
*
pParam
=
(
SMqCommitCbParam2
*
)
param
;
int32_t
tmqCommitCb
(
void
*
param
,
SDataBuf
*
pBuf
,
int32_t
code
)
{
SMqCommitCbParam
*
pParam
=
(
SMqCommitCbParam
*
)
param
;
SMqCommitCbParamSet
*
pParamSet
=
(
SMqCommitCbParamSet
*
)
pParam
->
params
;
// push into array
#if 0
...
...
@@ -440,7 +440,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
tEncodeSTqOffset
(
&
encoder
,
pOffset
);
// build param
SMqCommitCbParam
2
*
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqCommitCbParam2
));
SMqCommitCbParam
*
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqCommitCbParam
));
pParam
->
params
=
pParamSet
;
pParam
->
pOffset
=
pOffset
;
...
...
@@ -465,7 +465,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
pMsgSendInfo
->
requestObjRefId
=
0
;
pMsgSendInfo
->
param
=
pParam
;
pMsgSendInfo
->
paramFreeFp
=
taosMemoryFree
;
pMsgSendInfo
->
fp
=
tmqCommitCb
2
;
pMsgSendInfo
->
fp
=
tmqCommitCb
;
pMsgSendInfo
->
msgType
=
TDMT_VND_MQ_COMMIT_OFFSET
;
// send msg
...
...
@@ -1313,17 +1313,6 @@ int32_t tmq_seek(tmq_t* tmq, const tmq_topic_vgroup_t* offset) {
#endif
SMqPollReq
*
tmqBuildConsumeReqImpl
(
tmq_t
*
tmq
,
int64_t
timeout
,
SMqClientTopic
*
pTopic
,
SMqClientVg
*
pVg
)
{
/*int64_t reqOffset;*/
/*if (pVg->currentOffset >= 0) {*/
/*reqOffset = pVg->currentOffset;*/
/*} else {*/
/*if (tmq->resetOffsetCfg == TMQ_CONF__RESET_OFFSET__NONE) {*/
/*tscError("unable to poll since no committed offset but reset offset is set to none");*/
/*return NULL;*/
/*}*/
/*reqOffset = tmq->resetOffsetCfg;*/
/*}*/
SMqPollReq
*
pReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqPollReq
));
if
(
pReq
==
NULL
)
{
return
NULL
;
...
...
source/dnode/mnode/impl/inc/mndTopic.h
浏览文件 @
95f696b3
...
...
@@ -32,6 +32,7 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic);
SSdbRow
*
mndTopicActionDecode
(
SSdbRaw
*
pRaw
);
int32_t
mndDropTopicByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
int32_t
mndCheckTopicExist
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
const
char
*
mndTopicGetShowName
(
const
char
topic
[
TSDB_TOPIC_FNAME_LEN
]);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
95f696b3
...
...
@@ -995,11 +995,13 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
mDebug
(
"trans:%d, used to drop db:%s"
,
pTrans
->
id
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndCheckTopicExist
(
pMnode
,
pDb
)
<
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropOffsetByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSubByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropTopicByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
/*if (mndDropOffsetByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
/*if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
/*if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
if
(
mndDropStreamByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSmasByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
...
...
@@ -1706,7 +1708,7 @@ static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
static
bool
mndGetTablesOfDbFp
(
SMnode
*
pMnode
,
void
*
pObj
,
void
*
p1
,
void
*
p2
,
void
*
p3
)
{
SVgObj
*
pVgroup
=
pObj
;
int32_t
*
numOfTables
=
p1
;
int64_t
uid
=
*
(
int64_t
*
)
p2
;
int64_t
uid
=
*
(
int64_t
*
)
p2
;
if
(
pVgroup
->
dbUid
==
uid
)
{
*
numOfTables
+=
pVgroup
->
numOfTables
;
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
95f696b3
...
...
@@ -837,7 +837,7 @@ int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
sdbCancelFetch
(
pSdb
,
pIter
);
mError
(
"db:%s, failed to drop stream:%s since sourceDbUid:%"
PRId64
" not match with targetDbUid:%"
PRId64
,
pDb
->
name
,
pStream
->
name
,
pStream
->
sourceDbUid
,
pStream
->
targetDbUid
);
terrno
=
TSDB_CODE_MND_STREAM_
ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_STREAM_
MUST_BE_DELETED
;
return
-
1
;
}
else
{
#if 0
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
95f696b3
...
...
@@ -782,6 +782,26 @@ static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter) {
sdbCancelFetch
(
pSdb
,
pIter
);
}
int32_t
mndCheckTopicExist
(
SMnode
*
pMnode
,
SDbObj
*
pDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
SMqTopicObj
*
pTopic
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_TOPIC
,
pIter
,
(
void
**
)
&
pTopic
);
if
(
pIter
==
NULL
)
break
;
if
(
pTopic
->
dbUid
==
pDb
->
uid
)
{
sdbRelease
(
pSdb
,
pTopic
);
terrno
=
TSDB_CODE_MND_TOPIC_MUST_BE_DELETED
;
return
-
1
;
}
sdbRelease
(
pSdb
,
pTopic
);
}
return
0
;
}
int32_t
mndDropTopicByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
int32_t
code
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/util/src/terror.c
浏览文件 @
95f696b3
...
...
@@ -286,6 +286,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SUBSCRIBE_NOT_EXIST, "Subcribe not exist")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_OFFSET_NOT_EXIST
,
"Offset not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_CONSUMER_NOT_READY
,
"Consumer not ready"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOPIC_SUBSCRIBED
,
"Topic subscribed cannot be dropped"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOPIC_MUST_BE_DELETED
,
"Topic must be dropped first"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_CGROUP_USED
,
"Consumer group being used by some consumer"
)
// mnode-stream
...
...
taos-tools
@
3c7dafee
Subproject commit 3c7dafeea3e558968165b73bee0f51024898e3da
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录