Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
aa55054e
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aa55054e
编写于
10月 19, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1747]
上级
2cac39d6
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
111 addition
and
30 deletion
+111
-30
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-2
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+8
-6
src/client/src/tscStream.c
src/client/src/tscStream.c
+3
-3
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+4
-4
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+5
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+84
-11
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+3
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
aa55054e
...
...
@@ -231,10 +231,11 @@ int tscGetTableMeta(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo);
int
tscGetMeterMetaEx
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
bool
createIfNotExists
);
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
);
void
tscAddTimestampColumn
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
int16_t
tableIndex
);
void
tscDoQuery
(
SSqlObj
*
pSql
);
SVgroupsInfo
*
tscVgroupInfoClone
(
SVgroupsInfo
*
pInfo
);
void
*
tscVgroupInfoClear
(
SVgroupsInfo
*
pInfo
);
void
tscSCMVgroupInfoCopy
(
SCMVgroupInfo
*
dst
,
const
SCMVgroupInfo
*
src
);
/**
* The create object function must be successful expect for the out of memory issue.
*
...
...
src/client/inc/tsclient.h
浏览文件 @
aa55054e
...
...
@@ -443,6 +443,7 @@ void tscPartiallyFreeSqlObj(SSqlObj *pSql);
*/
void
tscFreeSqlObj
(
SSqlObj
*
pSql
);
void
tscFreeRegisteredSqlObj
(
void
*
pSql
);
void
tscFreeTableMetaHelper
(
void
*
pTableMeta
);
void
tscCloseTscObj
(
STscObj
*
pObj
);
...
...
src/client/src/tscServer.c
浏览文件 @
aa55054e
...
...
@@ -124,9 +124,11 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
pVgroupInfo
->
inUse
=
pEpSet
->
inUse
;
pVgroupInfo
->
numOfEps
=
pEpSet
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
pVgroupInfo
->
numOfEps
;
i
++
)
{
tstrncpy
(
pVgroupInfo
->
epAddr
[
i
].
fqdn
,
pEpSet
->
fqdn
[
i
],
TSDB_FQDN_LEN
);
taosTFree
(
pVgroupInfo
->
epAddr
[
i
].
fqdn
);
pVgroupInfo
->
epAddr
[
i
].
fqdn
=
strndup
(
pEpSet
->
fqdn
[
i
],
tListLen
(
pEpSet
->
fqdn
[
i
]));
pVgroupInfo
->
epAddr
[
i
].
port
=
pEpSet
->
port
[
i
];
}
tscDebug
(
"after: EndPoint in use: %d"
,
pVgroupInfo
->
inUse
);
taosCorEndWrite
(
&
pVgroupInfo
->
version
);
}
...
...
@@ -1852,15 +1854,15 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
//just init, no need to lock
SCMVgroupInfo
*
pVgroups
=
&
pInfo
->
vgroupList
->
vgroups
[
j
];
SCMVgroupMsg
*
v
groupM
sg
=
&
pVgroupMsg
->
vgroups
[
j
];
pVgroups
->
vgId
=
htonl
(
v
groupM
sg
->
vgId
);
pVgroups
->
numOfEps
=
v
groupM
sg
->
numOfEps
;
SCMVgroupMsg
*
v
m
sg
=
&
pVgroupMsg
->
vgroups
[
j
];
pVgroups
->
vgId
=
htonl
(
v
m
sg
->
vgId
);
pVgroups
->
numOfEps
=
v
m
sg
->
numOfEps
;
assert
(
pVgroups
->
numOfEps
>=
1
&&
pVgroups
->
vgId
>=
1
);
for
(
int32_t
k
=
0
;
k
<
pVgroups
->
numOfEps
;
++
k
)
{
pVgroups
->
epAddr
[
k
].
port
=
htons
(
v
groupM
sg
->
epAddr
[
k
].
port
);
pVgroups
->
epAddr
[
k
].
fqdn
=
strndup
(
v
groupMsg
->
epAddr
[
k
].
fqdn
,
tListLen
(
vgroupM
sg
->
epAddr
[
k
].
fqdn
));
pVgroups
->
epAddr
[
k
].
port
=
htons
(
v
m
sg
->
epAddr
[
k
].
port
);
pVgroups
->
epAddr
[
k
].
fqdn
=
strndup
(
v
msg
->
epAddr
[
k
].
fqdn
,
tListLen
(
vm
sg
->
epAddr
[
k
].
fqdn
));
}
}
...
...
src/client/src/tscStream.c
浏览文件 @
aa55054e
...
...
@@ -168,8 +168,8 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
taosCacheRelease
(
tscMetaCache
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
true
);
taosTFree
(
pTableMetaInfo
->
vgroupList
);
pTableMetaInfo
->
vgroupList
=
tscVgroupInfoClear
(
pTableMetaInfo
->
vgroupList
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
return
;
}
...
...
@@ -275,7 +275,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
tscFreeSqlResult
(
pSql
);
taosTFree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
taosTFree
(
pTableMetaInfo
->
vgroupList
);
pTableMetaInfo
->
vgroupList
=
tscVgroupInfoClear
(
pTableMetaInfo
->
vgroupList
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
}
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
aa55054e
...
...
@@ -449,7 +449,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
SVgroupTableInfo
info
=
{{
0
}};
for
(
int32_t
m
=
0
;
m
<
pvg
->
numOfVgroups
;
++
m
)
{
if
(
tt
->
vgId
==
pvg
->
vgroups
[
m
].
vgId
)
{
info
.
vgInfo
=
pvg
->
vgroups
[
m
]
;
tscSCMVgroupInfoCopy
(
&
info
.
vgInfo
,
&
pvg
->
vgroups
[
m
])
;
break
;
}
}
...
...
@@ -1645,9 +1645,9 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// data in from current vnode is stored in cache and disk
uint32_t
numOfRowsFromSubquery
=
(
uint32_t
)(
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfTotalElems
+
trsupport
->
localBuffer
->
num
);
tscDebug
(
"%p sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pParentSql
,
pSql
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
epAddr
[
0
].
fqdn
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
vgId
,
numOfRowsFromSubquery
,
idx
);
SVgroupsInfo
*
vgroupsInfo
=
pTableMetaInfo
->
vgroupList
;
tscDebug
(
"%p sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pParentSql
,
pSql
,
vgroupsInfo
->
vgroups
[
0
].
epAddr
[
0
].
fqdn
,
vgroupsInfo
->
vgroups
[
0
].
vgId
,
numOfRowsFromSubquery
,
idx
);
tColModelCompact
(
pDesc
->
pColumnModel
,
trsupport
->
localBuffer
,
pDesc
->
pColumnModel
->
capacity
);
...
...
src/client/src/tscSystem.c
浏览文件 @
aa55054e
...
...
@@ -77,6 +77,7 @@ int32_t tscInitRpc(const char *user, const char *secretEncrypt, void **pDnodeCon
return
0
;
}
void
taos_init_imp
(
void
)
{
char
temp
[
128
];
...
...
@@ -124,8 +125,9 @@ void taos_init_imp(void) {
double
factor
=
(
tscEmbedded
==
0
)
?
2
.
0
:
4
.
0
;
tscNumOfThreads
=
(
int
)(
tsNumOfCores
*
tsNumOfThreadsPerCore
/
factor
);
if
(
tscNumOfThreads
<
2
)
tscNumOfThreads
=
2
;
if
(
tscNumOfThreads
<
2
)
{
tscNumOfThreads
=
2
;
}
tscQhandle
=
taosInitScheduler
(
queueSize
,
tscNumOfThreads
,
"tsc"
);
if
(
NULL
==
tscQhandle
)
{
...
...
@@ -140,7 +142,7 @@ void taos_init_imp(void) {
int64_t
refreshTime
=
10
;
// 10 seconds by default
if
(
tscMetaCache
==
NULL
)
{
tscMetaCache
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
NULL
,
"tableMeta"
);
tscMetaCache
=
taosCacheInit
(
TSDB_DATA_TYPE_BINARY
,
refreshTime
,
false
,
tscFreeTableMetaHelper
,
"tableMeta"
);
tscObjCache
=
taosCacheInit
(
TSDB_CACHE_PTR_KEY
,
refreshTime
/
2
,
false
,
tscFreeRegisteredSqlObj
,
"sqlObj"
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
aa55054e
...
...
@@ -115,7 +115,7 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
// for select query super table, the super table vgroup list can not be null in any cases.
if
(
pQueryInfo
->
command
==
TSDB_SQL_SELECT
&&
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
assert
(
pTableMetaInfo
->
vgroupList
!=
NULL
);
// assert(pTableMetaInfo->vgroupList != NULL); // if retrieve vgroupInfo failed, the value may be null
}
if
((
pQueryInfo
->
type
&
TSDB_QUERY_TYPE_FREE_RESOURCE
)
==
TSDB_QUERY_TYPE_FREE_RESOURCE
)
{
...
...
@@ -408,6 +408,24 @@ void tscFreeRegisteredSqlObj(void *pSql) {
}
}
void
tscFreeTableMetaHelper
(
void
*
pTableMeta
)
{
STableMeta
*
p
=
(
STableMeta
*
)
pTableMeta
;
int32_t
numOfEps
=
p
->
vgroupInfo
.
numOfEps
;
assert
(
numOfEps
>=
0
&&
numOfEps
<=
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
numOfEps
;
++
i
)
{
taosTFree
(
p
->
vgroupInfo
.
epAddr
[
i
].
fqdn
);
}
int32_t
numOfEps1
=
p
->
corVgroupInfo
.
numOfEps
;
assert
(
numOfEps1
>=
0
&&
numOfEps1
<=
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
numOfEps1
;
++
i
)
{
taosTFree
(
p
->
corVgroupInfo
.
epAddr
[
i
].
fqdn
);
}
}
void
tscFreeSqlObj
(
SSqlObj
*
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
;
...
...
@@ -1682,8 +1700,14 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) {
void
tscFreeVgroupTableInfo
(
SArray
*
pVgroupTables
)
{
if
(
pVgroupTables
!=
NULL
)
{
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pVgroupTables
);
i
++
)
{
size_t
num
=
taosArrayGetSize
(
pVgroupTables
);
for
(
size_t
i
=
0
;
i
<
num
;
i
++
)
{
SVgroupTableInfo
*
pInfo
=
taosArrayGet
(
pVgroupTables
,
i
);
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgInfo
.
numOfEps
;
++
j
)
{
taosTFree
(
pInfo
->
vgInfo
.
epAddr
[
j
].
fqdn
);
}
taosArrayDestroy
(
pInfo
->
itemList
);
}
taosArrayDestroy
(
pVgroupTables
);
...
...
@@ -1695,6 +1719,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool rem
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
tscFreeVgroupTableInfo
(
pTableMetaInfo
->
pVgroupTables
);
tscClearTableMetaInfo
(
pTableMetaInfo
,
removeFromCache
);
free
(
pTableMetaInfo
);
...
...
@@ -1727,13 +1752,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
pTableMetaInfo
->
pTableMeta
=
pTableMeta
;
if
(
vgroupList
!=
NULL
)
{
size_t
size
=
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SCMVgroupInfo
)
*
vgroupList
->
numOfVgroups
;
pTableMetaInfo
->
vgroupList
=
malloc
(
size
);
if
(
pTableMetaInfo
->
vgroupList
==
NULL
)
{
return
NULL
;
}
memcpy
(
pTableMetaInfo
->
vgroupList
,
vgroupList
,
size
);
pTableMetaInfo
->
vgroupList
=
tscVgroupInfoClone
(
vgroupList
);
}
pTableMetaInfo
->
tagColList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
...
...
@@ -1762,8 +1781,7 @@ void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache)
taosCacheRelease
(
tscMetaCache
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
removeFromCache
);
}
taosTFree
(
pTableMetaInfo
->
vgroupList
);
pTableMetaInfo
->
vgroupList
=
tscVgroupInfoClear
(
pTableMetaInfo
->
vgroupList
);
tscColumnListDestroy
(
pTableMetaInfo
->
tagColList
);
pTableMetaInfo
->
tagColList
=
NULL
;
}
...
...
@@ -2403,3 +2421,58 @@ void tscClearSqlOwner(SSqlObj* pSql) {
assert
(
taosCheckPthreadValid
(
pSql
->
owner
));
atomic_store_64
(
&
pSql
->
owner
,
0
);
}
SVgroupsInfo
*
tscVgroupInfoClone
(
SVgroupsInfo
*
vgroupList
)
{
if
(
vgroupList
==
NULL
)
{
return
NULL
;
}
size_t
size
=
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SCMVgroupInfo
)
*
vgroupList
->
numOfVgroups
;
SVgroupsInfo
*
pNew
=
calloc
(
1
,
size
);
if
(
pNew
==
NULL
)
{
return
NULL
;
}
pNew
->
numOfVgroups
=
vgroupList
->
numOfVgroups
;
for
(
int32_t
i
=
0
;
i
<
vgroupList
->
numOfVgroups
;
++
i
)
{
SCMVgroupInfo
*
pNewVInfo
=
&
pNew
->
vgroups
[
i
];
SCMVgroupInfo
*
pvInfo
=
&
vgroupList
->
vgroups
[
i
];
pNewVInfo
->
vgId
=
pvInfo
->
vgId
;
pNewVInfo
->
numOfEps
=
pvInfo
->
numOfEps
;
for
(
int32_t
j
=
0
;
j
<
pvInfo
->
numOfEps
;
++
j
)
{
pNewVInfo
->
epAddr
[
j
].
fqdn
=
strdup
(
pvInfo
->
epAddr
[
j
].
fqdn
);
pNewVInfo
->
epAddr
[
j
].
port
=
pvInfo
->
epAddr
[
j
].
port
;
}
}
return
pNew
;
}
void
*
tscVgroupInfoClear
(
SVgroupsInfo
*
vgroupList
)
{
if
(
vgroupList
==
NULL
)
{
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
vgroupList
->
numOfVgroups
;
++
i
)
{
SCMVgroupInfo
*
pVgroupInfo
=
&
vgroupList
->
vgroups
[
i
];
for
(
int32_t
j
=
0
;
j
<
pVgroupInfo
->
numOfEps
;
++
j
)
{
taosTFree
(
pVgroupInfo
->
epAddr
[
j
].
fqdn
);
}
}
taosTFree
(
vgroupList
);
return
NULL
;
}
void
tscSCMVgroupInfoCopy
(
SCMVgroupInfo
*
dst
,
const
SCMVgroupInfo
*
src
)
{
dst
->
vgId
=
src
->
vgId
;
dst
->
numOfEps
=
src
->
numOfEps
;
for
(
int32_t
i
=
0
;
i
<
dst
->
numOfEps
;
++
i
)
{
dst
->
epAddr
[
i
].
port
=
src
->
epAddr
[
i
].
port
;
dst
->
epAddr
[
i
].
fqdn
=
strdup
(
src
->
epAddr
[
i
].
fqdn
);
}
}
src/mnode/src/mnodeTable.c
浏览文件 @
aa55054e
...
...
@@ -1472,7 +1472,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
int32_t
numOfTable
=
htonl
(
pInfo
->
numOfTables
);
// reserve space
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
)
+
32
*
sizeof
(
SCMVgroup
Info
)
+
sizeof
(
SVgroupsMsg
);
int32_t
contLen
=
sizeof
(
SCMSTableVgroupRspMsg
)
+
32
*
sizeof
(
SCMVgroup
Msg
)
+
sizeof
(
SVgroupsMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
...
...
@@ -1521,6 +1521,8 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
if
(
pVgroup
==
NULL
)
continue
;
pVgroupMsg
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgroup
->
vgId
);
pVgroupMsg
->
vgroups
[
vgSize
].
numOfEps
=
0
;
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
numOfVnodes
;
++
vn
)
{
SDnodeObj
*
pDnode
=
pVgroup
->
vnodeGid
[
vn
].
pDnode
;
if
(
pDnode
==
NULL
)
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录