Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f569355d
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f569355d
编写于
10月 08, 2022
作者:
5
54liuyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream):memory leak
上级
13bee74a
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
172 addition
and
34 deletion
+172
-34
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+35
-25
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+15
-6
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+14
-3
tests/script/tsim/stream/distributeIntervalRetrive0.sim
tests/script/tsim/stream/distributeIntervalRetrive0.sim
+40
-0
tests/script/tsim/stream/fillIntervalDelete1.sim
tests/script/tsim/stream/fillIntervalDelete1.sim
+18
-0
tests/script/tsim/stream/fillIntervalLinear.sim
tests/script/tsim/stream/fillIntervalLinear.sim
+18
-0
tests/script/tsim/stream/fillIntervalPrevNext.sim
tests/script/tsim/stream/fillIntervalPrevNext.sim
+17
-0
tests/script/tsim/stream/fillIntervalValue.sim
tests/script/tsim/stream/fillIntervalValue.sim
+15
-0
未找到文件。
source/libs/executor/src/tfill.c
浏览文件 @
f569355d
...
...
@@ -706,6 +706,9 @@ void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) {
pFillSup
->
pAllColInfo
=
destroyFillColumnInfo
(
pFillSup
->
pAllColInfo
,
pFillSup
->
numOfFillCols
,
pFillSup
->
numOfAllCols
);
tSimpleHashCleanup
(
pFillSup
->
pResMap
);
pFillSup
->
pResMap
=
NULL
;
streamStateReleaseBuf
(
NULL
,
NULL
,
pFillSup
->
cur
.
pRowVal
);
pFillSup
->
cur
.
pRowVal
=
NULL
;
taosMemoryFree
(
pFillSup
);
return
NULL
;
}
...
...
@@ -722,6 +725,7 @@ void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) {
taosMemoryFreeClear
(
pFillInfo
->
pResRow
);
}
pFillInfo
->
pLinearInfo
=
destroyStreamFillLinearInfo
(
pFillInfo
->
pLinearInfo
);
taosArrayDestroy
(
pFillInfo
->
delRanges
);
taosMemoryFree
(
pFillInfo
);
return
NULL
;
}
...
...
@@ -732,6 +736,8 @@ void destroyStreamFillOperatorInfo(void* param) {
pInfo
->
pFillSup
=
destroyStreamFillSupporter
(
pInfo
->
pFillSup
);
pInfo
->
pRes
=
blockDataDestroy
(
pInfo
->
pRes
);
pInfo
->
pSrcBlock
=
blockDataDestroy
(
pInfo
->
pSrcBlock
);
pInfo
->
pPrevSrcBlock
=
blockDataDestroy
(
pInfo
->
pPrevSrcBlock
);
pInfo
->
pDelRes
=
blockDataDestroy
(
pInfo
->
pDelRes
);
pInfo
->
pColMatchColInfo
=
taosArrayDestroy
(
pInfo
->
pColMatchColInfo
);
taosMemoryFree
(
pInfo
);
}
...
...
@@ -743,6 +749,7 @@ static void resetFillWindow(SResultRowData* pRowData) {
void
resetPrevAndNextWindow
(
SStreamFillSupporter
*
pFillSup
,
SStreamState
*
pState
)
{
resetFillWindow
(
&
pFillSup
->
prev
);
streamStateReleaseBuf
(
NULL
,
NULL
,
pFillSup
->
cur
.
pRowVal
);
resetFillWindow
(
&
pFillSup
->
cur
);
resetFillWindow
(
&
pFillSup
->
next
);
resetFillWindow
(
&
pFillSup
->
nextNext
);
...
...
@@ -753,12 +760,12 @@ void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupI
resetPrevAndNextWindow
(
pFillSup
,
pState
);
SWinKey
key
=
{.
ts
=
ts
,
.
groupId
=
groupId
};
void
*
curVal
=
NULL
;
//
void* curVal = NULL;
int32_t
curVLen
=
0
;
int32_t
code
=
streamStateFillGet
(
pState
,
&
key
,
(
void
**
)
&
cur
Val
,
&
curVLen
);
int32_t
code
=
streamStateFillGet
(
pState
,
&
key
,
(
void
**
)
&
pFillSup
->
cur
.
pRow
Val
,
&
curVLen
);
ASSERT
(
code
==
TSDB_CODE_SUCCESS
);
pFillSup
->
cur
.
key
=
key
.
ts
;
pFillSup
->
cur
.
pRowVal
=
curVal
;
//
pFillSup->cur.pRowVal = curVal;
}
void
getWindowFromDiscBuf
(
SOperatorInfo
*
pOperator
,
TSKEY
ts
,
uint64_t
groupId
,
SStreamFillSupporter
*
pFillSup
)
{
...
...
@@ -777,11 +784,9 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId,
SWinKey
preKey
=
{.
groupId
=
groupId
};
void
*
preVal
=
NULL
;
int32_t
preVLen
=
0
;
if
(
pCur
)
{
code
=
streamStateGetGroupKVByCur
(
pCur
,
&
preKey
,
(
const
void
**
)
&
preVal
,
&
preVLen
);
}
if
(
pCur
&&
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pFillSup
->
prev
.
key
=
preKey
.
ts
;
pFillSup
->
prev
.
pRowVal
=
preVal
;
...
...
@@ -790,13 +795,14 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId,
code
=
streamStateCurNext
(
pState
,
pCur
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
streamStateFreeCur
(
pCur
);
pCur
=
NULL
;
}
}
else
{
streamStateFreeCur
(
pCur
);
pCur
=
streamStateFillSeekKeyNext
(
pState
,
&
key
);
}
if
(
pCur
)
{
SWinKey
nextKey
=
{.
groupId
=
groupId
};
void
*
nextVal
=
NULL
;
int32_t
nextVLen
=
0
;
...
...
@@ -818,7 +824,7 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId,
}
}
}
}
streamStateFreeCur
(
pCur
);
}
static
bool
hasPrevWindow
(
SStreamFillSupporter
*
pFillSup
)
{
return
pFillSup
->
prev
.
key
!=
INT64_MIN
;
}
...
...
@@ -1388,6 +1394,7 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) {
}
pInfo
->
srcDelRowIndex
++
;
}
streamStateFreeCur
(
pCur
);
doDeleteFillResultImpl
(
pOperator
,
ts
,
endTs
,
groupId
);
}
pFillInfo
->
current
=
pFillInfo
->
end
+
1
;
...
...
@@ -1538,9 +1545,12 @@ static int32_t initResultBuf(SStreamFillSupporter* pFillSup) {
pFillSup
->
next
.
key
=
INT64_MIN
;
pFillSup
->
nextNext
.
key
=
INT64_MIN
;
pFillSup
->
prev
.
key
=
INT64_MIN
;
pFillSup
->
cur
.
key
=
INT64_MIN
;
pFillSup
->
next
.
pRowVal
=
NULL
;
pFillSup
->
nextNext
.
pRowVal
=
NULL
;
pFillSup
->
prev
.
pRowVal
=
NULL
;
pFillSup
->
cur
.
pRowVal
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
f569355d
...
...
@@ -879,8 +879,13 @@ static void removeResults(SArray* pWins, SHashObj* pUpdatedMap) {
int32_t
size
=
taosArrayGetSize
(
pWins
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SWinKey
*
pW
=
taosArrayGet
(
pWins
,
i
);
void
*
tmp
=
taosHashGet
(
pUpdatedMap
,
pW
,
sizeof
(
SWinKey
));
if
(
tmp
)
{
void
*
value
=
*
(
void
**
)
tmp
;
taosMemoryFree
(
value
);
taosHashRemove
(
pUpdatedMap
,
pW
,
sizeof
(
SWinKey
));
}
}
}
int64_t
getWinReskey
(
void
*
data
,
int32_t
index
)
{
...
...
@@ -1410,8 +1415,13 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, int3
taosArrayPush
(
pUpWins
,
&
winRes
);
}
if
(
pUpdatedMap
)
{
void
*
tmp
=
taosHashGet
(
pUpdatedMap
,
&
winRes
,
sizeof
(
SWinKey
));
if
(
tmp
)
{
void
*
value
=
*
(
void
**
)
tmp
;
taosMemoryFree
(
value
);
taosHashRemove
(
pUpdatedMap
,
&
winRes
,
sizeof
(
SWinKey
));
}
}
getNextTimeWindow
(
pInterval
,
pInterval
->
precision
,
TSDB_ORDER_ASC
,
&
win
);
}
while
(
win
.
ekey
<=
endTsCols
[
i
]);
}
...
...
@@ -2872,12 +2882,13 @@ static void rebuildIntervalWindow(SOperatorInfo* pOperator, SExprSupp* pSup, SAr
pChildSup
->
rowEntryInfoOffset
,
&
pChInfo
->
aggSup
);
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
parentWin
,
true
);
compactFunctions
(
pSup
->
pCtx
,
pChildSup
->
pCtx
,
numOfOutput
,
pTaskInfo
,
&
pInfo
->
twAggSup
.
timeWindowData
);
releaseOutputBuf
(
pChInfo
->
pState
,
pWinRes
,
pChResult
);
}
if
(
num
>
0
&&
pUpdatedMap
)
{
saveWinResultInfo
(
pCurResult
->
win
.
skey
,
pWinRes
->
groupId
,
pUpdatedMap
);
saveOutputBuf
(
pInfo
->
pState
,
pWinRes
,
pCurResult
,
pInfo
->
aggSup
.
resultRowSize
);
releaseOutputBuf
(
pInfo
->
pState
,
pWinRes
,
pCurResult
);
}
releaseOutputBuf
(
pInfo
->
pState
,
pWinRes
,
pCurResult
);
}
}
...
...
@@ -2891,9 +2902,7 @@ bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) {
bool
isDeletedStreamWindow
(
STimeWindow
*
pWin
,
uint64_t
groupId
,
SStreamState
*
pState
,
STimeWindowAggSupp
*
pTwSup
)
{
if
(
pWin
->
ekey
<
pTwSup
->
maxTs
-
pTwSup
->
deleteMark
)
{
SWinKey
key
=
{.
ts
=
pWin
->
skey
,
.
groupId
=
groupId
};
void
*
pVal
=
NULL
;
int32_t
size
=
0
;
if
(
streamStateGet
(
pState
,
&
key
,
&
pVal
,
&
size
)
==
TSDB_CODE_SUCCESS
)
{
if
(
streamStateGet
(
pState
,
&
key
,
NULL
,
0
)
==
TSDB_CODE_SUCCESS
)
{
return
false
;
}
return
true
;
...
...
source/libs/stream/src/streamState.c
浏览文件 @
f569355d
...
...
@@ -196,6 +196,7 @@ int32_t streamStateClear(SStreamState* pState) {
SStreamStateCur
*
pCur
=
streamStateSeekKeyNext
(
pState
,
&
key
);
SWinKey
delKey
=
{
0
};
int32_t
code
=
streamStateGetKVByCur
(
pCur
,
&
delKey
,
NULL
,
0
);
streamStateFreeCur
(
pCur
);
if
(
code
==
0
)
{
streamStateDel
(
pState
,
&
delKey
);
}
else
{
...
...
@@ -225,6 +226,9 @@ int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void*
int32_t
streamStateReleaseBuf
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
*
pVal
)
{
// todo refactor
if
(
!
pVal
)
{
return
0
;
}
streamFreeVal
(
pVal
);
return
0
;
}
...
...
@@ -236,7 +240,7 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) {
int32_t
c
;
SStateKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWin
Key
),
&
c
);
tdbTbcMoveTo
(
pCur
->
pCur
,
&
sKey
,
sizeof
(
SState
Key
),
&
c
);
if
(
c
!=
0
)
{
taosMemoryFree
(
pCur
);
return
NULL
;
...
...
@@ -253,7 +257,7 @@ SStreamStateCur* streamStateFillGetCur(SStreamState* pState, const SWinKey* key)
int32_t
c
;
tdbTbcMoveTo
(
pCur
->
pCur
,
key
,
sizeof
(
SWinKey
),
&
c
);
if
(
c
!=
0
)
{
taosMemoryFree
(
pCur
);
streamStateFreeCur
(
pCur
);
return
NULL
;
}
return
pCur
;
...
...
@@ -266,6 +270,7 @@ SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key) {
if
(
code
==
0
)
{
return
pCur
;
}
streamStateFreeCur
(
pCur
);
}
return
NULL
;
}
...
...
@@ -300,6 +305,9 @@ int32_t streamStateFillGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const vo
}
int32_t
streamStateGetGroupKVByCur
(
SStreamStateCur
*
pCur
,
SWinKey
*
pKey
,
const
void
**
pVal
,
int32_t
*
pVLen
)
{
if
(
!
pCur
)
{
return
-
1
;
}
uint64_t
groupId
=
pKey
->
groupId
;
int32_t
code
=
streamStateFillGetKVByCur
(
pCur
,
pKey
,
pVal
,
pVLen
);
if
(
code
==
0
)
{
...
...
@@ -360,7 +368,7 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
SStreamStateCur
*
streamStateFillSeekKeyNext
(
SStreamState
*
pState
,
const
SWinKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
{
if
(
!
pCur
)
{
return
NULL
;
}
if
(
tdbTbcOpen
(
pState
->
pFillStateDb
,
&
pCur
->
pCur
,
NULL
)
<
0
)
{
...
...
@@ -411,6 +419,9 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey*
}
int32_t
streamStateCurNext
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
)
{
if
(
!
pCur
)
{
return
-
1
;
}
//
return
tdbTbcMoveToNext
(
pCur
->
pCur
);
}
...
...
tests/script/tsim/stream/distributeIntervalRetrive0.sim
浏览文件 @
f569355d
...
...
@@ -3,12 +3,15 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 50
sql connect
sql create dnode $hostname2 port 7200
system sh/exec.sh -n dnode2 -s start
#==system sh/exec.sh -n dnode2 -s start -v
print ===== step1
$x = 0
...
...
@@ -232,4 +235,41 @@ endi
print loop3 over
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==system sh/exec.sh -n dnode2 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode2
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
system sh/stop_dnodes.sh
tests/script/tsim/stream/fillIntervalDelete1.sim
浏览文件 @
f569355d
...
...
@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200
sql connect
...
...
@@ -353,6 +355,22 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
sql drop stream if exists streams0;
...
...
tests/script/tsim/stream/fillIntervalLinear.sim
浏览文件 @
f569355d
...
...
@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200
sql connect
...
...
@@ -671,6 +673,22 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
sql drop stream if exists streams0;
...
...
tests/script/tsim/stream/fillIntervalPrevNext.sim
浏览文件 @
f569355d
...
...
@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200
sql connect
...
...
@@ -1011,6 +1013,21 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
...
...
tests/script/tsim/stream/fillIntervalValue.sim
浏览文件 @
f569355d
...
...
@@ -4,6 +4,7 @@ looptest:
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200
sql connect
...
...
@@ -463,6 +464,20 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录