Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d7fc732d
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
d7fc732d
编写于
2月 12, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
serailze db req
上级
1755559d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
202 addition
and
199 deletion
+202
-199
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+55
-54
source/dnode/mnode/impl/test/db/db.cpp
source/dnode/mnode/impl/test/db/db.cpp
+50
-46
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+25
-23
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+25
-23
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+46
-52
source/util/src/terror.c
source/util/src/terror.c
+1
-1
未找到文件。
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
d7fc732d
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDb.h"
#include "mndAuth.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -369,7 +370,7 @@ static int32_t mndSetCreateDbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SDropVnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_VNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_VNODE_NOT_DEPLOYED
;
action
.
acceptableCode
=
TSDB_CODE_DND_VNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
return
-
1
;
...
...
@@ -451,54 +452,54 @@ CREATE_DB_OVER:
}
static
int32_t
mndProcessCreateDbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SCreateDbReq
*
pCreate
=
pReq
->
rpcMsg
.
pCont
;
pCreate
->
numOfVgroups
=
htonl
(
pCreate
->
numOfVgroups
);
pCreate
->
cacheBlockSize
=
htonl
(
pCreate
->
cacheBlockSize
);
pCreate
->
totalBlocks
=
htonl
(
pCreate
->
totalBlocks
);
pCreate
->
daysPerFile
=
htonl
(
pCreate
->
daysPerFile
);
pCreate
->
daysToKeep0
=
htonl
(
pCreate
->
daysToKeep0
);
pCreate
->
daysToKeep1
=
htonl
(
pCreate
->
daysToKeep1
);
pCreate
->
daysToKeep2
=
htonl
(
pCreate
->
daysToKeep2
);
pCreate
->
minRows
=
htonl
(
pCreate
->
minRows
);
pCreate
->
maxRows
=
htonl
(
pCreate
->
maxRows
);
pCreate
->
commitTime
=
htonl
(
pCreate
->
commitTime
);
pCreate
->
fsyncPeriod
=
htonl
(
pCreate
->
fsyncPeriod
);
mDebug
(
"db:%s, start to create, vgroups:%d"
,
pCreate
->
db
,
pCreate
->
numOfVgroups
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pCreate
->
db
);
SMnode
*
pMnode
=
pReq
->
pMnode
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SCreateDbReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDbReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_DB_OVER
;
}
mDebug
(
"db:%s, start to create, vgroups:%d"
,
createReq
.
db
,
createReq
.
numOfVgroups
);
pDb
=
mndAcquireDb
(
pMnode
,
createReq
.
db
);
if
(
pDb
!=
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
if
(
pCreate
->
ignoreExist
)
{
mDebug
(
"db:%s, already exist, ignore exist is set"
,
pCreate
->
db
)
;
return
0
;
if
(
createReq
.
ignoreExist
)
{
mDebug
(
"db:%s, already exist, ignore exist is set"
,
createReq
.
db
);
code
=
0
;
goto
CREATE_DB_OVER
;
}
else
{
terrno
=
TSDB_CODE_MND_DB_ALREADY_EXIST
;
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
db
,
terrstr
());
return
-
1
;
goto
CREATE_DB_OVER
;
}
}
else
if
(
terrno
!=
TSDB_CODE_MND_DB_NOT_EXIST
)
{
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
db
,
terrstr
());
return
-
1
;
goto
CREATE_DB_OVER
;
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pOperUser
==
NULL
)
{
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
db
,
terrstr
());
return
-
1
;
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
goto
CREATE_DB_OVER
;
}
int32_t
code
=
mndCreateDb
(
pMnode
,
pReq
,
pCreate
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
if
(
mndCheckCreateDbAuth
(
pUser
)
!=
0
)
{
goto
CREATE_DB_OVER
;
}
if
(
code
!=
0
)
{
mError
(
"db:%s, failed to create since %s"
,
pCreate
->
db
,
terrstr
());
return
-
1
;
code
=
mndCreateDb
(
pMnode
,
pReq
,
&
createReq
,
pUser
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
CREATE_DB_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to create since %s"
,
createReq
.
db
,
terrstr
());
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
static
int32_t
mndSetDbCfgFromAlterDbReq
(
SDbObj
*
pDb
,
SAlterDbReq
*
pAlter
)
{
...
...
@@ -818,7 +819,7 @@ static int32_t mndProcessDropDbReq(SMnodeMsg *pReq) {
static
void
mndBuildDBVgroupInfo
(
SDbObj
*
pDb
,
SMnode
*
pMnode
,
SVgroupInfo
*
vgList
,
int32_t
*
vgNum
)
{
int32_t
vindex
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
while
(
vindex
<
pDb
->
cfg
.
numOfVgroups
)
{
...
...
@@ -833,9 +834,9 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SVgroupInfo *vgLis
pInfo
->
hashEnd
=
htonl
(
pVgroup
->
hashEnd
);
pInfo
->
epset
.
numOfEps
=
pVgroup
->
replica
;
for
(
int32_t
gid
=
0
;
gid
<
pVgroup
->
replica
;
++
gid
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
gid
];
SEp
*
pEp
=
&
pInfo
->
epset
.
eps
[
gid
];
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
gid
];
SEp
*
pEp
=
&
pInfo
->
epset
.
eps
[
gid
];
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pDnode
!=
NULL
)
{
memcpy
(
pEp
->
fqdn
,
pDnode
->
fqdn
,
TSDB_FQDN_LEN
);
pEp
->
port
=
htons
(
pDnode
->
port
);
...
...
@@ -895,12 +896,12 @@ static int32_t mndProcessUseDbReq(SMnodeMsg *pReq) {
}
int32_t
mndValidateDBInfo
(
SMnode
*
pMnode
,
SDbVgVersion
*
dbs
,
int32_t
num
,
void
**
rsp
,
int32_t
*
rspLen
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
bufSize
=
num
*
(
sizeof
(
SUseDbRsp
)
+
TSDB_DEFAULT_VN_PER_DB
*
sizeof
(
SVgroupInfo
));
void
*
buf
=
malloc
(
bufSize
);
int32_t
len
=
0
;
int32_t
contLen
=
0
;
int32_t
bufOffset
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
bufSize
=
num
*
(
sizeof
(
SUseDbRsp
)
+
TSDB_DEFAULT_VN_PER_DB
*
sizeof
(
SVgroupInfo
));
void
*
buf
=
malloc
(
bufSize
);
int32_t
len
=
0
;
int32_t
contLen
=
0
;
int32_t
bufOffset
=
0
;
SUseDbRsp
*
pRsp
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
@@ -909,11 +910,11 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
db
->
vgVersion
=
ntohl
(
db
->
vgVersion
);
len
=
0
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
db
->
dbFName
);
if
(
pDb
==
NULL
)
{
mInfo
(
"db %s not exist"
,
db
->
dbFName
);
len
=
sizeof
(
SUseDbRsp
);
}
else
if
(
pDb
->
uid
!=
db
->
dbId
||
db
->
vgVersion
<
pDb
->
vgVersion
)
{
len
=
sizeof
(
SUseDbRsp
)
+
pDb
->
cfg
.
numOfVgroups
*
sizeof
(
SVgroupInfo
);
...
...
@@ -921,16 +922,16 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
if
(
0
==
len
)
{
mndReleaseDb
(
pMnode
,
pDb
);
continue
;
}
contLen
+=
len
;
if
(
contLen
>
bufSize
)
{
buf
=
realloc
(
buf
,
contLen
);
}
pRsp
=
(
SUseDbRsp
*
)((
char
*
)
buf
+
bufOffset
);
memcpy
(
pRsp
->
db
,
db
->
dbFName
,
TSDB_DB_FNAME_LEN
);
if
(
pDb
)
{
...
...
@@ -949,7 +950,7 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
}
bufOffset
+=
len
;
mndReleaseDb
(
pMnode
,
pDb
);
}
...
...
source/dnode/mnode/impl/test/db/db.cpp
浏览文件 @
d7fc732d
...
...
@@ -53,29 +53,31 @@ TEST_F(MndTestDb, 01_ShowDb) {
TEST_F
(
MndTestDb
,
02
_Create_Alter_Drop_Db
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
numOfVgroups
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
maxRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replications
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
"1.d1"
);
createReq
.
numOfVgroups
=
2
;
createReq
.
cacheBlockSize
=
16
;
createReq
.
totalBlocks
=
10
;
createReq
.
daysPerFile
=
10
;
createReq
.
daysToKeep0
=
3650
;
createReq
.
daysToKeep1
=
3650
;
createReq
.
daysToKeep2
=
3650
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
commitTime
=
3600
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
quorum
=
1
;
createReq
.
update
=
0
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -217,29 +219,31 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
TEST_F
(
MndTestDb
,
03
_Create_Use_Restart_Use_Db
)
{
{
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
"1.d2"
);
pReq
->
numOfVgroups
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
maxRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replications
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
"1.d2"
);
createReq
.
numOfVgroups
=
2
;
createReq
.
cacheBlockSize
=
16
;
createReq
.
totalBlocks
=
10
;
createReq
.
daysPerFile
=
10
;
createReq
.
daysToKeep0
=
3650
;
createReq
.
daysToKeep1
=
3650
;
createReq
.
daysToKeep2
=
3650
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
commitTime
=
3600
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
quorum
=
1
;
createReq
.
update
=
0
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
d7fc732d
...
...
@@ -38,29 +38,31 @@ class MndTestStb : public ::testing::Test {
Testbase
MndTestStb
::
test
;
void
*
MndTestStb
::
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
dbname
);
pReq
->
numOfVgroups
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
maxRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replications
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
dbname
);
createReq
.
numOfVgroups
=
2
;
createReq
.
cacheBlockSize
=
16
;
createReq
.
totalBlocks
=
10
;
createReq
.
daysPerFile
=
10
;
createReq
.
daysToKeep0
=
3650
;
createReq
.
daysToKeep1
=
3650
;
createReq
.
daysToKeep2
=
3650
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
commitTime
=
3600
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
quorum
=
1
;
createReq
.
update
=
0
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
*
pContLen
=
contLen
;
return
pReq
;
...
...
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
d7fc732d
...
...
@@ -319,29 +319,31 @@ TEST_F(MndTestUser, 03_Alter_User) {
}
{
int32_t
contLen
=
sizeof
(
SCreateDbReq
);
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
"1.d2"
);
pReq
->
numOfVgroups
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
maxRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replications
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
"1.d2"
);
createReq
.
numOfVgroups
=
2
;
createReq
.
cacheBlockSize
=
16
;
createReq
.
totalBlocks
=
10
;
createReq
.
daysPerFile
=
10
;
createReq
.
daysToKeep0
=
3650
;
createReq
.
daysToKeep1
=
3650
;
createReq
.
daysToKeep2
=
3650
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
commitTime
=
3600
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
quorum
=
1
;
createReq
.
update
=
0
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
d7fc732d
...
...
@@ -39,7 +39,7 @@ namespace {
extern
"C"
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
);
extern
"C"
int32_t
ctgUpdateTableMetaCache
(
struct
SCatalog
*
pCatalog
,
STableMetaOutput
*
output
);
extern
"C"
int32_t
ctgDbgGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgDbgGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
void
ctgTestSetPrepareTableMeta
();
void
ctgTestSetPrepareCTableMeta
();
...
...
@@ -52,14 +52,14 @@ bool ctgTestDeadLoop = false;
int32_t
ctgTestPrintNum
=
200000
;
int32_t
ctgTestMTRunSec
=
5
;
int32_t
ctgTestCurrentVgVersion
=
0
;
int32_t
ctgTestVgVersion
=
1
;
int32_t
ctgTestVgNum
=
10
;
int32_t
ctgTestColNum
=
2
;
int32_t
ctgTestTagNum
=
1
;
int32_t
ctgTestSVersion
=
1
;
int32_t
ctgTestTVersion
=
1
;
int32_t
ctgTestSuid
=
2
;
int32_t
ctgTestCurrentVgVersion
=
0
;
int32_t
ctgTestVgVersion
=
1
;
int32_t
ctgTestVgNum
=
10
;
int32_t
ctgTestColNum
=
2
;
int32_t
ctgTestTagNum
=
1
;
int32_t
ctgTestSVersion
=
1
;
int32_t
ctgTestTVersion
=
1
;
int32_t
ctgTestSuid
=
2
;
uint64_t
ctgTestDbId
=
33
;
uint64_t
ctgTestClusterId
=
0x1
;
...
...
@@ -69,31 +69,35 @@ char *ctgTestCTablename = "ctable1";
char
*
ctgTestSTablename
=
"stable1"
;
void
sendCreateDbMsg
(
void
*
shandle
,
SEpSet
*
pEpSet
)
{
SCreateDbReq
*
pReq
=
(
SCreateDbReq
*
)
rpcMallocCont
(
sizeof
(
SCreateDbReq
));
strcpy
(
pReq
->
db
,
"1.db1"
);
pReq
->
numOfVgroups
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
maxRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replications
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
"1.db1"
);
createReq
.
numOfVgroups
=
2
;
createReq
.
cacheBlockSize
=
16
;
createReq
.
totalBlocks
=
10
;
createReq
.
daysPerFile
=
10
;
createReq
.
daysToKeep0
=
3650
;
createReq
.
daysToKeep1
=
3650
;
createReq
.
daysToKeep2
=
3650
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
commitTime
=
3600
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
quorum
=
1
;
createReq
.
update
=
0
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDbReq
)
;
rpcMsg
.
contLen
=
contLen
;
rpcMsg
.
msgType
=
TDMT_MND_CREATE_DB
;
SRpcMsg
rpcRsp
=
{
0
};
...
...
@@ -210,7 +214,6 @@ void ctgTestBuildDBVgroup(SDBVgroupInfo **pdbVgroup) {
*
pdbVgroup
=
dbVgroup
;
}
void
ctgTestBuildSTableMetaRsp
(
STableMetaRsp
*
rspMsg
)
{
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
sprintf
(
rspMsg
->
tbName
,
"%s"
,
ctgTestSTablename
);
...
...
@@ -248,7 +251,6 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) {
return
;
}
void
ctgTestPrepareDbVgroups
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
SUseDbRsp
*
rspMsg
=
NULL
;
// todo
...
...
@@ -372,8 +374,8 @@ void ctgTestPrepareSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpc
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
strcpy
(
rspMsg
->
tbName
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
stbName
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
tbName
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
stbName
,
ctgTestSTablename
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
...
...
@@ -635,7 +637,7 @@ void *ctgTestGetDbVgroupThread(void *param) {
void
*
ctgTestSetSameDbVgroupThread
(
void
*
param
)
{
struct
SCatalog
*
pCtg
=
(
struct
SCatalog
*
)
param
;
int32_t
code
=
0
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
int32_t
n
=
0
;
while
(
!
ctgTestStop
)
{
...
...
@@ -656,11 +658,10 @@ void *ctgTestSetSameDbVgroupThread(void *param) {
return
NULL
;
}
void
*
ctgTestSetDiffDbVgroupThread
(
void
*
param
)
{
struct
SCatalog
*
pCtg
=
(
struct
SCatalog
*
)
param
;
int32_t
code
=
0
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
int32_t
n
=
0
;
while
(
!
ctgTestStop
)
{
...
...
@@ -681,7 +682,6 @@ void *ctgTestSetDiffDbVgroupThread(void *param) {
return
NULL
;
}
void
*
ctgTestGetCtableMetaThread
(
void
*
param
)
{
struct
SCatalog
*
pCtg
=
(
struct
SCatalog
*
)
param
;
int32_t
code
=
0
;
...
...
@@ -741,7 +741,6 @@ void *ctgTestSetCtableMetaThread(void *param) {
return
NULL
;
}
TEST
(
tableMeta
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
...
@@ -914,7 +913,7 @@ TEST(tableMeta, childTableCase) {
}
if
(
stbNum
)
{
printf
(
"got expired stb,suid:%"
PRId64
",dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
printf
(
"got expired stb,suid:%"
PRId64
",dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
free
(
stb
);
stb
=
NULL
;
}
else
{
...
...
@@ -1016,7 +1015,7 @@ TEST(tableMeta, superTableCase) {
if
(
stbNum
)
{
printf
(
"got expired stb,suid:%"
PRId64
",dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
free
(
stb
);
stb
=
NULL
;
}
else
{
...
...
@@ -1078,7 +1077,7 @@ TEST(tableMeta, rmStbMeta) {
ASSERT_EQ
(
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
ASSERT_EQ
(
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
),
0
);
catalogDestroy
();
}
...
...
@@ -1146,12 +1145,10 @@ TEST(tableMeta, updateStbMeta) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
tfree
(
tableMeta
);
catalogDestroy
();
}
TEST
(
tableDistVgroup
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
...
@@ -1258,7 +1255,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
void
*
mockPointer
=
(
void
*
)
0x1
;
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
*
pvgInfo
=
NULL
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
SArray
*
vgList
=
NULL
;
ctgTestInitLogFile
();
...
...
@@ -1418,8 +1415,6 @@ TEST(multiThread, getSetRmDiffDbVgroup) {
catalogDestroy
();
}
TEST
(
multiThread
,
ctableMeta
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
...
@@ -1470,8 +1465,6 @@ TEST(multiThread, ctableMeta) {
catalogDestroy
();
}
TEST
(
rentTest
,
allRent
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
...
@@ -1530,7 +1523,8 @@ TEST(rentTest, allRent) {
printf
(
"%d - expired stableNum:%d
\n
"
,
i
,
num
);
if
(
stable
)
{
for
(
int32_t
n
=
0
;
n
<
num
;
++
n
)
{
printf
(
"suid:%"
PRId64
", dbFName:%s, stbName:%s, sversion:%d, tversion:%d
\n
"
,
stable
[
n
].
suid
,
stable
[
n
].
dbFName
,
stable
[
n
].
stbName
,
stable
[
n
].
sversion
,
stable
[
n
].
tversion
);
printf
(
"suid:%"
PRId64
", dbFName:%s, stbName:%s, sversion:%d, tversion:%d
\n
"
,
stable
[
n
].
suid
,
stable
[
n
].
dbFName
,
stable
[
n
].
stbName
,
stable
[
n
].
sversion
,
stable
[
n
].
tversion
);
}
free
(
stable
);
stable
=
NULL
;
...
...
source/util/src/terror.c
浏览文件 @
d7fc732d
...
...
@@ -77,7 +77,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PTR, "Invalid pointer")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
"Memory corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FILE_CORRUPTED
,
"Data file corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_CHECKSUM_ERROR
,
"Checksum error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_MSG
,
"Invalid
config
message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_MSG
,
"Invalid message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MSG_NOT_PROCESSED
,
"Message not processed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_PARA
,
"Invalid parameters"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_REPEAT_INIT
,
"Repeat initialization"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录