Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
814aa051
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看板
未验证
提交
814aa051
编写于
10月 17, 2022
作者:
L
Liu Jicong
提交者:
GitHub
10月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17403 from taosdata/fix/client_mem_leak
refactor: tmq client
上级
50dfc57c
177fe40e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
20 deletion
+25
-20
include/common/tmsg.h
include/common/tmsg.h
+1
-1
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+24
-19
未找到文件。
include/common/tmsg.h
浏览文件 @
814aa051
...
...
@@ -1902,7 +1902,7 @@ static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
if
(
pRebInfo
==
NULL
)
{
return
NULL
;
}
tstrncpy
(
pRebInfo
->
key
,
key
,
sizeof
(
pRebInfo
->
key
)
);
tstrncpy
(
pRebInfo
->
key
,
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
pRebInfo
->
lostConsumers
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
if
(
pRebInfo
->
lostConsumers
==
NULL
)
{
goto
_err
;
...
...
source/client/src/clientTmq.c
浏览文件 @
814aa051
...
...
@@ -233,12 +233,12 @@ void tmq_conf_destroy(tmq_conf_t* conf) {
tmq_conf_res_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
)
{
if
(
strcmp
(
key
,
"group.id"
)
==
0
)
{
strcpy
(
conf
->
groupId
,
value
);
tstrncpy
(
conf
->
groupId
,
value
,
TSDB_CGROUP_LEN
);
return
TMQ_CONF_OK
;
}
if
(
strcmp
(
key
,
"client.id"
)
==
0
)
{
strcpy
(
conf
->
clientId
,
value
);
tstrncpy
(
conf
->
clientId
,
value
,
256
);
return
TMQ_CONF_OK
;
}
...
...
@@ -452,7 +452,6 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
int32_t
code
;
tEncodeSize
(
tEncodeSTqOffset
,
pOffset
,
len
,
code
);
if
(
code
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
void
*
buf
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgHead
)
+
len
);
...
...
@@ -464,15 +463,22 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
SEncoder
encoder
;
tEncoderInit
(
&
encoder
,
abuf
,
len
);
tEncodeSTqOffset
(
&
encoder
,
pOffset
);
tEncoderClear
(
&
encoder
);
// build param
SMqCommitCbParam
*
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqCommitCbParam
));
if
(
pParam
==
NULL
)
{
taosMemoryFree
(
buf
);
return
-
1
;
}
pParam
->
params
=
pParamSet
;
pParam
->
pOffset
=
pOffset
;
// build send info
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
pMsgSendInfo
==
NULL
)
{
taosMemoryFree
(
buf
);
taosMemoryFree
(
pParam
);
return
-
1
;
}
pMsgSendInfo
->
msgInfo
=
(
SDataBuf
){
...
...
@@ -547,6 +553,8 @@ int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_comm
if
(
pVg
->
currentOffset
.
type
>
0
&&
!
tOffsetEqual
(
&
pVg
->
currentOffset
,
&
pVg
->
committedOffset
))
{
if
(
tmqSendCommitReq
(
tmq
,
pVg
,
pTopic
,
pParamSet
)
<
0
)
{
tsem_destroy
(
&
pParamSet
->
rspSem
);
taosMemoryFree
(
pParamSet
);
goto
FAIL
;
}
goto
HANDLE_RSP
;
...
...
@@ -565,6 +573,7 @@ HANDLE_RSP:
tsem_wait
(
&
pParamSet
->
rspSem
);
code
=
pParamSet
->
rspErr
;
tsem_destroy
(
&
pParamSet
->
rspSem
);
taosMemoryFree
(
pParamSet
);
return
code
;
}
else
{
code
=
0
;
...
...
@@ -587,7 +596,14 @@ int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t
SMqCommitCbParamSet
*
pParamSet
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqCommitCbParamSet
));
if
(
pParamSet
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
if
(
async
)
{
if
(
automatic
)
{
tmq
->
commitCb
(
tmq
,
code
,
tmq
->
commitCbUserParam
);
}
else
{
userCb
(
tmq
,
code
,
userParam
);
}
}
return
-
1
;
}
...
...
@@ -642,16 +658,6 @@ int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t
code
=
pParamSet
->
rspErr
;
tsem_destroy
(
&
pParamSet
->
rspSem
);
taosMemoryFree
(
pParamSet
);
}
else
{
code
=
0
;
}
if
(
code
!=
0
&&
async
)
{
if
(
automatic
)
{
tmq
->
commitCb
(
tmq
,
code
,
tmq
->
commitCbUserParam
);
}
else
{
userCb
(
tmq
,
code
,
userParam
);
}
}
#if 0
...
...
@@ -722,6 +728,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
SMsgSendInfo
*
sendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
sendInfo
==
NULL
)
{
taosMemoryFree
(
pReq
);
goto
OVER
;
}
sendInfo
->
msgInfo
=
(
SDataBuf
){
.
pData
=
pReq
,
...
...
@@ -871,7 +878,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
tmq_t
*
pTmq
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_t
));
if
(
pTmq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tscError
(
"
consumer setup failed since %s"
,
terrstr
()
);
tscError
(
"
setting up new consumer failed since %s, consumer group %s"
,
terrstr
(),
conf
->
groupId
);
return
NULL
;
}
...
...
@@ -1060,9 +1067,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
code
=
0
;
FAIL:
if
(
req
.
topicNames
!=
NULL
)
taosArrayDestroyP
(
req
.
topicNames
,
taosMemoryFree
);
if
(
code
!=
0
&&
buf
)
{
taosMemoryFree
(
buf
);
}
taosMemoryFree
(
buf
);
return
code
;
}
...
...
@@ -1100,7 +1106,6 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
)
{
SMqPollRspWrapper
*
pRspWrapper
=
taosAllocateQitem
(
sizeof
(
SMqPollRspWrapper
),
DEF_QITEM
);
if
(
pRspWrapper
==
NULL
)
{
taosMemoryFree
(
pMsg
->
pData
);
tscWarn
(
"msg discard from vgId:%d, epoch %d since out of memory"
,
vgId
,
epoch
);
goto
CREATE_MSG_FAIL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录