Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2d439d29
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
2d439d29
编写于
1月 28, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle drop stb req
上级
ba13d6da
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
59 deletion
+87
-59
include/common/tmsg.h
include/common/tmsg.h
+16
-8
source/common/src/tmsg.c
source/common/src/tmsg.c
+15
-0
source/dnode/mgmt/impl/test/vnode/vnode.cpp
source/dnode/mgmt/impl/test/vnode/vnode.cpp
+22
-23
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+34
-28
未找到文件。
include/common/tmsg.h
浏览文件 @
2d439d29
...
...
@@ -140,6 +140,11 @@ typedef enum _mgmt_table {
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
#define TSDB_COL_IS_UD_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_UDC)
#define TSDB_COL_REQ_NULL(f) (((f)&TSDB_COL_NULL) != 0)
#define TD_SUPER_TABLE TSDB_SUPER_TABLE
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
typedef
struct
{
int32_t
vgId
;
char
*
dbName
;
...
...
@@ -1139,10 +1144,7 @@ typedef struct SVCreateTbReq {
char
*
name
;
uint32_t
ttl
;
uint32_t
keep
;
#define TD_SUPER_TABLE TSDB_SUPER_TABLE
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
uint8_t
type
;
uint8_t
type
;
union
{
struct
{
tb_uid_t
suid
;
...
...
@@ -1187,15 +1189,21 @@ typedef struct {
}
SVAlterTbRsp
;
typedef
struct
{
SMsgHead
head
;
char
name
[
TSDB_TABLE_FNAME_LEN
];
int64_t
suid
;
uint64_t
ver
;
char
*
name
;
uint8_t
type
;
tb_uid_t
suid
;
}
SVDropTbReq
;
typedef
struct
{
SMsgHead
head
;
uint64_t
ver
;
}
SVDropTbRsp
;
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
);
void
*
tDeserializeSVDropTbReq
(
void
*
buf
,
SVDropTbReq
*
pReq
);
int32_t
tSerializeSVDropTbRsp
(
void
**
buf
,
SVDropTbRsp
*
pRsp
);
void
*
tDeserializeSVDropTbRsp
(
void
*
buf
,
SVDropTbRsp
*
pRsp
);
typedef
struct
{
SMsgHead
head
;
int64_t
uid
;
...
...
source/common/src/tmsg.c
浏览文件 @
2d439d29
...
...
@@ -310,3 +310,18 @@ void *tSVCreateTbBatchReqDeserialize(void *buf, SVCreateTbBatchReq *pReq) {
return
buf
;
}
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedU8
(
buf
,
pReq
->
type
);
return
tlen
;
}
void
*
tDeserializeSVDropTbReq
(
void
*
buf
,
SVDropTbReq
*
pReq
)
{
buf
=
taosDecodeFixedU64
(
buf
,
&
pReq
->
ver
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
name
);
buf
=
taosDecodeFixedU8
(
buf
,
&
pReq
->
type
);
return
buf
;
}
source/dnode/mgmt/impl/test/vnode/vnode.cpp
浏览文件 @
2d439d29
...
...
@@ -199,19 +199,16 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
req
.
stbCfg
.
nTagCols
=
3
;
req
.
stbCfg
.
pTagSchema
=
&
schemas
[
2
];
int32_t
bsize
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
);
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
bsize
);
SMsgHead
*
pMsgHead
=
(
SMsgHead
*
)
buf
;
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
(
SMsgHead
*
)
rpcMallocCont
(
contLen
);
p
MsgHead
->
contLen
=
htonl
(
sizeof
(
SMsgHead
)
+
bsize
);
p
Msg
Head
->
vgId
=
htonl
(
2
);
p
Head
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
2
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
bsize
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_CREATE_STB
,
buf
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_CREATE_STB
,
(
void
*
)
pHead
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
...
@@ -236,23 +233,25 @@ TEST_F(DndTestVnode, 04_ALTER_Stb) {
TEST_F
(
DndTestVnode
,
05
_DROP_Stb
)
{
{
int32_t
contLen
=
sizeof
(
SVDropTbReq
);
SVDropTbReq
*
pReq
=
(
SVDropTbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
"stb1"
);
pReq
->
suid
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
SVDropTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
suid
=
9599
;
req
.
type
=
TD_SUPER_TABLE
;
SMsgHead
*
pMsgHead
=
(
SMsgHead
*
)
&
pReq
->
head
;
pMsgHead
->
contLen
=
htonl
(
contLen
);
pMsgHead
->
vgId
=
htonl
(
2
);
int32_t
contLen
=
tSerializeSVDropTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
(
SMsgHead
*
)
rpcMallocCont
(
contLen
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_DROP_STB
,
pReq
,
contLen
);
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
2
);
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVDropTbReq
(
&
pBuf
,
&
req
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_DROP_STB
,
(
void
*
)
pHead
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
// else {
// ASSERT_EQ(pRsp->code, TSDB_CODE_TDB_INVALID_TABLE_ID);
//}
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
2d439d29
...
...
@@ -231,15 +231,11 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
}
static
void
*
mndBuildCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
SVCreateTbReq
req
=
{
0
};
void
*
buf
=
NULL
;
int32_t
bsize
=
0
;
SMsgHead
*
pMsgHead
=
NULL
;
req
.
ver
=
0
;
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
keep
=
0
;
...
...
@@ -250,40 +246,48 @@ static void *mndBuildCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb
req
.
stbCfg
.
nTagCols
=
pStb
->
numOfTags
;
req
.
stbCfg
.
pTagSchema
=
pStb
->
pSchema
+
pStb
->
numOfColumns
;
bsize
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
);
buf
=
malloc
(
sizeof
(
SMsgHead
)
+
bsize
);
if
(
buf
==
NULL
)
{
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
malloc
(
contLen
);
if
(
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pMsgHead
=
(
SMsgHead
*
)
buf
;
pMsgHead
->
contLen
=
htonl
(
sizeof
(
SMsgHead
)
+
bsize
);
pMsgHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
sizeof
(
SMsgHead
)
+
bsize
;
return
buf
;
*
pContLen
=
contLen
;
return
pHead
;
}
static
SVDropTbReq
*
mndBuildDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
)
{
int32_t
contLen
=
sizeof
(
SVDropTbReq
);
static
void
*
mndBuildDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
SVDropTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
type
=
TD_SUPER_TABLE
;
req
.
suid
=
pStb
->
uid
;
SVDropTbReq
*
pDrop
=
calloc
(
1
,
contLen
);
if
(
pDrop
==
NULL
)
{
int32_t
contLen
=
tSerializeSVDropTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
malloc
(
contLen
);
if
(
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pDrop
->
head
.
contLen
=
htonl
(
contLen
);
pDrop
->
head
.
vgId
=
htonl
(
pVgroup
->
vgId
);
memcpy
(
pDrop
->
name
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
pDrop
->
suid
=
htobe64
(
pStb
->
uid
);
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVDropTbReq
(
&
pBuf
,
&
req
);
return
pDrop
;
*
pContLen
=
contLen
;
return
pHead
;
}
static
int32_t
mndCheckCreateStbReq
(
SMCreateStbReq
*
pCreate
)
{
...
...
@@ -403,7 +407,8 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
SVDropTbReq
*
pReq
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
);
if
(
pReq
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
...
...
@@ -414,7 +419,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVDropTbReq
)
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_DROP_STB
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
...
...
@@ -625,7 +630,8 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
void
*
pReq
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
);
if
(
pReq
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录