Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7493384d
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看板
提交
7493384d
编写于
4月 24, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-171] fix memory leaks in super table query.
上级
a2f05401
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
26 deletion
+48
-26
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+1
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+42
-25
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+5
-0
未找到文件。
src/query/inc/queryExecutor.h
浏览文件 @
7493384d
...
...
@@ -108,7 +108,7 @@ typedef struct STableQueryInfo {
SWindowResInfo
windowResInfo
;
}
STableQueryInfo
;
typedef
struct
STableDataInfo
{
typedef
struct
STableDataInfo
{
// todo merge with the STableQueryInfo struct
int32_t
tableIndex
;
int32_t
groupIdx
;
// group id in table list
STableQueryInfo
*
pTableQInfo
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
7493384d
...
...
@@ -111,7 +111,7 @@ static void getNextTimeWindow(SQuery *pQuery, STimeWindow *pTimeWindow);
static
void
setExecParams
(
SQuery
*
pQuery
,
SQLFunctionCtx
*
pCtx
,
void
*
inputData
,
TSKEY
*
tsCol
,
int32_t
size
,
int32_t
functionId
,
SDataStatis
*
pStatis
,
bool
hasNull
,
void
*
param
,
int32_t
scanFlag
);
static
void
initCtxOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
static
void
destroy
Meter
QueryInfo
(
STableQueryInfo
*
pTableQueryInfo
,
int32_t
numOfCols
);
static
void
destroy
Table
QueryInfo
(
STableQueryInfo
*
pTableQueryInfo
,
int32_t
numOfCols
);
static
void
resetCtxOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
static
bool
hasMainOutput
(
SQuery
*
pQuery
);
static
void
createTableDataInfo
(
SQInfo
*
pQInfo
);
...
...
@@ -3478,7 +3478,7 @@ STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, int32_t tid
return
pTableQueryInfo
;
}
UNUSED_FUNC
void
destroyMeter
QueryInfo
(
STableQueryInfo
*
pTableQueryInfo
,
int32_t
numOfCols
)
{
void
destroyTable
QueryInfo
(
STableQueryInfo
*
pTableQueryInfo
,
int32_t
numOfCols
)
{
if
(
pTableQueryInfo
==
NULL
)
{
return
;
}
...
...
@@ -4186,8 +4186,11 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, bool isSTableQuery)
.
colList
=
pQuery
->
colList
,
.
numOfCols
=
pQuery
->
numOfCols
,
};
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryTables
(
tsdb
,
&
cond
,
&
pQInfo
->
groupInfo
);
if
(
!
isSTableQuery
||
isIntervalQuery
(
pQuery
)
||
isFixedOutputQuery
(
pQuery
))
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryTables
(
tsdb
,
&
cond
,
&
pQInfo
->
groupInfo
);
}
pQInfo
->
tsdb
=
tsdb
;
pRuntimeEnv
->
pQuery
=
pQuery
;
...
...
@@ -4410,8 +4413,15 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
STableGroupInfo
gp
=
{.
numOfTables
=
1
,
.
pGroupList
=
g1
};
// include only current table
if
(
pRuntimeEnv
->
pQueryHandle
!=
NULL
)
{
tsdbCleanupQueryHandle
(
pRuntimeEnv
->
pQueryHandle
);
pRuntimeEnv
->
pQueryHandle
=
NULL
;
}
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryTables
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
);
taosArrayDestroy
(
tx
);
taosArrayDestroy
(
g1
);
if
(
pRuntimeEnv
->
pTSBuf
!=
NULL
)
{
if
(
pRuntimeEnv
->
cur
.
vnodeIndex
==
-
1
)
{
int64_t
tag
=
pRuntimeEnv
->
pCtx
[
0
].
tag
.
i64Key
;
...
...
@@ -5760,14 +5770,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
pColInfo
->
filters
=
tscFilterInfoClone
(
pQueryMsg
->
colList
[
i
].
filters
,
pColInfo
->
numOfFilters
);
}
pQuery
->
tagColList
=
calloc
(
pQueryMsg
->
numOfTags
,
sizeof
(
SColumnInfo
));
if
(
pQuery
->
tagColList
==
NULL
)
{
goto
_cleanup
;
}
for
(
int16_t
i
=
0
;
i
<
pQuery
->
numOfTags
;
++
i
)
{
pQuery
->
tagColList
[
i
]
=
pTagCols
[
i
];
}
pQuery
->
tagColList
=
pTagCols
;
// calculate the result row size
for
(
int16_t
col
=
0
;
col
<
numOfOutput
;
++
col
)
{
...
...
@@ -5930,10 +5933,6 @@ static void freeQInfo(SQInfo *pQInfo) {
}
}
tfree
(
pQuery
->
pFilterInfo
);
tfree
(
pQuery
->
colList
);
tfree
(
pQuery
->
sdata
);
if
(
pQuery
->
pSelectExpr
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SExprInfo
*
pBinExprInfo
=
&
pQuery
->
pSelectExpr
[
i
].
binExprInfo
;
...
...
@@ -5951,17 +5950,35 @@ static void freeQInfo(SQInfo *pQInfo) {
tfree
(
pQuery
->
defaultVal
);
}
tfree
(
pQuery
->
pGroupbyExpr
);
tfree
(
pQuery
);
// todo refactor, extract method to destroytableDataInfo
int32_t
numOfGroups
=
taosArrayGetSize
(
pQInfo
->
groupInfo
.
pGroupList
);
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
p
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
i
);
size_t
num
=
taosArrayGetSize
(
p
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SPair
*
pair
=
taosArrayGet
(
p
,
j
);
if
(
pair
->
sec
!=
NULL
)
{
destroyTableQueryInfo
(((
STableDataInfo
*
)
pair
->
sec
)
->
pTableQInfo
,
pQuery
->
numOfOutput
);
tfree
(
pair
->
sec
);
}
}
taosArrayDestroy
(
p
);
}
if
(
pQuery
->
pGroupbyExpr
!=
NULL
)
{
taosArrayDestroy
(
pQuery
->
pGroupbyExpr
->
columnInfo
);
tfree
(
pQuery
->
pGroupbyExpr
);
}
tfree
(
pQuery
->
tagColList
);
tfree
(
pQuery
->
pFilterInfo
);
tfree
(
pQuery
->
colList
);
tfree
(
pQuery
->
sdata
);
taosArrayDestroy
(
pQInfo
->
groupInfo
.
pGroupList
);
tfree
(
pQuery
);
qTrace
(
"QInfo:%p QInfo is freed"
,
pQInfo
);
// destroy signature, in order to avoid the query process pass the object safety check
...
...
@@ -6036,8 +6053,8 @@ int32_t qCreateQueryInfo(void *tsdb, SQueryTableMsg *pQueryMsg, qinfo_t *pQInfo)
SColIndex
*
pGroupColIndex
=
NULL
;
SColumnInfo
*
pTagColumnInfo
=
NULL
;
if
((
code
=
convertQueryMsg
(
pQueryMsg
,
&
pTableIdList
,
&
pExprMsg
,
&
tagCond
,
&
pGroupColIndex
,
&
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
convertQueryMsg
(
pQueryMsg
,
&
pTableIdList
,
&
pExprMsg
,
&
tagCond
,
&
pGroupColIndex
,
&
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -6096,7 +6113,7 @@ int32_t qCreateQueryInfo(void *tsdb, SQueryTableMsg *pQueryMsg, qinfo_t *pQInfo)
_query_over:
taosArrayDestroy
(
pTableIdList
);
// if failed to add ref for all meters in this query, abort current query
// atomic_fetch_add_32(&vnodeSelectReqNum, 1);
return
TSDB_CODE_SUCCESS
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
7493384d
...
...
@@ -1133,6 +1133,7 @@ static int32_t getAllTableIdList(STsdbRepo* tsdb, int64_t uid, SArray* list) {
taosArrayPush
(
list
,
&
t
);
}
tSkipListDestroyIter
(
iter
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1445,6 +1446,7 @@ int32_t tsdbQueryByTagsCond(TsdbRepoT* tsdb, int64_t uid, const char* pTagCond,
pGroupInfo
->
numOfTables
=
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
);
taosArrayDestroy
(
res
);
return
ret
;
}
...
...
@@ -1463,6 +1465,7 @@ int32_t tsdbQueryByTagsCond(TsdbRepoT* tsdb, int64_t uid, const char* pTagCond,
pGroupInfo
->
numOfTables
=
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
);
taosArrayDestroy
(
res
);
return
ret
;
}
...
...
@@ -1483,6 +1486,7 @@ int32_t tsdbGetOneTableGroup(TsdbRepoT* tsdb, int64_t uid, STableGroupInfo* pGro
return
TSDB_CODE_SUCCESS
;
}
void
tsdbCleanupQueryHandle
(
TsdbQueryHandleT
queryHandle
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
queryHandle
;
if
(
pQueryHandle
==
NULL
)
{
...
...
@@ -1516,5 +1520,6 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
tfree
(
pQueryHandle
->
pDataBlockInfo
);
tsdbDestroyHelper
(
&
pQueryHandle
->
rhelper
);
tfree
(
pQueryHandle
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录