Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
748d161a
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
748d161a
编写于
1月 28, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of github.com:taosdata/TDengine into 3.0
上级
17792e02
236393e1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
189 addition
and
82 deletion
+189
-82
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
+23
-18
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+94
-55
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+5
-0
source/util/test/CMakeLists.txt
source/util/test/CMakeLists.txt
+7
-1
source/util/test/queueTest.cpp
source/util/test/queueTest.cpp
+29
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
748d161a
...
@@ -147,6 +147,11 @@ typedef enum _mgmt_table {
...
@@ -147,6 +147,11 @@ typedef enum _mgmt_table {
#define TSDB_COL_IS_NORMAL_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_NORMAL)
#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_IS_UD_COL(f) ((f & (~(TSDB_COL_NULL))) == TSDB_COL_UDC)
#define TSDB_COL_REQ_NULL(f) (((f)&TSDB_COL_NULL) != 0)
#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
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
char
*
dbName
;
char
*
dbName
;
...
@@ -1154,10 +1159,7 @@ typedef struct SVCreateTbReq {
...
@@ -1154,10 +1159,7 @@ typedef struct SVCreateTbReq {
char
*
name
;
char
*
name
;
uint32_t
ttl
;
uint32_t
ttl
;
uint32_t
keep
;
uint32_t
keep
;
#define TD_SUPER_TABLE TSDB_SUPER_TABLE
uint8_t
type
;
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
uint8_t
type
;
union
{
union
{
struct
{
struct
{
tb_uid_t
suid
;
tb_uid_t
suid
;
...
@@ -1202,15 +1204,21 @@ typedef struct {
...
@@ -1202,15 +1204,21 @@ typedef struct {
}
SVAlterTbRsp
;
}
SVAlterTbRsp
;
typedef
struct
{
typedef
struct
{
SMsgHead
head
;
uint64_t
ver
;
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
*
name
;
int64_t
suid
;
uint8_t
type
;
tb_uid_t
suid
;
}
SVDropTbReq
;
}
SVDropTbReq
;
typedef
struct
{
typedef
struct
{
SMsgHead
head
;
uint64_t
ver
;
}
SVDropTbRsp
;
}
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
{
typedef
struct
{
SMsgHead
head
;
SMsgHead
head
;
int64_t
uid
;
int64_t
uid
;
...
...
source/common/src/tmsg.c
浏览文件 @
748d161a
...
@@ -320,3 +320,18 @@ void *tSVCreateTbBatchReqDeserialize(void *buf, SVCreateTbBatchReq *pReq) {
...
@@ -320,3 +320,18 @@ void *tSVCreateTbBatchReqDeserialize(void *buf, SVCreateTbBatchReq *pReq) {
return
buf
;
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
浏览文件 @
748d161a
...
@@ -199,19 +199,16 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
...
@@ -199,19 +199,16 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
req
.
stbCfg
.
nTagCols
=
3
;
req
.
stbCfg
.
nTagCols
=
3
;
req
.
stbCfg
.
pTagSchema
=
&
schemas
[
2
];
req
.
stbCfg
.
pTagSchema
=
&
schemas
[
2
];
int32_t
bsize
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
);
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
bsize
);
SMsgHead
*
pHead
=
(
SMsgHead
*
)
rpcMallocCont
(
contLen
);
SMsgHead
*
pMsgHead
=
(
SMsgHead
*
)
buf
;
p
MsgHead
->
contLen
=
htonl
(
sizeof
(
SMsgHead
)
+
bsize
);
p
Head
->
contLen
=
htonl
(
contLen
);
p
Msg
Head
->
vgId
=
htonl
(
2
);
pHead
->
vgId
=
htonl
(
2
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
bsize
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_CREATE_STB
,
(
void
*
)
pHead
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_CREATE_STB
,
buf
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -235,20 +232,28 @@ TEST_F(DndTestVnode, 04_ALTER_Stb) {
...
@@ -235,20 +232,28 @@ TEST_F(DndTestVnode, 04_ALTER_Stb) {
}
}
TEST_F
(
DndTestVnode
,
05
_DROP_Stb
)
{
TEST_F
(
DndTestVnode
,
05
_DROP_Stb
)
{
#if 0
{
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
SRpcMsg* pRsp = test.SendReq(TDMT_VND_DROP_STB, pReq, contLen);
SVDropTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
suid
=
9599
;
req
.
type
=
TD_SUPER_TABLE
;
int32_t
contLen
=
tSerializeSVDropTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
(
SMsgHead
*
)
rpcMallocCont
(
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
);
ASSERT_NE
(
pRsp
,
nullptr
);
if (i == 0) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ(pRsp->code, 0);
test.Restart();
} else {
ASSERT_EQ(pRsp->code, TSDB_CODE_TDB_INVALID_TABLE_ID);
}
}
}
}
}
#endif
}
}
TEST_F
(
DndTestVnode
,
06
_DROP_Vnode
)
{
TEST_F
(
DndTestVnode
,
06
_DROP_Vnode
)
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
748d161a
...
@@ -181,23 +181,26 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
...
@@ -181,23 +181,26 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
,
SStbObj
*
pNew
)
{
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
,
SStbObj
*
pNew
)
{
mTrace
(
"stb:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
mTrace
(
"stb:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
atomic_exchange_32
(
&
pOld
->
updateTime
,
pNew
->
updateTime
);
atomic_exchange_32
(
&
pOld
->
version
,
pNew
->
version
);
taosWLockLatch
(
&
pOld
->
lock
);
taosWLockLatch
(
&
pOld
->
lock
);
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
int32_t
totalCols
=
pNew
->
numOfTags
+
pNew
->
numOfColumns
;
int32_t
totalCols
=
pNew
->
numOfTags
+
pNew
->
numOfColumns
;
int32_t
totalSize
=
totalCols
*
sizeof
(
SSchema
);
int32_t
totalSize
=
totalCols
*
sizeof
(
SSchema
);
if
(
pOld
->
numOfTags
+
pOld
->
numOfColumns
<
totalCols
)
{
if
(
pOld
->
numOfTags
+
pOld
->
numOfColumns
<
totalCols
)
{
void
*
pSchema
=
malloc
(
totalSize
);
void
*
pSchema
=
malloc
(
totalSize
);
if
(
pSchema
!=
NULL
)
{
if
(
pSchema
!=
NULL
)
{
free
(
pOld
->
pSchema
);
free
(
pOld
->
pSchema
);
pOld
->
pSchema
=
pSchema
;
pOld
->
pSchema
=
pSchema
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
}
}
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
version
=
pNew
->
version
;
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
memcpy
(
pOld
->
pSchema
,
pNew
->
pSchema
,
totalSize
);
memcpy
(
pOld
->
pSchema
,
pNew
->
pSchema
,
totalSize
);
taosWUnLockLatch
(
&
pOld
->
lock
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
return
0
;
...
@@ -228,15 +231,11 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
...
@@ -228,15 +231,11 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
}
}
static
void
*
mndBuildCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
SVCreateTbReq
req
;
void
*
buf
;
int32_t
bsize
;
SMsgHead
*
pMsgHead
;
req
.
ver
=
0
;
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
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
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -247,40 +246,48 @@ static void *mndBuildCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb
...
@@ -247,40 +246,48 @@ static void *mndBuildCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb
req
.
stbCfg
.
nTagCols
=
pStb
->
numOfTags
;
req
.
stbCfg
.
nTagCols
=
pStb
->
numOfTags
;
req
.
stbCfg
.
pTagSchema
=
pStb
->
pSchema
+
pStb
->
numOfColumns
;
req
.
stbCfg
.
pTagSchema
=
pStb
->
pSchema
+
pStb
->
numOfColumns
;
bsize
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
);
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
buf
=
malloc
(
sizeof
(
SMsgHead
)
+
bsize
);
SMsgHead
*
pHead
=
malloc
(
contLen
);
if
(
buf
==
NULL
)
{
if
(
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
pMsgHead
=
(
SMsgHead
*
)
buf
;
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pMsgHead
->
contLen
=
htonl
(
sizeof
(
SMsgHead
)
+
bsize
);
pMsgHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
sizeof
(
SMsgHead
)
+
bsize
;
*
pContLen
=
contLen
;
return
buf
;
return
pHead
;
}
}
static
SVDropTbReq
*
mndBuildDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
)
{
static
void
*
mndBuildDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SVDropTbReq
);
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
);
int32_t
contLen
=
tSerializeSVDropTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
if
(
pDrop
==
NULL
)
{
SMsgHead
*
pHead
=
malloc
(
contLen
);
if
(
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
pDrop
->
head
.
contLen
=
htonl
(
contLen
);
pHead
->
contLen
=
htonl
(
contLen
);
pDrop
->
head
.
vgId
=
htonl
(
pVgroup
->
vgId
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
memcpy
(
pDrop
->
name
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
pDrop
->
suid
=
htobe64
(
pStb
->
uid
);
return
pDrop
;
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVDropTbReq
(
&
pBuf
,
&
req
);
*
pContLen
=
contLen
;
return
pHead
;
}
}
static
int32_t
mndCheckCreateStbReq
(
SMCreateStbReq
*
pCreate
)
{
static
int32_t
mndCheckCreateStbReq
(
SMCreateStbReq
*
pCreate
)
{
...
@@ -358,7 +365,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -358,7 +365,7 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
contLen
;
int32_t
contLen
;
while
(
1
)
{
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
...
@@ -400,7 +407,8 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -400,7 +407,8 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
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
)
{
if
(
pReq
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
...
@@ -411,7 +419,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -411,7 +419,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVDropTbReq
)
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_DROP_STB
;
action
.
msgType
=
TDMT_VND_DROP_STB
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
free
(
pReq
);
...
@@ -498,9 +506,9 @@ static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq) {
...
@@ -498,9 +506,9 @@ static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq) {
}
}
// topic should have different name with stb
// topic should have different name with stb
SStbObj
*
pTopic
=
mndAcquireStb
(
pMnode
,
pCreate
->
name
);
SStbObj
*
pTopic
Stb
=
mndAcquireStb
(
pMnode
,
pCreate
->
name
);
if
(
pTopic
!=
NULL
)
{
if
(
pTopic
Stb
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pTopic
);
mndReleaseStb
(
pMnode
,
pTopicStb
);
terrno
=
TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC
;
terrno
=
TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC
;
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -517,7 +525,6 @@ static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq) {
...
@@ -517,7 +525,6 @@ static int32_t mndProcessMCreateStbReq(SMnodeMsg *pReq) {
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
code
;
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -603,15 +610,6 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS
...
@@ -603,15 +610,6 @@ static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pS
return
0
;
return
0
;
}
}
static
int32_t
mndSetDropStbUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pUndoRaw
=
mndStbActionEncode
(
pStb
);
if
(
pUndoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
mndSetDropStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
static
int32_t
mndSetDropStbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
SSdbRaw
*
pCommitRaw
=
mndStbActionEncode
(
pStb
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
pCommitRaw
==
NULL
)
return
-
1
;
...
@@ -621,22 +619,54 @@ static int32_t mndSetDropStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *
...
@@ -621,22 +619,54 @@ static int32_t mndSetDropStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStbObj *
return
0
;
return
0
;
}
}
static
int32_t
mndSetDropStbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
return
0
;
}
static
int32_t
mndSetDropStbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
contLen
;
static
int32_t
mndSetDropStbUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
return
0
;
}
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SStbObj
*
pStb
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
);
if
(
pReq
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_DROP_STB
;
action
.
acceptableCode
=
TSDB_CODE_VND_TB_NOT_EXIST
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
}
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_STB_OVER
;
if
(
pTrans
==
NULL
)
goto
DROP_STB_OVER
;
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbUndoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbRedoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbUndoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_STB_OVER
;
code
=
0
;
code
=
0
;
...
@@ -664,7 +694,16 @@ static int32_t mndProcessMDropStbReq(SMnodeMsg *pReq) {
...
@@ -664,7 +694,16 @@ static int32_t mndProcessMDropStbReq(SMnodeMsg *pReq) {
}
}
}
}
int32_t
code
=
mndDropStb
(
pMnode
,
pReq
,
pStb
);
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
pDrop
->
name
);
if
(
pDb
==
NULL
)
{
mndReleaseStb
(
pMnode
,
pStb
);
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
mError
(
"stb:%s, failed to drop since %s"
,
pDrop
->
name
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndDropStb
(
pMnode
,
pReq
,
pDb
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -856,7 +895,7 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3
...
@@ -856,7 +895,7 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3
if
(
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
strncmp
(
pStb
->
db
,
pDb
->
name
,
tListLen
(
pStb
->
db
))
==
0
)
{
if
(
strncmp
(
pStb
->
db
,
pDb
->
name
,
tListLen
(
pStb
->
db
))
==
0
)
{
mError
(
"Inconsistent table data, name:%s, db:%s, dbUid:%"
PRIu64
,
pStb
->
name
,
pDb
->
name
,
pDb
->
uid
);
mError
(
"Inconsistent table data, name:%s, db:%s, dbUid:%"
PRIu64
,
pStb
->
name
,
pDb
->
name
,
pDb
->
uid
);
}
}
sdbRelease
(
pSdb
,
pStb
);
sdbRelease
(
pSdb
,
pStb
);
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
748d161a
...
@@ -103,7 +103,12 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -103,7 +103,12 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
break
;
break
;
case
TDMT_VND_ALTER_STB
:
vTrace
(
"vgId:%d, process drop stb req"
,
pVnode
->
vgId
);
break
;
case
TDMT_VND_DROP_STB
:
case
TDMT_VND_DROP_STB
:
vTrace
(
"vgId:%d, process drop stb req"
,
pVnode
->
vgId
);
break
;
case
TDMT_VND_DROP_TABLE
:
case
TDMT_VND_DROP_TABLE
:
// if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) {
// if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) {
// // TODO: handle error
// // TODO: handle error
...
...
source/util/test/CMakeLists.txt
浏览文件 @
748d161a
...
@@ -45,4 +45,10 @@ target_link_libraries(freelistTest os util gtest gtest_main)
...
@@ -45,4 +45,10 @@ target_link_libraries(freelistTest os util gtest gtest_main)
add_executable
(
encodeTest
"encodeTest.cpp"
)
add_executable
(
encodeTest
"encodeTest.cpp"
)
target_link_libraries
(
encodeTest os util gtest gtest_main
)
target_link_libraries
(
encodeTest os util gtest gtest_main
)
# queueTest
add_executable
(
queue_test
"queueTest.cpp"
)
target_link_libraries
(
queue_test os util gtest_main
)
add_test
(
NAME queue_test
COMMAND queue_test
)
\ No newline at end of file
source/util/test/queueTest.cpp
0 → 100644
浏览文件 @
748d161a
/**
* @file queue.cpp
* @author slguan (slguan@taosdata.com)
* @brief UTIL module queue tests
* @version 1.0
* @date 2022-01-27
*
* @copyright Copyright (c) 2022
*
*/
#include <gtest/gtest.h>
#include "os.h"
#include "tqueue.h"
class
UtilTestQueue
:
public
::
testing
::
Test
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
public:
static
void
SetUpTestSuite
()
{}
static
void
TearDownTestSuite
()
{}
};
TEST_F
(
UtilTestQueue
,
01
_ReadQitemFromQsetByThread
)
{
EXPECT_EQ
(
0
,
0
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录