Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
71fdf76b
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看板
提交
71fdf76b
编写于
3月 04, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/scheduler
上级
194722ee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
20 deletion
+63
-20
include/common/tmsg.h
include/common/tmsg.h
+5
-0
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+52
-18
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
71fdf76b
...
...
@@ -140,6 +140,8 @@ typedef enum _mgmt_table {
#define TSDB_KILL_MSG_LEN 30
#define TSDB_TABLE_NUM_UNIT 100000
#define TSDB_VN_READ_ACCCESS ((char)0x1)
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
...
...
@@ -566,6 +568,7 @@ typedef struct {
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int32_t
vgVersion
;
int32_t
numOfTable
;
}
SUseDbReq
;
int32_t
tSerializeSUseDbReq
(
void
*
buf
,
int32_t
bufLen
,
SUseDbReq
*
pReq
);
...
...
@@ -791,8 +794,10 @@ typedef struct SVgroupInfo {
uint32_t
hashBegin
;
uint32_t
hashEnd
;
SEpSet
epset
;
int32_t
numOfTable
;
// unit is TSDB_TABLE_NUM_UNIT
}
SVgroupInfo
;
typedef
struct
{
int32_t
numOfVgroups
;
SVgroupInfo
vgroups
[];
...
...
include/libs/catalog/catalog.h
浏览文件 @
71fdf76b
...
...
@@ -74,9 +74,9 @@ typedef struct SDbVgVersion {
char
dbFName
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int32_t
vgVersion
;
int32_t
numOfTable
;
// unit is TSDB_TABLE_NUM_UNIT
}
SDbVgVersion
;
int32_t
catalogInit
(
SCatalogCfg
*
cfg
);
/**
...
...
source/common/src/tmsg.c
浏览文件 @
71fdf76b
...
...
@@ -1423,6 +1423,7 @@ int32_t tSerializeSUseDbReq(void *buf, int32_t bufLen, SUseDbReq *pReq) {
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
dbId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTable
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1438,6 +1439,7 @@ int32_t tDeserializeSUseDbReq(void *buf, int32_t bufLen, SUseDbReq *pReq) {
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
dbId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTable
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
...
...
@@ -1482,6 +1484,7 @@ static int32_t tSerializeSUseDbRspImp(SCoder *pEncoder, SUseDbRsp *pRsp) {
if
(
tEncodeU32
(
pEncoder
,
pVgInfo
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
pEncoder
,
pVgInfo
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pVgInfo
->
epset
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pVgInfo
->
numOfTable
)
<
0
)
return
-
1
;
}
return
0
;
...
...
@@ -1542,6 +1545,7 @@ int32_t tDeserializeSUseDbRspImp(SCoder *pDecoder, SUseDbRsp *pRsp) {
if
(
tDecodeU32
(
pDecoder
,
&
vgInfo
.
hashBegin
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
pDecoder
,
&
vgInfo
.
hashEnd
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
vgInfo
.
epset
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
vgInfo
.
numOfTable
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
pVgroupInfos
,
&
vgInfo
);
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
71fdf76b
...
...
@@ -885,6 +885,29 @@ DROP_DB_OVER:
return
code
;
}
void
mndGetDBTableNum
(
SDbObj
*
pDb
,
SMnode
*
pMnode
,
int32_t
*
num
)
{
int32_t
vindex
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
while
(
vindex
<
pDb
->
cfg
.
numOfVgroups
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
==
pDb
->
uid
)
{
*
num
+=
pVgroup
->
numOfTables
/
TSDB_TABLE_NUM_UNIT
;
vindex
++
;
}
sdbRelease
(
pSdb
,
pVgroup
);
}
sdbCancelFetch
(
pSdb
,
pIter
);
}
static
void
mndBuildDBVgroupInfo
(
SDbObj
*
pDb
,
SMnode
*
pMnode
,
SArray
*
pVgList
)
{
int32_t
vindex
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -900,6 +923,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
vgInfo
.
vgId
=
pVgroup
->
vgId
;
vgInfo
.
hashBegin
=
pVgroup
->
hashBegin
;
vgInfo
.
hashEnd
=
pVgroup
->
hashEnd
;
vgInfo
.
numOfTable
=
pVgroup
->
numOfTables
/
TSDB_TABLE_NUM_UNIT
;
vgInfo
.
epset
.
numOfEps
=
pVgroup
->
replica
;
for
(
int32_t
gid
=
0
;
gid
<
pVgroup
->
replica
;
++
gid
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
gid
];
...
...
@@ -967,7 +991,10 @@ static int32_t mndProcessUseDbReq(SMnodeMsg *pReq) {
goto
USE_DB_OVER
;
}
if
(
usedbReq
.
vgVersion
<
pDb
->
vgVersion
||
usedbReq
.
dbId
!=
pDb
->
uid
)
{
int32_t
numOfTable
=
0
;
mndGetDBTableNum
(
pDb
,
pMnode
,
&
numOfTable
);
if
(
usedbReq
.
vgVersion
<
pDb
->
vgVersion
||
usedbReq
.
dbId
!=
pDb
->
uid
||
numOfTable
!=
usedbReq
.
numOfTable
)
{
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
usedbRsp
.
pVgroupInfos
);
}
...
...
@@ -1017,6 +1044,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
SDbVgVersion
*
pDbVgVersion
=
&
pDbs
[
i
];
pDbVgVersion
->
dbId
=
htobe64
(
pDbVgVersion
->
dbId
);
pDbVgVersion
->
vgVersion
=
htonl
(
pDbVgVersion
->
vgVersion
);
pDbVgVersion
->
numOfTable
=
htonl
(
pDbVgVersion
->
numOfTable
);
SUseDbRsp
usedbRsp
=
{
0
};
...
...
@@ -1027,28 +1055,34 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
usedbRsp
.
uid
=
pDbVgVersion
->
dbId
;
usedbRsp
.
vgVersion
=
-
1
;
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
}
else
if
(
pDbVgVersion
->
vgVersion
>=
pDb
->
vgVersion
)
{
mDebug
(
"db:%s, version not changed"
,
pDbVgVersion
->
dbFName
);
mndReleaseDb
(
pMnode
,
pDb
);
continue
;
}
else
{
usedbRsp
.
pVgroupInfos
=
taosArrayInit
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgroupInfo
));
if
(
usedbRsp
.
pVgroupInfos
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
mError
(
"db:%s, failed to malloc usedb response"
,
pDb
->
name
);
continue
;
}
}
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
usedbRsp
.
pVgroupInfos
);
memcpy
(
usedbRsp
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
usedbRsp
.
uid
=
pDb
->
uid
;
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
hashMethod
=
pDb
->
hashMethod
;
int32_t
numOfTable
=
0
;
mndGetDBTableNum
(
pDb
,
pMnode
,
&
numOfTable
);
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
if
(
pDbVgVersion
->
vgVersion
>=
pDb
->
vgVersion
&&
numOfTable
==
pDbVgVersion
->
numOfTable
)
{
mDebug
(
"db:%s, version & numOfTable not changed"
,
pDbVgVersion
->
dbFName
);
mndReleaseDb
(
pMnode
,
pDb
);
continue
;
}
usedbRsp
.
pVgroupInfos
=
taosArrayInit
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgroupInfo
));
if
(
usedbRsp
.
pVgroupInfos
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
mError
(
"db:%s, failed to malloc usedb response"
,
pDb
->
name
);
continue
;
}
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
usedbRsp
.
pVgroupInfos
);
memcpy
(
usedbRsp
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
usedbRsp
.
uid
=
pDb
->
uid
;
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
hashMethod
=
pDb
->
hashMethod
;
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
}
int32_t
rspLen
=
tSerializeSUseDbBatchRsp
(
NULL
,
0
,
&
batchUseRsp
);
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
71fdf76b
...
...
@@ -247,7 +247,7 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) {
PROCESS_META_OVER:
if
(
code
!=
0
)
{
qError
(
"failed to process table meta rsp since %s"
,
t
errstr
(
));
qError
(
"failed to process table meta rsp since %s"
,
t
strerror
(
code
));
}
tFreeSTableMetaRsp
(
&
metaRsp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录