Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
58118cfa
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
58118cfa
编写于
3月 16, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10] drop stable message
上级
63d2e696
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
192 addition
and
114 deletion
+192
-114
src/dnode/src/dnodeWrite.c
src/dnode/src/dnodeWrite.c
+91
-55
src/inc/taosmsg.h
src/inc/taosmsg.h
+7
-1
src/mnode/inc/mgmtChildTable.h
src/mnode/inc/mgmtChildTable.h
+1
-1
src/mnode/inc/mgmtNormalTable.h
src/mnode/inc/mgmtNormalTable.h
+1
-1
src/mnode/inc/mgmtVgroup.h
src/mnode/inc/mgmtVgroup.h
+1
-1
src/mnode/src/mgmtChildTable.c
src/mnode/src/mgmtChildTable.c
+11
-19
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+1
-1
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+11
-18
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+10
-5
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+56
-10
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+2
-2
未找到文件。
src/dnode/src/dnodeWrite.c
浏览文件 @
58118cfa
...
...
@@ -93,17 +93,14 @@ void dnodeWrite(SRpcMsg *pMsg) {
char
*
pCont
=
(
char
*
)
pMsg
->
pCont
;
SRpcContext
*
pRpcContext
=
NULL
;
int32_t
numOfVnodes
=
0
;
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
)
{
// TODO parse head, get number of vnodes;
numOfVnodes
=
1
;
}
else
{
numOfVnodes
=
1
;
}
if
(
numOfVnodes
>
1
)
{
pRpcContext
=
calloc
(
sizeof
(
SRpcContext
),
1
);
pRpcContext
->
numOfVnodes
=
numOfVnodes
;
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
||
pMsg
->
msgType
==
TSDB_MSG_TYPE_MD_DROP_STABLE
)
{
SWriteMsgDesc
*
pDesc
=
pCont
;
pDesc
->
numOfVnodes
=
htonl
(
pDesc
->
numOfVnodes
);
pCont
+=
sizeof
(
SWriteMsgDesc
);
if
(
pDesc
->
numOfVnodes
>
1
)
{
pRpcContext
=
calloc
(
sizeof
(
SRpcContext
),
1
);
pRpcContext
->
numOfVnodes
=
pDesc
->
numOfVnodes
;
}
}
while
(
leftLen
>
0
)
{
...
...
@@ -291,26 +288,9 @@ static void dnodeProcessSubmitMsg(SWriteMsg *pMsg) {
static
void
dnodeProcessCreateTableMsg
(
SWriteMsg
*
pMsg
)
{
SMDCreateTableMsg
*
pTable
=
pMsg
->
rpcMsg
.
pCont
;
dTrace
(
"table:%s, start to create in dnode, vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
void
*
pVnode
=
dnodeGetVnode
(
pTable
->
vgId
);
if
(
pVnode
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_VGROUP_ID
;
dTrace
(
"table:%s, failed to create in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
return
;
}
void
*
pTsdb
=
dnodeGetVnodeTsdb
(
pVnode
);
if
(
pTsdb
==
NULL
)
{
dnodeReleaseVnode
(
pVnode
);
rpcRsp
.
code
=
TSDB_CODE_NOT_ACTIVE_VNODE
;
dTrace
(
"table:%s, failed to create in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
return
;
}
dTrace
(
"table:%s, start to create in dnode, vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
pTable
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pTable
->
numOfTags
=
htons
(
pTable
->
numOfTags
);
pTable
->
sid
=
htonl
(
pTable
->
sid
);
...
...
@@ -344,7 +324,6 @@ static void dnodeProcessCreateTableMsg(SWriteMsg *pMsg) {
}
tsdbTableSetSchema
(
&
tCfg
,
pDestTagSchema
,
false
);
// TODO: add data row
char
*
pTagData
=
pTable
->
data
+
totalCols
*
sizeof
(
SSchema
);
int
accumBytes
=
0
;
SDataRow
dataRow
=
tdNewDataRowFromSchema
(
pDestTagSchema
);
...
...
@@ -356,50 +335,107 @@ static void dnodeProcessCreateTableMsg(SWriteMsg *pMsg) {
tsdbTableSetTagValue
(
&
tCfg
,
dataRow
,
false
);
}
void
*
pTsdb
=
dnodeGetVnodeTsdb
(
pMsg
->
pVnode
);
rpcRsp
.
code
=
tsdbCreateTable
(
pTsdb
,
&
tCfg
);
dnodeReleaseVnode
(
pVnode
);
dnodeReleaseVnode
(
p
Msg
->
p
Vnode
);
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
dError
(
"table:%s, failed to create in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
else
{
dTrace
(
"table:%s, created in dnode"
,
pTable
->
tableId
);
rpcSendResponse
(
&
rpcRsp
);
}
dTrace
(
"table:%s, create table result:%s"
,
pTable
->
tableId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
static
void
dnodeProcessDropTableMsg
(
SWriteMsg
*
pMsg
)
{
SMDDropTableMsg
*
pTable
=
pMsg
->
rpcMsg
.
pCont
;
dPrint
(
"table:%s, sid:%d is dropped"
,
pTable
->
tableId
,
pTable
->
sid
);
// pTable->sid = htonl(pTable->sid);
// pTable->numOfVPeers = htonl(pTable->numOfVPeers);
// pTable->uid = htobe64(pTable->uid);
//
// for (int i = 0; i < pTable->numOfVPeers; ++i) {
// pTable->vpeerDesc[i].ip = htonl(pTable->vpeerDesc[i].ip);
// pTable->vpeerDesc[i].vnode = htonl(pTable->vpeerDesc[i].vnode);
// }
//
// int32_t code = dnodeDropTable(pTable);
//
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
dTrace
(
"table:%s, start to drop in dnode, vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
STableId
tableId
=
{
.
uid
=
htobe64
(
pTable
->
uid
),
.
tid
=
htonl
(
pTable
->
sid
)
};
void
*
pTsdb
=
dnodeGetVnodeTsdb
(
pMsg
->
pVnode
);
rpcRsp
.
code
=
tsdbDropTable
(
pTsdb
,
tableId
);
dnodeReleaseVnode
(
pMsg
->
pVnode
);
dTrace
(
"table:%s, drop table result:%s"
,
pTable
->
tableId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
static
void
dnodeProcessAlterTableMsg
(
SWriteMsg
*
pMsg
)
{
SMDCreateTableMsg
*
pTable
=
pMsg
->
rpcMsg
.
pCont
;
dPrint
(
"table:%s, sid:%d is alterd"
,
pTable
->
tableId
,
pTable
->
sid
);
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
dTrace
(
"table:%s, start to alter in dnode, vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
pTable
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pTable
->
numOfTags
=
htons
(
pTable
->
numOfTags
);
pTable
->
sid
=
htonl
(
pTable
->
sid
);
pTable
->
sversion
=
htonl
(
pTable
->
sversion
);
pTable
->
tagDataLen
=
htonl
(
pTable
->
tagDataLen
);
pTable
->
sqlDataLen
=
htonl
(
pTable
->
sqlDataLen
);
pTable
->
uid
=
htobe64
(
pTable
->
uid
);
pTable
->
superTableUid
=
htobe64
(
pTable
->
superTableUid
);
pTable
->
createdTime
=
htobe64
(
pTable
->
createdTime
);
SSchema
*
pSchema
=
(
SSchema
*
)
pTable
->
data
;
int
totalCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
for
(
int
i
=
0
;
i
<
totalCols
;
i
++
)
{
pSchema
[
i
].
colId
=
htons
(
pSchema
[
i
].
colId
);
pSchema
[
i
].
bytes
=
htons
(
pSchema
[
i
].
bytes
);
}
STableCfg
tCfg
;
tsdbInitTableCfg
(
&
tCfg
,
pTable
->
tableType
,
pTable
->
uid
,
pTable
->
sid
);
STSchema
*
pDestSchema
=
tdNewSchema
(
pTable
->
numOfColumns
);
for
(
int
i
=
0
;
i
<
pTable
->
numOfColumns
;
i
++
)
{
tdSchemaAppendCol
(
pDestSchema
,
pSchema
[
i
].
type
,
pSchema
[
i
].
colId
,
pSchema
[
i
].
bytes
);
}
tsdbTableSetSchema
(
&
tCfg
,
pDestSchema
,
false
);
if
(
pTable
->
numOfTags
!=
0
)
{
STSchema
*
pDestTagSchema
=
tdNewSchema
(
pTable
->
numOfTags
);
for
(
int
i
=
pTable
->
numOfColumns
;
i
<
totalCols
;
i
++
)
{
tdSchemaAppendCol
(
pDestTagSchema
,
pSchema
[
i
].
type
,
pSchema
[
i
].
colId
,
pSchema
[
i
].
bytes
);
}
tsdbTableSetSchema
(
&
tCfg
,
pDestTagSchema
,
false
);
char
*
pTagData
=
pTable
->
data
+
totalCols
*
sizeof
(
SSchema
);
int
accumBytes
=
0
;
SDataRow
dataRow
=
tdNewDataRowFromSchema
(
pDestTagSchema
);
for
(
int
i
=
0
;
i
<
pTable
->
numOfTags
;
i
++
)
{
tdAppendColVal
(
dataRow
,
pTagData
+
accumBytes
,
pDestTagSchema
->
columns
+
i
);
accumBytes
+=
pSchema
[
i
+
pTable
->
numOfColumns
].
bytes
;
}
tsdbTableSetTagValue
(
&
tCfg
,
dataRow
,
false
);
}
void
*
pTsdb
=
dnodeGetVnodeTsdb
(
pMsg
->
pVnode
);
rpcRsp
.
code
=
tsdbAlterTable
(
pTsdb
,
&
tCfg
);
dnodeReleaseVnode
(
pMsg
->
pVnode
);
dTrace
(
"table:%s, alter table result:%s"
,
pTable
->
tableId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
static
void
dnodeProcessDropStableMsg
(
SWriteMsg
*
pMsg
)
{
SMDDropSTableMsg
*
pTable
=
pMsg
->
rpcMsg
.
pCont
;
dPrint
(
"stable:%s, is dropped"
,
pTable
->
tableId
);
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
dTrace
(
"stable:%s, start to drop in dnode, vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
pTable
->
uid
=
htobe64
(
pTable
->
uid
);
// TODO: drop stable in vvnode
//void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode);
//rpcRsp.code = tsdbDropSTable(pTsdb, pTable->uid);
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
dnodeReleaseVnode
(
pMsg
->
pVnode
);
dTrace
(
"stable:%s, drop stable result:%s"
,
pTable
->
tableId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
src/inc/taosmsg.h
浏览文件 @
58118cfa
...
...
@@ -234,6 +234,10 @@ typedef struct {
uint32_t
ip
;
}
SVnodeDesc
;
typedef
struct
{
int32_t
numOfVnodes
;
}
SWriteMsgDesc
;
typedef
struct
{
int32_t
contLen
;
int32_t
vgId
;
...
...
@@ -341,8 +345,10 @@ typedef struct {
}
SMDDropTableMsg
;
typedef
struct
{
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
int32_t
contLen
;
int32_t
vgId
;
int64_t
uid
;
char
tableId
[
TSDB_TABLE_ID_LEN
+
1
];
}
SMDDropSTableMsg
;
typedef
struct
{
...
...
src/mnode/inc/mgmtChildTable.h
浏览文件 @
58118cfa
...
...
@@ -33,7 +33,7 @@ void * mgmtGetChildTable(char *tableId);
void
*
mgmtCreateChildTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
void
*
mgmtBuildCreateChildTableMsg
(
SCMCreateTableMsg
*
pCreate
,
SChildTableObj
*
pTable
);
int32_t
mgmtDropChildTable
(
S
DbObj
*
pDb
,
S
ChildTableObj
*
pTable
);
int32_t
mgmtDropChildTable
(
SChildTableObj
*
pTable
);
int32_t
mgmtModifyChildTableTagValueByName
(
SChildTableObj
*
pTable
,
char
*
tagName
,
char
*
nContent
);
int32_t
mgmtGetChildTableMeta
(
SDbObj
*
pDb
,
SChildTableObj
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
);
...
...
src/mnode/inc/mgmtNormalTable.h
浏览文件 @
58118cfa
...
...
@@ -31,7 +31,7 @@ void * mgmtGetNormalTable(char *tableId);
void
*
mgmtCreateNormalTable
(
SCMCreateTableMsg
*
pCreate
,
SVgObj
*
pVgroup
,
int32_t
sid
);
void
*
mgmtBuildCreateNormalTableMsg
(
SNormalTableObj
*
pTable
);
int32_t
mgmtDropNormalTable
(
S
DbObj
*
pDb
,
S
NormalTableObj
*
pTable
);
int32_t
mgmtDropNormalTable
(
SNormalTableObj
*
pTable
);
int32_t
mgmtAddNormalTableColumn
(
SNormalTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
);
int32_t
mgmtDropNormalTableColumnByName
(
SNormalTableObj
*
pTable
,
char
*
colName
);
...
...
src/mnode/inc/mgmtVgroup.h
浏览文件 @
58118cfa
...
...
@@ -30,7 +30,7 @@ SVgObj *mgmtGetVgroup(int32_t vgId);
SVgObj
*
mgmtGetVgroupByVnode
(
uint32_t
dnode
,
int32_t
vnode
);
void
mgmtCreateVgroup
(
SQueuedMsg
*
pMsg
);
int32_t
mgmtDropVgroup
(
S
DbObj
*
pDb
,
S
VgObj
*
pVgroup
);
int32_t
mgmtDropVgroup
(
SVgObj
*
pVgroup
);
void
mgmtUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mgmtSetVgroupIdPool
();
...
...
src/mnode/src/mgmtChildTable.c
浏览文件 @
58118cfa
...
...
@@ -355,45 +355,37 @@ void* mgmtCreateChildTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
return
pTable
;
}
int32_t
mgmtDropChildTable
(
S
DbObj
*
pDb
,
S
ChildTableObj
*
pTable
)
{
int32_t
mgmtDropChildTable
(
SChildTableObj
*
pTable
)
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to drop child table, vgroup not exist"
,
pTable
->
tableId
);
return
TSDB_CODE_OTHERS
;
}
SMDDropTableMsg
*
p
Remove
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
p
Remove
==
NULL
)
{
SMDDropTableMsg
*
p
Drop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
p
Drop
==
NULL
)
{
mError
(
"table:%s, failed to drop child table, no enough memory"
,
pTable
->
tableId
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
p
Remove
->
tableId
,
pTable
->
tableId
);
p
Remove
->
vgId
=
htonl
(
pTable
->
vgId
);
p
Remove
->
contLen
=
htonl
(
sizeof
(
SMDDropTableMsg
));
p
Remove
->
sid
=
htonl
(
pTable
->
sid
);
p
Remove
->
uid
=
htobe64
(
pTable
->
uid
);
strcpy
(
p
Drop
->
tableId
,
pTable
->
tableId
);
p
Drop
->
vgId
=
htonl
(
pTable
->
vgId
);
p
Drop
->
contLen
=
htonl
(
sizeof
(
SMDDropTableMsg
));
p
Drop
->
sid
=
htonl
(
pTable
->
sid
);
p
Drop
->
uid
=
htobe64
(
pTable
->
uid
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
mTrace
(
"table:%s, send drop table msg"
,
p
Remove
->
tableId
);
mTrace
(
"table:%s, send drop table msg"
,
p
Drop
->
tableId
);
SRpcMsg
rpcMsg
=
{
.
handle
=
0
,
.
pCont
=
p
Remove
,
.
pCont
=
p
Drop
,
.
contLen
=
sizeof
(
SMDDropTableMsg
),
.
code
=
0
,
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_TABLE
};
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
if
(
sdbDeleteRow
(
tsChildTableSdb
,
pTable
)
<
0
)
{
mError
(
"table:%s, update ctables sdb error"
,
pTable
->
tableId
);
return
TSDB_CODE_SDB_ERROR
;
}
if
(
pVgroup
->
numOfTables
<=
0
)
{
mgmtDropVgroup
(
pDb
,
pVgroup
);
}
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/mnode/src/mgmtDb.c
浏览文件 @
58118cfa
...
...
@@ -368,7 +368,7 @@ static bool mgmtCheckDropDbFinished(SDbObj *pDb) {
}
static
void
mgmtDropDbFromSdb
(
SDbObj
*
pDb
)
{
while
(
pDb
->
pHead
)
mgmtDropVgroup
(
pDb
,
pDb
->
pHead
);
while
(
pDb
->
pHead
)
mgmtDropVgroup
(
pDb
->
pHead
);
// SSuperTableObj *pMetric = pDb->pSTable;
// while (pMetric) {
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
58118cfa
...
...
@@ -389,43 +389,36 @@ void *mgmtCreateNormalTable(SCMCreateTableMsg *pCreate, SVgObj *pVgroup, int32_t
return
pTable
;
}
int32_t
mgmtDropNormalTable
(
S
DbObj
*
pDb
,
S
NormalTableObj
*
pTable
)
{
int32_t
mgmtDropNormalTable
(
SNormalTableObj
*
pTable
)
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to drop normal table, vgroup not exist"
,
pTable
->
tableId
);
return
TSDB_CODE_OTHERS
;
}
SMDDropTableMsg
*
p
Remove
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
p
Remove
==
NULL
)
{
SMDDropTableMsg
*
p
Drop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
p
Drop
==
NULL
)
{
mError
(
"table:%s, failed to drop normal table, no enough memory"
,
pTable
->
tableId
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
strcpy
(
pRemove
->
tableId
,
pTable
->
tableId
);
pRemove
->
sid
=
htonl
(
pTable
->
sid
);
pRemove
->
uid
=
htobe64
(
pTable
->
uid
);
strcpy
(
pDrop
->
tableId
,
pTable
->
tableId
);
pDrop
->
contLen
=
htonl
(
sizeof
(
SMDDropTableMsg
));
pDrop
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pDrop
->
sid
=
htonl
(
pTable
->
sid
);
pDrop
->
uid
=
htobe64
(
pTable
->
uid
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
mTrace
(
"table:%s, send drop table msg"
,
p
Remove
->
tableId
);
mTrace
(
"table:%s, send drop table msg"
,
p
Drop
->
tableId
);
SRpcMsg
rpcMsg
=
{
.
handle
=
0
,
.
pCont
=
p
Remove
,
.
pCont
=
p
Drop
,
.
contLen
=
sizeof
(
SMDDropTableMsg
),
.
code
=
0
,
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_TABLE
};
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
if
(
sdbDeleteRow
(
tsNormalTableSdb
,
pTable
)
<
0
)
{
mError
(
"table:%s, update ntables sdb error"
,
pTable
->
tableId
);
return
TSDB_CODE_SDB_ERROR
;
}
if
(
pVgroup
->
numOfTables
<=
0
)
{
mgmtDropVgroup
(
pDb
,
pVgroup
);
}
mgmtSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
58118cfa
...
...
@@ -250,11 +250,16 @@ int32_t mgmtCreateSuperTable(SCMCreateTableMsg *pCreate) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pSuperTable
)
{
//TODO drop all child tables
mgmtRemoveSuperTableFromDb
(
pDb
);
return
sdbDeleteRow
(
tsSuperTableSdb
,
pSuperTable
);
int32_t
mgmtDropSuperTable
(
SDbObj
*
pDb
,
SSuperTableObj
*
pStable
)
{
if
(
pStable
->
numOfTables
!=
0
)
{
mError
(
"stable:%s, numOfTables:%d not 0"
,
pStable
->
tableId
,
pStable
->
numOfTables
);
return
TSDB_CODE_OTHERS
;
}
else
{
//TODO: drop child tables
mError
(
"stable:%s, is dropped from sdb"
,
pStable
->
tableId
);
mgmtRemoveSuperTableFromDb
(
pDb
);
return
TSDB_CODE_OTHERS
;
}
}
void
*
mgmtGetSuperTable
(
char
*
tableId
)
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
58118cfa
...
...
@@ -51,6 +51,7 @@ static void mgmtProcessTableMetaMsg(SQueuedMsg *queueMsg);
static
void
mgmtProcessMultiTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessSuperTableMetaMsg
(
SQueuedMsg
*
queueMsg
);
static
void
mgmtProcessCreateTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mgmtGetShowTableMeta
(
STableMeta
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessGetTableMeta
(
STableInfo
*
pTable
,
void
*
thandle
);
...
...
@@ -82,7 +83,7 @@ int32_t mgmtInitTables() {
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_TABLE
,
mgmtGetShowTableMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mgmtRetrieveShowTables
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP
,
mgmtProcessCreateTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_TABLE_RSP
,
NULL
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_TABLE_RSP
,
mgmtProcessDropTableRsp
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP
,
NULL
);
mgmtAddDClientRspHandle
(
TSDB_MSG_TYPE_MD_DROP_STABLE_RSP
,
NULL
);
...
...
@@ -439,19 +440,19 @@ void mgmtProcessCreateTableMsg(SQueuedMsg *pMsg) {
return
;
}
pMDCreate
=
mgmtBuildCreateChildTableMsg
(
pCreate
,
pTable
);
if
(
pCreate
==
NULL
)
{
if
(
p
MD
Create
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
terrno
);
return
;
}
}
else
{
mTrace
(
"table:%s, is a normal table, vgroup:%d sid:%d ahandle:%p"
,
pCreate
->
tableId
,
pVgroup
->
vgId
,
sid
,
pMsg
);
cod
e
=
mgmtCreateNormalTable
(
pCreate
,
pVgroup
,
sid
);
pTabl
e
=
mgmtCreateNormalTable
(
pCreate
,
pVgroup
,
sid
);
if
(
pTable
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
terrno
);
return
;
}
pMDCreate
=
mgmtBuildCreateNormalTableMsg
(
pTable
);
if
(
pCreate
==
NULL
)
{
if
(
p
MD
Create
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
terrno
);
return
;
}
...
...
@@ -509,31 +510,36 @@ void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) {
}
if
(
mgmtCheckIsMonitorDB
(
pDb
->
name
,
tsMonitorDbName
))
{
mError
(
"table:%s, failed to
create
table, in monitor database"
,
pDrop
->
tableId
);
mError
(
"table:%s, failed to
drop
table, in monitor database"
,
pDrop
->
tableId
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_MONITOR_DB_FORBIDDEN
);
return
;
}
int32_t
code
;
switch
(
pTable
->
type
)
{
case
TSDB_SUPER_TABLE
:
mTrace
(
"table:%s, start to drop super table"
,
pDrop
->
tableId
);
mgmtDropSuperTable
(
pDb
,
(
SSuperTableObj
*
)
pTable
);
code
=
mgmtDropSuperTable
(
pDb
,
(
SSuperTableObj
*
)
pTable
);
break
;
case
TSDB_CHILD_TABLE
:
mTrace
(
"table:%s, start to drop child table"
,
pDrop
->
tableId
);
mgmtDropChildTable
(
pDb
,
(
SChildTableObj
*
)
pTable
);
code
=
mgmtDropChildTable
(
(
SChildTableObj
*
)
pTable
);
break
;
case
TSDB_NORMAL_TABLE
:
mTrace
(
"table:%s, start to drop normal table"
,
pDrop
->
tableId
);
mgmtDropNormalTable
(
pDb
,
(
SNormalTableObj
*
)
pTable
);
code
=
mgmtDropNormalTable
(
(
SNormalTableObj
*
)
pTable
);
break
;
case
TSDB_STREAM_TABLE
:
mTrace
(
"table:%s, start to drop stream table"
,
pDrop
->
tableId
);
mgmtDropNormalTable
(
pDb
,
(
SNormalTableObj
*
)
pTable
);
code
=
mgmtDropNormalTable
(
(
SNormalTableObj
*
)
pTable
);
break
;
default:
code
=
TSDB_CODE_INVALID_TABLE_TYPE
;
mError
(
"table:%s, invalid table type:%d"
,
pDrop
->
tableId
,
pTable
->
type
);
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_TABLE
);
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
code
);
}
}
...
...
@@ -778,3 +784,43 @@ static void mgmtProcessCreateTableRsp(SRpcMsg *rpcMsg) {
free
(
queueMsg
);
}
static
void
mgmtProcessDropTableRsp
(
SRpcMsg
*
rpcMsg
)
{
if
(
rpcMsg
->
handle
==
NULL
)
return
;
STableInfo
*
pTable
=
rpcMsg
->
handle
;
mTrace
(
"table:%s, drop table rsp received, thandle:%p result:%s"
,
pTable
->
tableId
,
rpcMsg
->
handle
,
tstrerror
(
rpcMsg
->
code
));
if
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"table:%s, failed to drop in dnode, reason:%s"
,
pTable
->
tableId
,
tstrerror
(
rpcMsg
->
code
));
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
rpcMsg
->
code
);
return
;
}
else
{
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to get vgroup"
,
pTable
->
tableId
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_INVALID_VGROUP_ID
);
return
;
}
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
sdbDeleteRow
(
tsChildTableSdb
,
pTable
)
<
0
)
{
mError
(
"table:%s, update ctables sdb error"
,
pTable
->
tableId
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_SDB_ERROR
);
return
;
}
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
){
if
(
sdbDeleteRow
(
tsNormalTableSdb
,
pTable
)
<
0
)
{
mError
(
"table:%s, update ntables sdb error"
,
pTable
->
tableId
);
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_SDB_ERROR
);
return
;
}
}
if
(
pVgroup
->
numOfTables
<=
0
)
{
mgmtDropVgroup
(
pVgroup
);
}
}
mgmtSendSimpleResp
(
rpcMsg
->
handle
,
TSDB_CODE_SUCCESS
);
}
src/mnode/src/mgmtVgroup.c
浏览文件 @
58118cfa
...
...
@@ -185,7 +185,7 @@ void mgmtCreateVgroup(SQueuedMsg *pMsg) {
mgmtSendCreateVgroupMsg
(
pVgroup
,
pMsg
);
}
int32_t
mgmtDropVgroup
(
S
DbObj
*
pDb
,
S
VgObj
*
pVgroup
)
{
int32_t
mgmtDropVgroup
(
SVgObj
*
pVgroup
)
{
STableInfo
*
pTable
;
if
(
pVgroup
->
numOfTables
>
0
)
{
...
...
@@ -197,7 +197,7 @@ int32_t mgmtDropVgroup(SDbObj *pDb, SVgObj *pVgroup) {
// }
}
mTrace
(
"vgroup:%d,
db:%s replica:%d is deleted"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mTrace
(
"vgroup:%d,
replica:%d is deleted"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
);
//mgmtSendDropVgroupMsg(pVgroup, NULL);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录