Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cafc5e4c
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看板
提交
cafc5e4c
编写于
11月 22, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: refact fetch message
上级
422735d3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
109 addition
and
34 deletion
+109
-34
include/common/tmsg.h
include/common/tmsg.h
+4
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+55
-0
source/libs/executor/src/exchangeoperator.c
source/libs/executor/src/exchangeoperator.c
+26
-11
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+7
-12
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+17
-10
未找到文件。
include/common/tmsg.h
浏览文件 @
cafc5e4c
...
...
@@ -1629,7 +1629,6 @@ int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq);
int32_t
tDeserializeSSubQueryMsg
(
void
*
buf
,
int32_t
bufLen
,
SSubQueryMsg
*
pReq
);
void
tFreeSSubQueryMsg
(
SSubQueryMsg
*
pReq
);
typedef
struct
{
SMsgHead
header
;
uint64_t
sId
;
...
...
@@ -1667,6 +1666,10 @@ typedef struct {
int32_t
execId
;
}
SResFetchReq
;
int32_t
tSerializeSResFetchReq
(
void
*
buf
,
int32_t
bufLen
,
SResFetchReq
*
pReq
);
int32_t
tDeserializeSResFetchReq
(
void
*
buf
,
int32_t
bufLen
,
SResFetchReq
*
pReq
);
typedef
struct
{
SMsgHead
header
;
uint64_t
sId
;
...
...
source/common/src/tmsg.c
浏览文件 @
cafc5e4c
...
...
@@ -4723,6 +4723,61 @@ void tFreeSSubQueryMsg(SSubQueryMsg *pReq) {
taosMemoryFreeClear
(
pReq
->
msg
);
}
int32_t
tSerializeSResFetchReq
(
void
*
buf
,
int32_t
bufLen
,
SResFetchReq
*
pReq
)
{
int32_t
headLen
=
sizeof
(
SMsgHead
);
if
(
buf
!=
NULL
)
{
buf
=
(
char
*
)
buf
+
headLen
;
bufLen
-=
headLen
;
}
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pReq
->
sId
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pReq
->
queryId
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pReq
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
execId
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
if
(
buf
!=
NULL
)
{
SMsgHead
*
pHead
=
(
SMsgHead
*
)((
char
*
)
buf
-
headLen
);
pHead
->
vgId
=
htonl
(
pReq
->
header
.
vgId
);
pHead
->
contLen
=
htonl
(
tlen
+
headLen
);
}
return
tlen
+
headLen
;
}
int32_t
tDeserializeSResFetchReq
(
void
*
buf
,
int32_t
bufLen
,
SResFetchReq
*
pReq
)
{
int32_t
headLen
=
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
buf
;
pHead
->
vgId
=
pReq
->
header
.
vgId
;
pHead
->
contLen
=
pReq
->
header
.
contLen
;
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
(
char
*
)
buf
+
headLen
,
bufLen
-
headLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pReq
->
sId
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pReq
->
queryId
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pReq
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
execId
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSTqOffsetVal
(
SEncoder
*
pEncoder
,
STqOffsetVal
*
pOffset
)
{
if
(
tEncodeI8
(
pEncoder
,
pOffset
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pOffset
->
uid
)
<
0
)
return
-
1
;
...
...
source/libs/executor/src/exchangeoperator.c
浏览文件 @
cafc5e4c
...
...
@@ -403,27 +403,42 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
loadRemoteDataCallback
(
pWrapper
,
&
pBuf
,
code
);
taosMemoryFree
(
pWrapper
);
}
else
{
SResFetchReq
*
pMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SResFetchReq
));
if
(
NULL
==
pMsg
)
{
SResFetchReq
req
=
{
0
};
req
.
header
.
vgId
=
pSource
->
addr
.
nodeId
;
req
.
sId
=
pSource
->
schedId
;
req
.
taskId
=
pSource
->
taskId
;
req
.
queryId
=
pTaskInfo
->
id
.
queryId
;
req
.
execId
=
pSource
->
execId
;
int32_t
msgSize
=
tSerializeSResFetchReq
(
NULL
,
0
,
&
req
);
if
(
msgSize
<
0
)
{
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
taosMemoryFree
(
pWrapper
);
return
pTaskInfo
->
code
;
}
void
*
msg
=
taosMemoryCalloc
(
1
,
msgSize
);
if
(
NULL
==
msg
)
{
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
taosMemoryFree
(
pWrapper
);
return
pTaskInfo
->
code
;
}
if
(
tSerializeSResFetchReq
(
msg
,
msgSize
,
&
req
)
<
0
)
{
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
taosMemoryFree
(
pWrapper
);
taosMemoryFree
(
msg
);
return
pTaskInfo
->
code
;
}
qDebug
(
"%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%"
PRIx64
", execId:%d, %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
addr
.
epSet
.
eps
[
0
].
fqdn
,
pSource
->
taskId
,
pSource
->
execId
,
sourceIndex
,
totalSources
);
pMsg
->
header
.
vgId
=
htonl
(
pSource
->
addr
.
nodeId
);
pMsg
->
sId
=
htobe64
(
pSource
->
schedId
);
pMsg
->
taskId
=
htobe64
(
pSource
->
taskId
);
pMsg
->
queryId
=
htobe64
(
pTaskInfo
->
id
.
queryId
);
pMsg
->
execId
=
htonl
(
pSource
->
execId
);
// send the fetch remote task result reques
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
NULL
==
pMsgSendInfo
)
{
taosMemoryFreeClear
(
pM
sg
);
taosMemoryFreeClear
(
m
sg
);
taosMemoryFree
(
pWrapper
);
qError
(
"%s prepare message %d failed"
,
GET_TASKID
(
pTaskInfo
),
(
int32_t
)
sizeof
(
SMsgSendInfo
));
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
...
...
@@ -432,8 +447,8 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
pMsgSendInfo
->
param
=
pWrapper
;
pMsgSendInfo
->
paramFreeFp
=
taosMemoryFree
;
pMsgSendInfo
->
msgInfo
.
pData
=
pM
sg
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SResFetchReq
)
;
pMsgSendInfo
->
msgInfo
.
pData
=
m
sg
;
pMsgSendInfo
->
msgInfo
.
len
=
msgSize
;
pMsgSendInfo
->
msgType
=
pSource
->
fetchMsgType
;
pMsgSendInfo
->
fp
=
loadRemoteDataCallback
;
...
...
source/libs/qworker/src/qwMsg.c
浏览文件 @
cafc5e4c
...
...
@@ -499,27 +499,22 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
SResFetchReq
*
msg
=
pMsg
->
pCont
;
SResFetchReq
req
=
{
0
}
;
SQWorker
*
mgmt
=
(
SQWorker
*
)
qWorkerMgmt
;
qwUpdateTimeInQueue
(
mgmt
,
ts
,
FETCH_QUEUE
);
QW_STAT_INC
(
mgmt
->
stat
.
msgStat
.
fetchProcessed
,
1
);
if
(
NULL
==
msg
||
pMsg
->
contLen
<
sizeof
(
*
msg
)
)
{
QW_ELOG
(
"
invalid fetch msg, msg:%p, msgLen:%d"
,
msg
,
pMsg
->
contLen
);
if
(
tDeserializeSResFetchReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
QW_ELOG
(
"
tDeserializeSResFetchReq %d failed"
,
pMsg
->
contLen
);
QW_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
msg
->
sId
=
be64toh
(
msg
->
sId
);
msg
->
queryId
=
be64toh
(
msg
->
queryId
);
msg
->
taskId
=
be64toh
(
msg
->
taskId
);
msg
->
execId
=
ntohl
(
msg
->
execId
);
uint64_t
sId
=
msg
->
sId
;
uint64_t
qId
=
msg
->
queryId
;
uint64_t
tId
=
msg
->
taskId
;
uint64_t
sId
=
req
.
sId
;
uint64_t
qId
=
req
.
queryId
;
uint64_t
tId
=
req
.
taskId
;
int64_t
rId
=
0
;
int32_t
eId
=
msg
->
execId
;
int32_t
eId
=
req
.
execId
;
SQWMsg
qwMsg
=
{.
node
=
node
,
.
msg
=
NULL
,
.
msgLen
=
0
,
.
connInfo
=
pMsg
->
info
,
.
msgType
=
pMsg
->
msgType
};
...
...
source/libs/scheduler/src/schRemote.c
浏览文件 @
cafc5e4c
...
...
@@ -1083,22 +1083,29 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
}
case
TDMT_SCH_FETCH
:
case
TDMT_SCH_MERGE_FETCH
:
{
msgSize
=
sizeof
(
SResFetchReq
);
SResFetchReq
req
=
{
0
};
req
.
header
.
vgId
=
addr
->
nodeId
;
req
.
sId
=
schMgmt
.
sId
;
req
.
queryId
=
pJob
->
queryId
;
req
.
taskId
=
pTask
->
taskId
;
req
.
execId
=
pTask
->
execId
;
msgSize
=
tSerializeSResFetchReq
(
NULL
,
0
,
&
req
);
if
(
msgSize
<
0
)
{
SCH_TASK_ELOG
(
"tSerializeSResFetchReq get size, msgSize:%d"
,
msgSize
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
msg
=
taosMemoryCalloc
(
1
,
msgSize
);
if
(
NULL
==
msg
)
{
SCH_TASK_ELOG
(
"calloc %d failed"
,
msgSize
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
SResFetchReq
*
pMsg
=
msg
;
pMsg
->
header
.
vgId
=
htonl
(
addr
->
nodeId
);
pMsg
->
sId
=
htobe64
(
schMgmt
.
sId
);
pMsg
->
queryId
=
htobe64
(
pJob
->
queryId
);
pMsg
->
taskId
=
htobe64
(
pTask
->
taskId
);
pMsg
->
execId
=
htonl
(
pTask
->
execId
);
if
(
tSerializeSResFetchReq
(
msg
,
msgSize
,
&
req
)
<
0
)
{
SCH_TASK_ELOG
(
"tSerializeSResFetchReq %d failed"
,
msgSize
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
break
;
}
case
TDMT_SCH_DROP_TASK
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录