Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e31d9299
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看板
未验证
提交
e31d9299
编写于
5月 26, 2023
作者:
H
Haojun Liao
提交者:
GitHub
5月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21480 from taosdata/mark/sml
fix:memory leak
上级
c7886d31
208ba2ef
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
75 addition
and
47 deletion
+75
-47
source/client/inc/clientSml.h
source/client/inc/clientSml.h
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-0
source/client/src/clientSml.c
source/client/src/clientSml.c
+39
-31
source/client/src/clientSmlJson.c
source/client/src/clientSmlJson.c
+13
-3
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+9
-1
source/client/src/clientSmlTelnet.c
source/client/src/clientSmlTelnet.c
+5
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+4
-7
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+1
-1
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+2
-2
未找到文件。
source/client/inc/clientSml.h
浏览文件 @
e31d9299
...
...
@@ -251,7 +251,7 @@ int32_t smlClearForRerun(SSmlHandle *info);
int32_t
smlParseValue
(
SSmlKv
*
pVal
,
SSmlMsgBuf
*
msg
);
uint8_t
smlGetTimestampLen
(
int64_t
num
);
void
clearColValArray
(
SArray
*
pCols
);
void
smlDestroyTableInfo
(
SSmlHandle
*
info
,
SSmlTableInfo
*
tag
);
void
smlDestroyTableInfo
(
void
*
para
);
void
freeSSmlKv
(
void
*
data
);
int32_t
smlParseInfluxString
(
SSmlHandle
*
info
,
char
*
sql
,
char
*
sqlEnd
,
SSmlLineInfo
*
elements
);
...
...
source/client/src/clientImpl.c
浏览文件 @
e31d9299
...
...
@@ -1757,6 +1757,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
return
TSDB_CODE_TSC_INTERNAL_ERROR
;
}
taosMemoryFreeClear
(
pResultInfo
->
convertJson
);
pResultInfo
->
convertJson
=
taosMemoryCalloc
(
1
,
dataLen
);
if
(
pResultInfo
->
convertJson
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
char
*
p1
=
pResultInfo
->
convertJson
;
...
...
source/client/src/clientSml.c
浏览文件 @
e31d9299
...
...
@@ -230,6 +230,16 @@ void getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tin
}
}
static
void
smlDestroySTableMeta
(
void
*
para
)
{
SSmlSTableMeta
*
meta
=
*
(
SSmlSTableMeta
**
)
para
;
taosHashCleanup
(
meta
->
tagHash
);
taosHashCleanup
(
meta
->
colHash
);
taosArrayDestroy
(
meta
->
tags
);
taosArrayDestroy
(
meta
->
cols
);
taosMemoryFreeClear
(
meta
->
tableMeta
);
taosMemoryFree
(
meta
);
}
SSmlSTableMeta
*
smlBuildSTableMeta
(
bool
isDataFormat
)
{
SSmlSTableMeta
*
meta
=
(
SSmlSTableMeta
*
)
taosMemoryCalloc
(
sizeof
(
SSmlSTableMeta
),
1
);
if
(
!
meta
)
{
...
...
@@ -264,7 +274,7 @@ SSmlSTableMeta *smlBuildSTableMeta(bool isDataFormat) {
return
meta
;
cleanup:
taosMemoryFree
(
meta
);
smlDestroySTableMeta
(
meta
);
return
NULL
;
}
...
...
@@ -1035,6 +1045,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
}
}
taosMemoryFreeClear
(
sTableData
->
tableMeta
);
sTableData
->
tableMeta
=
pTableMeta
;
uDebug
(
"SML:0x%"
PRIx64
"modify schema uid:%"
PRIu64
", sversion:%d, tversion:%d"
,
info
->
id
,
pTableMeta
->
uid
,
pTableMeta
->
sversion
,
pTableMeta
->
tversion
)
tmp
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
tmp
);
...
...
@@ -1093,15 +1104,6 @@ static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols) {
}
}
static
void
smlDestroySTableMeta
(
SSmlSTableMeta
*
meta
)
{
taosHashCleanup
(
meta
->
tagHash
);
taosHashCleanup
(
meta
->
colHash
);
taosArrayDestroy
(
meta
->
tags
);
taosArrayDestroy
(
meta
->
cols
);
taosMemoryFree
(
meta
->
tableMeta
);
taosMemoryFree
(
meta
);
}
static
int32_t
smlUpdateMeta
(
SHashObj
*
metaHash
,
SArray
*
metaArray
,
SArray
*
cols
,
bool
isTag
,
SSmlMsgBuf
*
msg
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
i
);
...
...
@@ -1141,7 +1143,8 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
return
TSDB_CODE_SUCCESS
;
}
void
smlDestroyTableInfo
(
SSmlHandle
*
info
,
SSmlTableInfo
*
tag
)
{
void
smlDestroyTableInfo
(
void
*
para
)
{
SSmlTableInfo
*
tag
=
*
(
SSmlTableInfo
**
)
para
;
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
tag
->
cols
);
i
++
)
{
SHashObj
*
kvHash
=
(
SHashObj
*
)
taosArrayGetP
(
tag
->
cols
,
i
);
taosHashCleanup
(
kvHash
);
...
...
@@ -1178,18 +1181,18 @@ void smlDestroyInfo(SSmlHandle *info) {
qDestroyQuery
(
info
->
pQuery
);
// destroy info->childTables
SSmlTableInfo
**
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
NULL
);
while
(
oneTable
)
{
smlDestroyTableInfo
(
info
,
*
oneTable
);
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
);
}
//
SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL);
//
while (oneTable) {
// smlDestroyTableInfo(
oneTable);
//
oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable);
//
}
// destroy info->superTables
SSmlSTableMeta
**
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
while
(
oneSTable
)
{
smlDestroySTableMeta
(
*
oneSTable
);
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
oneSTable
);
}
//
SSmlSTableMeta **oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL);
//
while (oneSTable) {
//
smlDestroySTableMeta(*oneSTable);
//
oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, oneSTable);
//
}
// destroy info->pVgHash
taosHashCleanup
(
info
->
pVgHash
);
...
...
@@ -1248,6 +1251,8 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
info
->
childTables
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
info
->
tableUids
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
info
->
superTables
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
taosHashSetFreeFp
(
info
->
superTables
,
smlDestroySTableMeta
);
taosHashSetFreeFp
(
info
->
childTables
,
smlDestroyTableInfo
);
info
->
id
=
smlGenId
();
info
->
pQuery
=
smlInitHandle
();
...
...
@@ -1354,6 +1359,9 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
uDebug
(
"SML:0x%"
PRIx64
" smlParseLineBottom add meta, format:%d, linenum:%d"
,
info
->
id
,
info
->
dataFormat
,
info
->
lineNum
);
SSmlSTableMeta
*
meta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
if
(
meta
==
NULL
){
return
TSDB_CODE_OUT_OF_MEMORY
;
}
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
meta
,
POINTER_BYTES
);
terrno
=
0
;
smlInsertMeta
(
meta
->
tagHash
,
meta
->
tags
,
tinfo
->
tags
);
...
...
@@ -1473,18 +1481,18 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
int32_t
smlClearForRerun
(
SSmlHandle
*
info
)
{
info
->
reRun
=
false
;
// clear info->childTables
SSmlTableInfo
**
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
NULL
);
while
(
oneTable
)
{
smlDestroyTableInfo
(
info
,
*
oneTable
);
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
);
}
//
SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL);
//
while (oneTable) {
//
smlDestroyTableInfo(info, *oneTable);
//
oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable);
//
}
// clear info->superTables
SSmlSTableMeta
**
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
NULL
);
while
(
oneSTable
)
{
smlDestroySTableMeta
(
*
oneSTable
);
oneSTable
=
(
SSmlSTableMeta
**
)
taosHashIterate
(
info
->
superTables
,
oneSTable
);
}
//
SSmlSTableMeta **oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL);
//
while (oneSTable) {
//
smlDestroySTableMeta(*oneSTable);
//
oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, oneSTable);
//
}
taosHashClear
(
info
->
childTables
);
taosHashClear
(
info
->
superTables
);
...
...
source/client/src/clientSmlJson.c
浏览文件 @
e31d9299
...
...
@@ -695,6 +695,10 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
return
TSDB_CODE_SUCCESS
;
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
if
(
sMeta
==
NULL
){
taosMemoryFreeClear
(
pTableMeta
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
sMeta
->
tableMeta
=
pTableMeta
;
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
for
(
int
i
=
pTableMeta
->
tableInfo
.
numOfColumns
;
i
<
pTableMeta
->
tableInfo
.
numOfTags
+
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
){
...
...
@@ -784,7 +788,7 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
tinfo
->
tableDataCtx
=
smlInitTableDataCtx
(
info
->
pQuery
,
info
->
currSTableMeta
);
if
(
tinfo
->
tableDataCtx
==
NULL
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlInitTableDataCtx error"
,
NULL
);
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyTableInfo
(
&
tinfo
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
}
...
...
@@ -1048,12 +1052,18 @@ static int32_t smlParseJSONExt(SSmlHandle *info, char *payload) {
return
TSDB_CODE_TSC_INVALID_JSON
;
}
info
->
lineNum
=
payloadNum
;
info
->
dataFormat
=
true
;
if
(
unlikely
(
info
->
lines
!=
NULL
))
{
for
(
int
i
=
0
;
i
<
info
->
lineNum
;
i
++
)
{
taosArrayDestroyEx
(
info
->
lines
[
i
].
colArray
,
freeSSmlKv
);
if
(
info
->
lines
[
i
].
measureTagsLen
!=
0
)
taosMemoryFree
(
info
->
lines
[
i
].
measureTag
);
}
taosMemoryFree
(
info
->
lines
);
info
->
lines
=
NULL
;
}
info
->
lineNum
=
payloadNum
;
info
->
dataFormat
=
true
;
ret
=
smlClearForRerun
(
info
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
...
...
source/client/src/clientSmlLine.c
浏览文件 @
e31d9299
...
...
@@ -168,6 +168,10 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
TSDB_CODE_SUCCESS
;
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
if
(
sMeta
==
NULL
){
taosMemoryFreeClear
(
pTableMeta
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
sMeta
->
tableMeta
=
pTableMeta
;
taosHashPut
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
for
(
int
i
=
pTableMeta
->
tableInfo
.
numOfColumns
;
...
...
@@ -326,7 +330,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
info
->
currSTableMeta
->
uid
=
tinfo
->
uid
;
tinfo
->
tableDataCtx
=
smlInitTableDataCtx
(
info
->
pQuery
,
info
->
currSTableMeta
);
if
(
tinfo
->
tableDataCtx
==
NULL
)
{
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyTableInfo
(
&
tinfo
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlInitTableDataCtx error"
,
NULL
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
...
...
@@ -372,6 +376,10 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
return
TSDB_CODE_SUCCESS
;
}
*
tmp
=
smlBuildSTableMeta
(
info
->
dataFormat
);
if
(
*
tmp
==
NULL
){
taosMemoryFreeClear
(
pTableMeta
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
tmp
)
->
tableMeta
=
pTableMeta
;
taosHashPut
(
info
->
superTables
,
currElement
->
measure
,
currElement
->
measureLen
,
tmp
,
POINTER_BYTES
);
...
...
source/client/src/clientSmlTelnet.c
浏览文件 @
e31d9299
...
...
@@ -91,6 +91,10 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
return
TSDB_CODE_SUCCESS
;
}
sMeta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
if
(
sMeta
==
NULL
){
taosMemoryFreeClear
(
pTableMeta
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
sMeta
->
tableMeta
=
pTableMeta
;
taosHashPut
(
info
->
superTables
,
elements
->
measure
,
elements
->
measureLen
,
&
sMeta
,
POINTER_BYTES
);
for
(
int
i
=
pTableMeta
->
tableInfo
.
numOfColumns
;
i
<
pTableMeta
->
tableInfo
.
numOfTags
+
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
){
...
...
@@ -212,7 +216,7 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
tinfo
->
tableDataCtx
=
smlInitTableDataCtx
(
info
->
pQuery
,
info
->
currSTableMeta
);
if
(
tinfo
->
tableDataCtx
==
NULL
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlInitTableDataCtx error"
,
NULL
);
smlDestroyTableInfo
(
info
,
tinfo
);
smlDestroyTableInfo
(
&
tinfo
);
return
TSDB_CODE_SML_INVALID_DATA
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e31d9299
...
...
@@ -8008,6 +8008,9 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
if
(
pTagSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
isJson
=
true
;
code
=
buildJsonTagVal
(
pCxt
,
pTagSchema
,
pVal
,
pTagArray
,
ppTag
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pVal
);
}
taosArrayPush
(
tagName
,
pTagSchema
->
name
);
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
&&
!
pVal
->
isNull
)
{
char
*
tmpVal
=
nodesGetValueFromNode
(
pVal
);
...
...
@@ -8328,13 +8331,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
SArray
*
pTagVals
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
int32_t
code
=
TSDB_CODE_SUCCESS
;
STag
*
pTag
=
NULL
;
do
{
code
=
parseJsontoTagData
(
pStmt
->
pVal
->
literal
,
pTagVals
,
&
pTag
,
&
pCxt
->
msgBuf
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
while
(
0
);
code
=
parseJsontoTagData
(
pStmt
->
pVal
->
literal
,
pTagVals
,
&
pTag
,
&
pCxt
->
msgBuf
);
taosArrayDestroy
(
pTagVals
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
e31d9299
...
...
@@ -416,7 +416,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
end:
taosHashCleanup
(
keyHash
);
if
(
retCode
==
TSDB_CODE_SUCCESS
)
{
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
retCode
=
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
++
i
)
{
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
...
...
tests/parallel_test/cases.task
浏览文件 @
e31d9299
...
...
@@ -571,7 +571,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_replica.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py
#
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_json_taosc_insert.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_muti_insert_query.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/test_stmt_set_tbname_tag.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_stable.py
...
...
@@ -1089,7 +1089,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/timetruncate.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/diff.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Timediff.py -Q 4
#
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/json_tag.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/json_tag.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/top.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/bottom.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/percentile.py -Q 4
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录