Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
953ef456
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
953ef456
编写于
12月 31, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
2e82b55a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
29 addition
and
18 deletion
+29
-18
include/common/tmsg.h
include/common/tmsg.h
+2
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+13
-16
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+9
-2
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+5
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
953ef456
...
...
@@ -174,6 +174,7 @@ typedef enum _mgmt_table {
typedef
struct
SBuildTableMetaInput
{
int32_t
vgId
;
char
*
dbName
;
char
*
tableFullName
;
}
SBuildTableMetaInput
;
...
...
@@ -776,6 +777,7 @@ typedef struct {
typedef
struct
{
SMsgHead
header
;
char
dbFname
[
TSDB_DB_FNAME_LEN
];
char
tableFname
[
TSDB_TABLE_FNAME_LEN
];
}
STableInfoMsg
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
953ef456
...
...
@@ -161,7 +161,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pTableName
,
tbFullName
);
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
tableFullName
=
tbFullName
};
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
dbName
=
NULL
,
.
tableFullName
=
tbFullName
};
char
*
msg
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
int32_t
msgLen
=
0
;
...
...
@@ -194,10 +194,10 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SE
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
char
tbFullName
[
TSDB_TABLE
_FNAME_LEN
];
tName
ExtractFullName
(
pTableName
,
t
bFullName
);
char
dbFullName
[
TSDB_DB
_FNAME_LEN
];
tName
GetFullDbName
(
pTableName
,
d
bFullName
);
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
tableFullName
=
tbFullN
ame
};
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
dbName
=
dbFullName
,
.
tableFullName
=
pTableName
->
tn
ame
};
char
*
msg
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
int32_t
msgLen
=
0
;
...
...
@@ -355,19 +355,19 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
if
(
output
->
metaNum
!=
1
&&
output
->
metaNum
!=
2
)
{
ctgError
(
"invalid table meta number[%d] got from meta rsp"
,
output
->
metaNum
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
if
(
NULL
==
output
->
tbMeta
)
{
ctgError
(
"no valid table meta got from meta rsp"
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
pCatalog
->
tableCache
.
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
ctgError
(
"init hash[%d] for tablemeta cache failed"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
...
...
@@ -375,19 +375,19 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
pCatalog
->
tableCache
.
stableCache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
tableCache
.
stableCache
)
{
ctgError
(
"init hash[%d] for stablemeta cache failed"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
output
->
metaNum
==
2
)
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
ctbFname
,
strlen
(
output
->
ctbFname
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
ctgError
(
"push ctable[%s] to table cache failed"
,
output
->
ctbFname
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
if
(
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
ctgError
(
"table type[%d] error, expected:%d"
,
output
->
tbMeta
->
tableType
,
TSDB_SUPER_TABLE
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
...
...
@@ -398,26 +398,23 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stableLock
);
ctgError
(
"push table[%s] to table cache failed"
,
output
->
tbFname
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
STableMeta
*
tbMeta
=
taosHashGet
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
));
if
(
taosHashPut
(
pCatalog
->
tableCache
.
stableCache
,
&
output
->
tbMeta
->
suid
,
sizeof
(
output
->
tbMeta
->
suid
),
&
tbMeta
,
POINTER_BYTES
)
!=
0
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stableLock
);
ctgError
(
"push suid[%"
PRIu64
"] to stable cache failed"
,
output
->
tbMeta
->
suid
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stableLock
);
}
else
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
ctgError
(
"push table[%s] to table cache failed"
,
output
->
tbFname
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
_return:
tfree
(
output
->
tbMeta
);
CTG_RET
(
code
);
}
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
953ef456
...
...
@@ -557,6 +557,8 @@ void *ctgTestGetCtableMetaThread(void *param) {
assert
(
0
);
}
tfree
(
tbMeta
);
if
(
ctgTestEnableSleep
)
{
usleep
(
rand
()
%
5
);
}
...
...
@@ -592,6 +594,8 @@ void *ctgTestSetCtableMetaThread(void *param) {
}
}
tfree
(
output
.
tbMeta
);
return
NULL
;
}
...
...
@@ -944,7 +948,6 @@ TEST(dbVgroup, getSetDbVgroupCase) {
catalogDestroy();
}
#endif
TEST(multiThread, getSetDbVgroupCase) {
struct SCatalog* pCtg = NULL;
...
...
@@ -996,6 +999,9 @@ TEST(multiThread, getSetDbVgroupCase) {
catalogDestroy();
}
#endif
TEST
(
multiThread
,
ctableMeta
)
{
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
...
@@ -1024,8 +1030,9 @@ TEST(multiThread, ctableMeta) {
pthread_attr_init
(
&
thattr
);
pthread_t
thread1
,
thread2
;
pthread_create
(
&
(
thread1
),
&
thattr
,
ctgTestGetCtableMetaThread
,
pCtg
);
pthread_create
(
&
(
thread1
),
&
thattr
,
ctgTestSetCtableMetaThread
,
pCtg
);
sleep
(
1
);
pthread_create
(
&
(
thread1
),
&
thattr
,
ctgTestGetCtableMetaThread
,
pCtg
);
while
(
true
)
{
if
(
ctgTestDeadLoop
)
{
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
953ef456
...
...
@@ -42,6 +42,11 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3
bMsg
->
header
.
vgId
=
htonl
(
bInput
->
vgId
);
if
(
bInput
->
dbName
)
{
strncpy
(
bMsg
->
dbFname
,
bInput
->
dbName
,
sizeof
(
bMsg
->
dbFname
));
bMsg
->
dbFname
[
sizeof
(
bMsg
->
dbFname
)
-
1
]
=
0
;
}
strncpy
(
bMsg
->
tableFname
,
bInput
->
tableFullName
,
sizeof
(
bMsg
->
tableFname
));
bMsg
->
tableFname
[
sizeof
(
bMsg
->
tableFname
)
-
1
]
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录