Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
86e3d838
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
86e3d838
编写于
3月 16, 2023
作者:
H
Haojun Liao
提交者:
GitHub
3月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20495 from taosdata/fix/liaohj
fix(tmq): adjust the time out value check.
上级
7af1d00d
08ac1021
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
34 deletion
+43
-34
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+17
-14
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+26
-20
未找到文件。
source/client/inc/clientInt.h
浏览文件 @
86e3d838
...
...
@@ -287,22 +287,25 @@ static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
}
static
FORCE_INLINE
SReqResultInfo
*
tmqGetNextResInfo
(
TAOS_RES
*
res
,
bool
convertUcs4
)
{
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
msg
->
resIter
++
;
if
(
msg
->
resIter
<
msg
->
rsp
.
blockNum
)
{
SRetrieveTableRsp
*
pRetrieve
=
(
SRetrieveTableRsp
*
)
taosArrayGetP
(
msg
->
rsp
.
blockData
,
msg
->
resIter
);
if
(
msg
->
rsp
.
withSchema
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosArrayGetP
(
msg
->
rsp
.
blockSchema
,
msg
->
resIter
);
setResSchemaInfo
(
&
msg
->
resInfo
,
pSW
->
pSchema
,
pSW
->
nCols
);
taosMemoryFreeClear
(
msg
->
resInfo
.
row
);
taosMemoryFreeClear
(
msg
->
resInfo
.
pCol
);
taosMemoryFreeClear
(
msg
->
resInfo
.
length
);
taosMemoryFreeClear
(
msg
->
resInfo
.
convertBuf
);
taosMemoryFreeClear
(
msg
->
resInfo
.
convertJson
);
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
pRspObj
->
resIter
++
;
if
(
pRspObj
->
resIter
<
pRspObj
->
rsp
.
blockNum
)
{
SRetrieveTableRsp
*
pRetrieve
=
(
SRetrieveTableRsp
*
)
taosArrayGetP
(
pRspObj
->
rsp
.
blockData
,
pRspObj
->
resIter
);
if
(
pRspObj
->
rsp
.
withSchema
)
{
SSchemaWrapper
*
pSW
=
(
SSchemaWrapper
*
)
taosArrayGetP
(
pRspObj
->
rsp
.
blockSchema
,
pRspObj
->
resIter
);
setResSchemaInfo
(
&
pRspObj
->
resInfo
,
pSW
->
pSchema
,
pSW
->
nCols
);
taosMemoryFreeClear
(
pRspObj
->
resInfo
.
row
);
taosMemoryFreeClear
(
pRspObj
->
resInfo
.
pCol
);
taosMemoryFreeClear
(
pRspObj
->
resInfo
.
length
);
taosMemoryFreeClear
(
pRspObj
->
resInfo
.
convertBuf
);
taosMemoryFreeClear
(
pRspObj
->
resInfo
.
convertJson
);
}
setQueryResultFromRsp
(
&
msg
->
resInfo
,
pRetrieve
,
convertUcs4
,
false
);
return
&
msg
->
resInfo
;
setQueryResultFromRsp
(
&
pRspObj
->
resInfo
,
pRetrieve
,
convertUcs4
,
false
);
return
&
pRspObj
->
resInfo
;
}
return
NULL
;
}
...
...
source/client/src/clientTmq.c
浏览文件 @
86e3d838
...
...
@@ -25,6 +25,7 @@
#include "ttimer.h"
#define EMPTY_BLOCK_POLL_IDLE_DURATION 100
#define DEFAULT_AUTO_COMMIT_INTERVAL 5000
struct
SMqMgmt
{
int8_t
inited
;
...
...
@@ -220,7 +221,7 @@ tmq_conf_t* tmq_conf_new() {
conf
->
withTbName
=
false
;
conf
->
autoCommit
=
true
;
conf
->
autoCommitInterval
=
5000
;
conf
->
autoCommitInterval
=
DEFAULT_AUTO_COMMIT_INTERVAL
;
conf
->
resetOffset
=
TMQ_OFFSET__RESET_EARLIEAST
;
conf
->
hbBgEnable
=
true
;
...
...
@@ -266,7 +267,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
}
if
(
strcasecmp
(
key
,
"auto.commit.interval.ms"
)
==
0
)
{
conf
->
autoCommitInterval
=
atoi
(
value
);
conf
->
autoCommitInterval
=
taosStr2int64
(
value
);
return
TMQ_CONF_OK
;
}
...
...
@@ -310,7 +311,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
}
if
(
strcasecmp
(
key
,
"experimental.snapshot.batch.size"
)
==
0
)
{
conf
->
snapBatchSize
=
atoi
(
value
);
conf
->
snapBatchSize
=
taosStr2int64
(
value
);
return
TMQ_CONF_OK
;
}
...
...
@@ -330,18 +331,22 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
conf
->
ip
=
taosStrdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcasecmp
(
key
,
"td.connect.user"
)
==
0
)
{
conf
->
user
=
taosStrdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcasecmp
(
key
,
"td.connect.pass"
)
==
0
)
{
conf
->
pass
=
taosStrdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcasecmp
(
key
,
"td.connect.port"
)
==
0
)
{
conf
->
port
=
atoi
(
value
);
conf
->
port
=
taosStr2int64
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcasecmp
(
key
,
"td.connect.db"
)
==
0
)
{
return
TMQ_CONF_OK
;
}
...
...
@@ -463,8 +468,8 @@ static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicN
pOffset
->
subKey
[
groupLen
]
=
TMQ_SEPARATOR
;
strcpy
(
pOffset
->
subKey
+
groupLen
+
1
,
pTopicName
);
int32_t
len
;
int32_t
code
;
int32_t
len
=
0
;
int32_t
code
=
0
;
tEncodeSize
(
tEncodeSTqOffset
,
pOffset
,
len
,
code
);
if
(
code
<
0
)
{
return
-
1
;
...
...
@@ -624,7 +629,7 @@ FAIL:
return
0
;
}
static
int32_t
tmqCommitConsumerImpl
(
tmq_t
*
tmq
,
int8_t
automatic
,
int8_t
async
,
tmq_commit_cb
*
userCb
,
static
int32_t
doAutoCommit
(
tmq_t
*
tmq
,
int8_t
automatic
,
int8_t
async
,
tmq_commit_cb
*
userCb
,
void
*
userParam
)
{
int32_t
code
=
-
1
;
...
...
@@ -717,31 +722,29 @@ static int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic,
if
(
msg
)
{
// user invoked commit
return
tmqCommitMsgImpl
(
tmq
,
msg
,
async
,
userCb
,
userParam
);
}
else
{
// this for auto commit
return
tmqCommitConsumerImpl
(
tmq
,
automatic
,
async
,
userCb
,
userParam
);
return
doAutoCommit
(
tmq
,
automatic
,
async
,
userCb
,
userParam
);
}
}
void
tmqAssignAskEpTask
(
void
*
param
,
void
*
tmrId
)
{
int64_t
refId
=
*
(
int64_t
*
)
param
;
tmq_t
*
tmq
=
taosAcquireRef
(
tmqMgmt
.
rsetId
,
refId
);
static
void
generateTimedTask
(
int64_t
refId
,
int32_t
type
)
{
tmq_t
*
tmq
=
taosAcquireRef
(
tmqMgmt
.
rsetId
,
refId
);
if
(
tmq
!=
NULL
)
{
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
),
DEF_QITEM
,
0
);
*
pTaskType
=
TMQ_DELAYED_TASK__ASK_EP
;
*
pTaskType
=
type
;
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
tsem_post
(
&
tmq
->
rspSem
);
}
}
void
tmqAssignAskEpTask
(
void
*
param
,
void
*
tmrId
)
{
int64_t
refId
=
*
(
int64_t
*
)
param
;
generateTimedTask
(
refId
,
TMQ_DELAYED_TASK__ASK_EP
);
taosMemoryFree
(
param
);
}
void
tmqAssignDelayedCommitTask
(
void
*
param
,
void
*
tmrId
)
{
int64_t
refId
=
*
(
int64_t
*
)
param
;
tmq_t
*
tmq
=
taosAcquireRef
(
tmqMgmt
.
rsetId
,
refId
);
if
(
tmq
!=
NULL
)
{
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
),
DEF_QITEM
,
0
);
*
pTaskType
=
TMQ_DELAYED_TASK__COMMIT
;
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
tsem_post
(
&
tmq
->
rspSem
);
}
generateTimedTask
(
refId
,
TMQ_DELAYED_TASK__COMMIT
);
taosMemoryFree
(
param
);
}
...
...
@@ -1579,14 +1582,17 @@ SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
SMqRspObj
*
tmqBuildRspFromWrapper
(
SMqPollRspWrapper
*
pWrapper
)
{
SMqRspObj
*
pRspObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqRspObj
));
pRspObj
->
resType
=
RES_TYPE__TMQ
;
tstrncpy
(
pRspObj
->
topic
,
pWrapper
->
topicHandle
->
topicName
,
TSDB_TOPIC_FNAME_LEN
);
tstrncpy
(
pRspObj
->
db
,
pWrapper
->
topicHandle
->
db
,
TSDB_DB_FNAME_LEN
);
pRspObj
->
vgId
=
pWrapper
->
vgHandle
->
vgId
;
pRspObj
->
resIter
=
-
1
;
memcpy
(
&
pRspObj
->
rsp
,
&
pWrapper
->
dataRsp
,
sizeof
(
SMqDataRsp
));
pRspObj
->
resInfo
.
totalRows
=
0
;
pRspObj
->
resInfo
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
if
(
!
pWrapper
->
dataRsp
.
withSchema
)
{
setResSchemaInfo
(
&
pRspObj
->
resInfo
,
pWrapper
->
topicHandle
->
schema
.
pSchema
,
pWrapper
->
topicHandle
->
schema
.
nCols
);
}
...
...
@@ -1943,7 +1949,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
return
NULL
;
}
if
(
timeout
!=
-
1
)
{
if
(
timeout
>=
0
)
{
int64_t
currentTime
=
taosGetTimestampMs
();
int64_t
elapsedTime
=
currentTime
-
startTime
;
if
(
elapsedTime
>
timeout
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录