Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c2a9c119
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看板
提交
c2a9c119
编写于
5月 11, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-271] fix bug while drop stable
上级
459c267a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
76 deletion
+75
-76
src/mnode/inc/mgmtDef.h
src/mnode/inc/mgmtDef.h
+1
-2
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+74
-74
未找到文件。
src/mnode/inc/mgmtDef.h
浏览文件 @
c2a9c119
...
...
@@ -85,8 +85,7 @@ typedef struct SSuperTableObj {
int32_t
numOfTables
;
int16_t
nextColId
;
SSchema
*
schema
;
int32_t
vgLen
;
int32_t
*
vgList
;
void
*
vgHash
;
}
SSuperTableObj
;
typedef
struct
{
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
c2a9c119
...
...
@@ -24,6 +24,7 @@
#include "tname.h"
#include "tidpool.h"
#include "tglobal.h"
#include "hash.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtInt.h"
...
...
@@ -363,39 +364,35 @@ static void mgmtCleanUpChildTables() {
}
static
void
mgmtAddTableIntoStable
(
SSuperTableObj
*
pStable
,
SChildTableObj
*
pCtable
)
{
if
(
pStable
->
vgLen
==
0
)
{
pStable
->
vgLen
=
8
;
pStable
->
vgList
=
calloc
(
pStable
->
vgLen
,
sizeof
(
int32_t
));
}
bool
find
=
false
;
int32_t
pos
=
0
;
for
(
pos
=
0
;
pos
<
pStable
->
vgLen
;
++
pos
)
{
if
(
pStable
->
vgList
[
pos
]
==
0
)
break
;
if
(
pStable
->
vgList
[
pos
]
==
pCtable
->
vgId
)
{
find
=
true
;
break
;
}
}
pStable
->
numOfTables
++
;
if
(
!
find
)
{
if
(
pos
>=
pStable
->
vgLen
)
{
pStable
->
vgLen
*=
2
;
pStable
->
vgList
=
realloc
(
pStable
->
vgList
,
pStable
->
vgLen
*
sizeof
(
int32_t
));
}
pStable
->
vgList
[
pos
]
=
pCtable
->
vgId
;
if
(
pStable
->
vgHash
==
NULL
)
{
pStable
->
vgHash
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
);
}
pStable
->
numOfTables
++
;
if
(
pStable
->
vgHash
!=
NULL
)
{
taosHashPut
(
pStable
->
vgHash
,
(
char
*
)
&
pCtable
->
vgId
,
sizeof
(
pCtable
->
vgId
),
&
pCtable
->
vgId
,
sizeof
(
pCtable
->
vgId
));
}
}
static
void
mgmtRemoveTableFromStable
(
SSuperTableObj
*
pStable
,
SChildTableObj
*
pCtable
)
{
pStable
->
numOfTables
--
;
if
(
pStable
->
vgHash
==
NULL
)
return
;
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
pCtable
->
vgId
);
if
(
pVgroup
!=
NULL
)
{
taosHashRemove
(
pStable
->
vgHash
,
(
char
*
)
&
pCtable
->
vgId
,
sizeof
(
pCtable
->
vgId
));
}
mgmtDecVgroupRef
(
pVgroup
);
}
static
void
mgmtDestroySuperTable
(
SSuperTableObj
*
pStable
)
{
if
(
pStable
->
vgHash
!=
NULL
)
{
taosHashCleanup
(
pStable
->
vgHash
);
pStable
->
vgHash
=
NULL
;
}
tfree
(
pStable
->
schema
);
tfree
(
pStable
->
vgList
)
tfree
(
pStable
);
}
...
...
@@ -434,7 +431,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) {
void
*
oldSchema
=
pTable
->
schema
;
memcpy
(
pTable
,
pNew
,
pOper
->
rowSize
);
pTable
->
schema
=
pNew
->
schema
;
free
(
pNew
->
vg
List
);
free
(
pNew
->
vg
Hash
);
free
(
pNew
);
free
(
oldSchema
);
}
...
...
@@ -797,26 +794,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
static
void
mgmtProcessDropSuperTableMsg
(
SQueuedMsg
*
pMsg
)
{
SSuperTableObj
*
pStable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
numOfTables
!=
0
)
{
mgmtDropAllChildTablesInStable
(
pStable
);
for
(
int32_t
vg
=
0
;
vg
<
pStable
->
vgLen
;
++
vg
)
{
int32_t
vgId
=
pStable
->
vgList
[
vg
];
if
(
vgId
==
0
)
break
;
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
vgId
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pStable
->
vgHash
);
while
(
taosHashIterNext
(
pIter
))
{
int32_t
*
pVgId
=
taosHashIterGet
(
pIter
);
SVgObj
*
pVgroup
=
mgmtGetVgroup
(
*
pVgId
);
if
(
pVgroup
==
NULL
)
break
;
SMDDropSTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropSTableMsg
));
pDrop
->
contLen
=
htonl
(
sizeof
(
SMDDropSTableMsg
));
pDrop
->
vgId
=
htonl
(
vgId
);
pDrop
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pDrop
->
uid
=
htobe64
(
pStable
->
uid
);
mgmtExtractTableName
(
pStable
->
info
.
tableId
,
pDrop
->
tableId
);
mPrint
(
"stable:%s, send drop stable msg to vgId:%d"
,
pStable
->
info
.
tableId
,
vgId
);
mPrint
(
"stable:%s, send drop stable msg to vgId:%d"
,
pStable
->
info
.
tableId
,
pVgroup
->
vgId
);
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pDrop
,
.
contLen
=
sizeof
(
SMDDropSTableMsg
),
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_STABLE
};
dnodeSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
mgmtDecVgroupRef
(
pVgroup
);
}
mgmtDropAllChildTablesInStable
(
pStable
);
}
SSdbOper
oper
=
{
...
...
@@ -1243,59 +1240,62 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) {
static
void
mgmtProcessSuperTableVgroupMsg
(
SQueuedMsg
*
pMsg
)
{
SCMSTableVgroupMsg
*
pInfo
=
pMsg
->
pCont
;
int32_t
numOfTable
=
htonl
(
pInfo
->
numOfTables
);
char
*
name
=
(
char
*
)
pInfo
+
sizeof
(
struct
SCMSTableVgroupMsg
);
SCMSTableVgroupRspMsg
*
pRsp
=
NULL
;
// todo set the initial size to be 10, fix me
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
)
+
(
sizeof
(
SCMVgroupInfo
)
*
10
+
sizeof
(
SVgroupsInfo
))
*
numOfTable
;
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
;
SSuperTableObj
*
pTable
=
mgmtGetSuperTable
(
stableName
);
if
(
pTable
!=
NULL
)
{
stableName
=
(
char
*
)
pTable
;
//hack way
}
if
(
pTable
->
vgHash
!=
NULL
)
{
contLen
+=
(
taosHashGetSize
(
pTable
->
vgHash
)
*
sizeof
(
SCMVgroupInfo
)
+
sizeof
(
SVgroupsInfo
));
}
mgmtDecTableRef
(
pTable
);
}
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
return
;
}
pRsp
->
numOfTables
=
htonl
(
numOfTable
);
char
*
msg
=
(
char
*
)
pRsp
+
sizeof
(
SCMSTableVgroupRspMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
SSuperTableObj
*
pTable
=
mgmtGetSuperTable
(
name
);
pMsg
->
pTable
=
(
STableObj
*
)
pTable
;
if
(
pMsg
->
pTable
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_TABLE
);
return
;
}
SVgroupsInfo
*
pVgroup
=
(
SVgroupsInfo
*
)
msg
;
int32_t
vg
=
0
;
for
(;
vg
<
pTable
->
vgLen
;
++
vg
)
{
int32_t
vgId
=
pTable
->
vgList
[
vg
];
if
(
vgId
==
0
)
break
;
SVgObj
*
vgItem
=
mgmtGetVgroup
(
vgId
);
if
(
vgItem
==
NULL
)
break
;
pVgroup
->
vgroups
[
vg
].
vgId
=
htonl
(
vgId
);
for
(
int32_t
vn
=
0
;
vn
<
vgItem
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
vgItem
->
vnodeGid
[
vn
].
pDnode
;
char
*
msg
=
(
char
*
)
pRsp
+
sizeof
(
SCMSTableVgroupRspMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)((
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
);
SVgroupsInfo
*
pVgroup
=
(
SVgroupsInfo
*
)
msg
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
vgHash
);
int32_t
vgSize
=
0
;
while
(
taosHashIterNext
(
pIter
))
{
int32_t
*
pVgId
=
taosHashIterGet
(
pIter
);
SVgObj
*
pVgItem
=
mgmtGetVgroup
(
*
pVgId
);
if
(
pVgItem
==
NULL
)
continue
;
pVgroup
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgItem
->
vgId
);
for
(
int32_t
vn
=
0
;
vn
<
pVgItem
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
pVgItem
->
vnodeGid
[
vn
].
pDnode
;
if
(
pDnode
==
NULL
)
break
;
strncpy
(
pVgroup
->
vgroups
[
vg
].
ipAddr
[
vn
].
fqdn
,
pDnode
->
dnodeFqdn
,
tListLen
(
pDnode
->
dnodeFqdn
));
pVgroup
->
vgroups
[
vg
].
ipAddr
[
vn
].
port
=
htons
(
tsDnodeShellPort
);
pVgroup
->
vgroups
[
vg
].
numOfIps
++
;
strncpy
(
pVgroup
->
vgroups
[
vg
Size
].
ipAddr
[
vn
].
fqdn
,
pDnode
->
dnodeFqdn
,
tListLen
(
pDnode
->
dnodeFqdn
));
pVgroup
->
vgroups
[
vg
Size
].
ipAddr
[
vn
].
port
=
htons
(
tsDnodeShellPort
);
pVgroup
->
vgroups
[
vg
Size
].
numOfIps
++
;
}
mgmtDecVgroupRef
(
vgItem
);
vgSize
++
;
mgmtDecVgroupRef
(
pVgItem
);
}
pVgroup
->
numOfVgroups
=
htonl
(
vg
);
pVgroup
->
numOfVgroups
=
htonl
(
vg
Size
);
// one table is done, try the next table
msg
+=
sizeof
(
SVgroupsInfo
)
+
vg
*
sizeof
(
SCMVgroupInfo
);
msg
+=
sizeof
(
SVgroupsInfo
)
+
vg
Size
*
sizeof
(
SCMVgroupInfo
);
}
SRpcMsg
rpcRsp
=
{
0
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录