Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
503a6110
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看板
提交
503a6110
编写于
7月 16, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5250]<enhance>: improve the performance of multi-table meta bulk load.
上级
eabbe88f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
28 deletion
+40
-28
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+24
-20
src/client/src/tscSql.c
src/client/src/tscSql.c
+7
-2
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-4
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+1
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
503a6110
...
...
@@ -310,7 +310,7 @@ void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
void
tscAsyncQuerySingleRowForNextVnode
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
,
SRpcCorEpSet
*
corEpSet
);
int32_t
getMultiTableMetaFromMnode
(
SSqlObj
*
pSql
,
SArray
*
pNameList
,
SArray
*
pVgroupNameList
,
__async_cb_func_t
fp
);
int32_t
getMultiTableMetaFromMnode
(
SSqlObj
*
pSql
,
SArray
*
pNameList
,
SArray
*
pVgroupNameList
,
__async_cb_func_t
fp
,
bool
metaClone
);
int
tscTransferTableNameList
(
SSqlObj
*
pSql
,
const
char
*
pNameList
,
int32_t
length
,
SArray
*
pNameArray
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
503a6110
...
...
@@ -7738,7 +7738,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// load the table meta for a given table name list
if
(
taosArrayGetSize
(
plist
)
>
0
||
taosArrayGetSize
(
pVgroupList
)
>
0
)
{
code
=
getMultiTableMetaFromMnode
(
pSql
,
plist
,
pVgroupList
,
tscTableMetaCallBack
);
code
=
getMultiTableMetaFromMnode
(
pSql
,
plist
,
pVgroupList
,
tscTableMetaCallBack
,
true
);
}
_end:
...
...
src/client/src/tscServer.c
浏览文件 @
503a6110
...
...
@@ -1873,7 +1873,6 @@ static int32_t tableMetaMsgConvert(STableMetaMsg* pMetaMsg) {
pMetaMsg
->
vgroup
.
vgId
=
htonl
(
pMetaMsg
->
vgroup
.
vgId
);
pMetaMsg
->
uid
=
htobe64
(
pMetaMsg
->
uid
);
// pMetaMsg->contLen = htonl(pMetaMsg->contLen);
pMetaMsg
->
numOfColumns
=
htons
(
pMetaMsg
->
numOfColumns
);
if
((
pMetaMsg
->
tableType
!=
TSDB_SUPER_TABLE
)
&&
...
...
@@ -1938,13 +1937,14 @@ static void doAddTableMetaToLocalBuf(STableMeta* pTableMeta, STableMetaMsg* pMet
int32_t
len
=
(
int32_t
)
strnlen
(
pTableMeta
->
sTableName
,
TSDB_TABLE_FNAME_LEN
);
// The super tableMeta already exists, create it according to tableMeta and add it to hash map
STableMeta
*
pSupTableMeta
=
createSuperTableMeta
(
pMetaMsg
);
if
(
updateSTable
)
{
STableMeta
*
pSupTableMeta
=
createSuperTableMeta
(
pMetaMsg
);
uint32_t
size
=
tscGetTableMetaSize
(
pSupTableMeta
);
int32_t
code
=
taosHashPut
(
tscTableMetaInfo
,
pTableMeta
->
sTableName
,
len
,
pSupTableMeta
,
size
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
uint32_t
size
=
tscGetTableMetaSize
(
pSupTableMeta
);
int32_t
code
=
taosHashPut
(
tscTableMetaInfo
,
pTableMeta
->
sTableName
,
len
,
pSupTableMeta
,
size
);
assert
(
code
==
TSDB_CODE_SUCCESS
);
tfree
(
pSupTableMeta
);
tfree
(
pSupTableMeta
);
}
CChildTableMeta
*
cMeta
=
tscCreateChildMeta
(
pTableMeta
);
taosHashPut
(
tscTableMetaInfo
,
pMetaMsg
->
tableFname
,
strlen
(
pMetaMsg
->
tableFname
),
cMeta
,
sizeof
(
CChildTableMeta
));
...
...
@@ -2049,10 +2049,10 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
}
SSqlCmd
*
pParentCmd
=
&
pParentSql
->
cmd
;
SHashObj
*
pSet
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pSet
=
taosHashInit
(
pMultiMeta
->
numOfVgroup
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
char
*
pMsg
=
pMultiMeta
->
meta
;
char
*
buf
=
NULL
;
char
*
pMsg
=
pMultiMeta
->
meta
;
if
(
pMultiMeta
->
compressed
)
{
buf
=
malloc
(
pMultiMeta
->
rawLen
-
sizeof
(
SMultiTableMeta
));
int32_t
len
=
tsDecompressString
(
pMultiMeta
->
meta
,
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
),
1
,
...
...
@@ -2086,22 +2086,25 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
SName
sn
=
{
0
};
tNameFromString
(
&
sn
,
pMetaMsg
->
tableFname
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
const
char
*
tableName
=
tNameGetTableName
(
&
sn
);
size_t
keyLen
=
strlen
(
tableName
)
;
if
(
pMultiMeta
->
metaClone
==
1
||
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
STableMetaVgroupInfo
p
=
{.
pTableMeta
=
pTableMeta
,}
;
STableMetaVgroupInfo
p
=
{.
pTableMeta
=
pTableMeta
,};
taosHashPut
(
pParentCmd
->
pTableMetaMap
,
tableName
,
keyLen
,
&
p
,
sizeof
(
STableMetaVgroupInfo
));
const
char
*
tableName
=
tNameGetTableName
(
&
sn
);
size_t
keyLen
=
strlen
(
tableName
);
taosHashPut
(
pParentCmd
->
pTableMetaMap
,
tableName
,
keyLen
,
&
p
,
sizeof
(
STableMetaVgroupInfo
));
}
bool
addToBuf
=
false
;
if
(
taosHashGet
(
pSet
,
&
pMetaMsg
->
uid
,
sizeof
(
pMetaMsg
->
uid
))
==
NULL
)
{
addToBuf
=
true
;
taosHashPut
(
pSet
,
&
pMetaMsg
->
uid
,
sizeof
(
pMetaMsg
->
uid
),
""
,
0
);
// for each super table, only update meta information once
bool
updateStableMeta
=
false
;
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
&&
taosHashGet
(
pSet
,
&
pMetaMsg
->
uid
,
sizeof
(
pMetaMsg
->
uid
))
==
NULL
)
{
updateStableMeta
=
true
;
taosHashPut
(
pSet
,
&
pTableMeta
->
suid
,
sizeof
(
pMetaMsg
->
suid
),
""
,
0
);
}
// create the tableMeta and add it into the TableMeta map
doAddTableMetaToLocalBuf
(
pTableMeta
,
pMetaMsg
,
addToBuf
);
doAddTableMetaToLocalBuf
(
pTableMeta
,
pMetaMsg
,
updateStableMeta
);
//
if the vgroup is not updated in current process, update it
.
//
for each vgroup, only update the information once
.
int64_t
vgId
=
pMetaMsg
->
vgroup
.
vgId
;
if
(
pTableMeta
->
tableType
!=
TSDB_SUPER_TABLE
&&
taosHashGet
(
pSet
,
&
vgId
,
sizeof
(
vgId
))
==
NULL
)
{
doUpdateVgroupInfo
(
pTableMeta
,
&
pMetaMsg
->
vgroup
);
...
...
@@ -2513,7 +2516,7 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
return
code
;
}
int32_t
getMultiTableMetaFromMnode
(
SSqlObj
*
pSql
,
SArray
*
pNameList
,
SArray
*
pVgroupNameList
,
__async_cb_func_t
fp
)
{
int32_t
getMultiTableMetaFromMnode
(
SSqlObj
*
pSql
,
SArray
*
pNameList
,
SArray
*
pVgroupNameList
,
__async_cb_func_t
fp
,
bool
metaClone
)
{
SSqlObj
*
pNew
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
NULL
==
pNew
)
{
tscError
(
"0x%"
PRIx64
" failed to allocate sqlobj to get multiple table meta"
,
pSql
->
self
);
...
...
@@ -2535,6 +2538,7 @@ int32_t getMultiTableMetaFromMnode(SSqlObj *pSql, SArray* pNameList, SArray* pVg
}
SMultiTableInfoMsg
*
pInfo
=
(
SMultiTableInfoMsg
*
)
pNew
->
cmd
.
payload
;
pInfo
->
metaClone
=
metaClone
?
1
:
0
;
pInfo
->
numOfTables
=
htonl
((
uint32_t
)
taosArrayGetSize
(
pNameList
));
pInfo
->
numOfVgroups
=
htonl
((
uint32_t
)
taosArrayGetSize
(
pVgroupNameList
));
...
...
src/client/src/tscSql.c
浏览文件 @
503a6110
...
...
@@ -948,7 +948,6 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
pSql
->
pTscObj
=
taos
;
pSql
->
signature
=
pSql
;
pSql
->
cmd
.
pTableMetaMap
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
int32_t
length
=
(
int32_t
)
strlen
(
tableNameList
);
if
(
length
>
MAX_TABLE_NAME_LENGTH
)
{
...
...
@@ -967,6 +966,11 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
strtolower
(
str
,
tableNameList
);
SArray
*
plist
=
taosArrayInit
(
4
,
POINTER_BYTES
);
SArray
*
vgroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
plist
==
NULL
||
vgroupList
==
NULL
)
{
tfree
(
str
);
tscFreeSqlObj
(
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
int32_t
code
=
(
uint8_t
)
tscTransferTableNameList
(
pSql
,
str
,
length
,
plist
);
free
(
str
);
...
...
@@ -976,10 +980,11 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
return
code
;
}
pSql
->
cmd
.
pTableMetaMap
=
taosHashInit
(
taosArrayGetSize
(
plist
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
registerSqlObj
(
pSql
);
tscDebug
(
"0x%"
PRIx64
" load multiple table meta, tableNameList: %s pObj:%p"
,
pSql
->
self
,
tableNameList
,
pObj
);
code
=
getMultiTableMetaFromMnode
(
pSql
,
plist
,
vgroupList
,
loadMultiTableMetaCallback
);
code
=
getMultiTableMetaFromMnode
(
pSql
,
plist
,
vgroupList
,
loadMultiTableMetaCallback
,
false
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
code
=
TSDB_CODE_SUCCESS
;
}
...
...
src/inc/taosmsg.h
浏览文件 @
503a6110
...
...
@@ -710,6 +710,7 @@ typedef struct {
}
STableInfoMsg
;
typedef
struct
{
uint8_t
metaClone
;
// create local clone of the cached table meta
int32_t
numOfVgroups
;
int32_t
numOfTables
;
char
tableNames
[];
...
...
@@ -761,10 +762,11 @@ typedef struct STableMetaMsg {
typedef
struct
SMultiTableMeta
{
int32_t
numOfTables
;
int32_t
numOfVgroup
;
uint32_t
contLen
:
31
;
uint8_t
compressed
:
1
;
// denote if compressed or not
uint32_t
rawLen
;
// size before compress
uint8_t
metaClone
;
// make meta clone after retrieve meta from mnode
uint8_t
compressed
;
// denote if compressed or not
int32_t
numOfVgroup
;
// number of tables
uint32_t
contLen
;
// current content length
uint32_t
rawLen
;
// size before compressed
char
meta
[];
}
SMultiTableMeta
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
503a6110
...
...
@@ -3036,6 +3036,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
int32_t
len
=
tsCompressString
(
pMultiMeta
->
meta
,
(
int32_t
)
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
),
1
,
tmp
+
sizeof
(
SMultiTableMeta
),
(
int32_t
)
pMultiMeta
->
contLen
-
sizeof
(
SMultiTableMeta
)
+
2
,
ONE_STAGE_COMP
,
NULL
,
0
);
pMultiMeta
->
metaClone
=
pInfo
->
metaClone
;
pMultiMeta
->
rawLen
=
pMultiMeta
->
contLen
;
if
(
len
==
-
1
||
len
+
sizeof
(
SMultiTableMeta
)
>=
pMultiMeta
->
contLen
+
2
)
{
// compress failed, do not compress this binary data
pMultiMeta
->
compressed
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录