Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
536e3aeb
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看板
提交
536e3aeb
编写于
12月 27, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
0be19201
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
389 addition
and
271 deletion
+389
-271
include/common/tmsg.h
include/common/tmsg.h
+6
-6
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+17
-3
source/libs/qworker/inc/qworkerInt.h
source/libs/qworker/inc/qworkerInt.h
+23
-5
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+307
-246
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+30
-5
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+1
-1
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+5
-5
未找到文件。
include/common/tmsg.h
浏览文件 @
536e3aeb
...
@@ -1002,7 +1002,7 @@ typedef struct {
...
@@ -1002,7 +1002,7 @@ typedef struct {
}
SUpdateTagValRsp
;
}
SUpdateTagValRsp
;
typedef
struct
SSubQueryMsg
{
typedef
struct
SSubQueryMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
queryId
;
uint64_t
taskId
;
uint64_t
taskId
;
uint32_t
contentLen
;
uint32_t
contentLen
;
...
@@ -1010,7 +1010,7 @@ typedef struct SSubQueryMsg {
...
@@ -1010,7 +1010,7 @@ typedef struct SSubQueryMsg {
}
SSubQueryMsg
;
}
SSubQueryMsg
;
typedef
struct
SResReadyMsg
{
typedef
struct
SResReadyMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
queryId
;
uint64_t
taskId
;
uint64_t
taskId
;
}
SResReadyMsg
;
}
SResReadyMsg
;
...
@@ -1020,13 +1020,13 @@ typedef struct SResReadyRsp {
...
@@ -1020,13 +1020,13 @@ typedef struct SResReadyRsp {
}
SResReadyRsp
;
}
SResReadyRsp
;
typedef
struct
SResFetchMsg
{
typedef
struct
SResFetchMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
queryId
;
uint64_t
taskId
;
uint64_t
taskId
;
}
SResFetchMsg
;
}
SResFetchMsg
;
typedef
struct
SSchTasksStatusMsg
{
typedef
struct
SSchTasksStatusMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
}
SSchTasksStatusMsg
;
}
SSchTasksStatusMsg
;
typedef
struct
STaskStatus
{
typedef
struct
STaskStatus
{
...
@@ -1041,7 +1041,7 @@ typedef struct SSchedulerStatusRsp {
...
@@ -1041,7 +1041,7 @@ typedef struct SSchedulerStatusRsp {
}
SSchedulerStatusRsp
;
}
SSchedulerStatusRsp
;
typedef
struct
STaskCancelMsg
{
typedef
struct
STaskCancelMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
queryId
;
uint64_t
taskId
;
uint64_t
taskId
;
}
STaskCancelMsg
;
}
STaskCancelMsg
;
...
@@ -1051,7 +1051,7 @@ typedef struct STaskCancelRsp {
...
@@ -1051,7 +1051,7 @@ typedef struct STaskCancelRsp {
}
STaskCancelRsp
;
}
STaskCancelRsp
;
typedef
struct
STaskDropMsg
{
typedef
struct
STaskDropMsg
{
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
queryId
;
uint64_t
taskId
;
uint64_t
taskId
;
}
STaskDropMsg
;
}
STaskDropMsg
;
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
536e3aeb
...
@@ -22,13 +22,27 @@ int vnodeQueryOpen(SVnode *pVnode) {
...
@@ -22,13 +22,27 @@ int vnodeQueryOpen(SVnode *pVnode) {
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
vInfo
(
"query message is processed"
);
vInfo
(
"query message is processed"
);
qWorkerProcessQueryMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
return
qWorkerProcessQueryMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
return
0
;
}
}
int
vnodeProcessFetchReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeProcessFetchReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
vInfo
(
"fetch message is processed"
);
vInfo
(
"fetch message is processed"
);
qWorkerProcessFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_FETCH
:
return
qWorkerProcessFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_RES_READY
:
return
qWorkerProcessReadyMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_TASKS_STATUS
:
return
qWorkerProcessStatusMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_CANCEL_TASK
:
return
qWorkerProcessCancelMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_DROP_TASK
:
return
qWorkerProcessDropMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in fetch queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
break
;
}
return
0
;
return
0
;
}
}
...
...
source/libs/qworker/inc/qworkerInt.h
浏览文件 @
536e3aeb
...
@@ -42,25 +42,41 @@ enum {
...
@@ -42,25 +42,41 @@ enum {
QW_WRITE
,
QW_WRITE
,
};
};
typedef
struct
SQWorkerTaskStatus
{
enum
{
QW_EXIST_ACQUIRE
=
1
,
QW_EXIST_RET_ERR
,
};
enum
{
QW_NOT_EXIST_RET_ERR
=
1
,
QW_NOT_EXIST_ADD
,
};
enum
{
QW_ADD_RET_ERR
=
1
,
QW_ADD_ACQUIRE
,
};
typedef
struct
SQWTaskStatus
{
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
code
;
int32_t
code
;
int8_t
status
;
int8_t
status
;
int8_t
ready
;
int8_t
ready
;
bool
cancel
;
bool
cancel
;
bool
drop
;
bool
drop
;
}
SQW
orker
TaskStatus
;
}
SQWTaskStatus
;
typedef
struct
SQWorkerResCache
{
typedef
struct
SQWorkerResCache
{
SRWLatch
lock
;
SRWLatch
lock
;
void
*
data
;
void
*
data
;
}
SQWorkerResCache
;
}
SQWorkerResCache
;
typedef
struct
SQW
orker
SchStatus
{
typedef
struct
SQWSchStatus
{
int32_t
lastAccessTs
;
// timestamp in second
int32_t
lastAccessTs
;
// timestamp in second
SRWLatch
tasksLock
;
SRWLatch
tasksLock
;
SHashObj
*
tasksHash
;
// key:queryId+taskId, value: SQWorkerTaskStatus
SHashObj
*
tasksHash
;
// key:queryId+taskId, value: SQWorkerTaskStatus
}
SQW
orker
SchStatus
;
}
SQWSchStatus
;
// Qnode/Vnode level task management
// Qnode/Vnode level task management
typedef
struct
SQWorkerMgmt
{
typedef
struct
SQWorkerMgmt
{
...
@@ -71,7 +87,7 @@ typedef struct SQWorkerMgmt {
...
@@ -71,7 +87,7 @@ typedef struct SQWorkerMgmt {
SHashObj
*
resHash
;
//key: queryId+taskId, value: SQWorkerResCache
SHashObj
*
resHash
;
//key: queryId+taskId, value: SQWorkerResCache
}
SQWorkerMgmt
;
}
SQWorkerMgmt
;
#define QW_GOT_RES_DATA(data) (
fals
e)
#define QW_GOT_RES_DATA(data) (
tru
e)
#define QW_LOW_RES_DATA(data) (false)
#define QW_LOW_RES_DATA(data) (false)
#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code))
#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code))
...
@@ -89,6 +105,8 @@ typedef struct SQWorkerMgmt {
...
@@ -89,6 +105,8 @@ typedef struct SQWorkerMgmt {
#define QW_LOCK(type, _lock) (QW_READ == (type) ? taosRLockLatch(_lock) : taosWLockLatch(_lock))
#define QW_LOCK(type, _lock) (QW_READ == (type) ? taosRLockLatch(_lock) : taosWLockLatch(_lock))
#define QW_UNLOCK(type, _lock) (QW_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock))
#define QW_UNLOCK(type, _lock) (QW_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock))
static
int32_t
qwAcquireScheduler
(
int32_t
rwType
,
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
SQWSchStatus
**
sch
,
int32_t
nOpt
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
536e3aeb
此差异已折叠。
点击以展开。
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
536e3aeb
...
@@ -40,6 +40,11 @@ int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
...
@@ -40,6 +40,11 @@ int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
return
0
;
return
0
;
}
}
void
qwtRpcSendResponse
(
const
SRpcMsg
*
pRsp
)
{
return
;
}
void
stubSetStringToPlan
()
{
void
stubSetStringToPlan
()
{
static
Stub
stub
;
static
Stub
stub
;
...
@@ -54,6 +59,20 @@ void stubSetStringToPlan() {
...
@@ -54,6 +59,20 @@ void stubSetStringToPlan() {
}
}
}
}
void
stubSetRpcSendResponse
()
{
static
Stub
stub
;
stub
.
set
(
rpcSendResponse
,
qwtRpcSendResponse
);
{
AddrAny
any
(
"libplanner.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
any
.
get_global_func_addr_dynsym
(
"^rpcSendResponse$"
,
result
);
for
(
const
auto
&
f
:
result
)
{
stub
.
set
(
f
.
second
,
qwtRpcSendResponse
);
}
}
}
}
}
...
@@ -68,30 +87,35 @@ TEST(testCase, normalCase) {
...
@@ -68,30 +87,35 @@ TEST(testCase, normalCase) {
SRpcMsg
dropRpc
=
{
0
};
SRpcMsg
dropRpc
=
{
0
};
SSubQueryMsg
*
queryMsg
=
(
SSubQueryMsg
*
)
calloc
(
1
,
sizeof
(
SSubQueryMsg
)
+
100
);
SSubQueryMsg
*
queryMsg
=
(
SSubQueryMsg
*
)
calloc
(
1
,
sizeof
(
SSubQueryMsg
)
+
100
);
queryMsg
->
queryId
=
htobe64
(
1
);
queryMsg
->
queryId
=
htobe64
(
1
);
queryMsg
->
s
cheduler
Id
=
htobe64
(
1
);
queryMsg
->
sId
=
htobe64
(
1
);
queryMsg
->
taskId
=
htobe64
(
1
);
queryMsg
->
taskId
=
htobe64
(
1
);
queryMsg
->
contentLen
=
htonl
(
100
);
queryMsg
->
contentLen
=
htonl
(
100
);
queryRpc
.
pCont
=
queryMsg
;
queryRpc
.
pCont
=
queryMsg
;
queryRpc
.
contLen
=
sizeof
(
SSubQueryMsg
)
+
100
;
SResReadyMsg
readyMsg
=
{
0
};
SResReadyMsg
readyMsg
=
{
0
};
readyMsg
.
s
cheduler
Id
=
htobe64
(
1
);
readyMsg
.
sId
=
htobe64
(
1
);
readyMsg
.
queryId
=
htobe64
(
1
);
readyMsg
.
queryId
=
htobe64
(
1
);
readyMsg
.
taskId
=
htobe64
(
1
);
readyMsg
.
taskId
=
htobe64
(
1
);
readyRpc
.
pCont
=
&
readyMsg
;
readyRpc
.
pCont
=
&
readyMsg
;
readyRpc
.
contLen
=
sizeof
(
SResReadyMsg
);
SResFetchMsg
fetchMsg
=
{
0
};
SResFetchMsg
fetchMsg
=
{
0
};
fetchMsg
.
s
cheduler
Id
=
htobe64
(
1
);
fetchMsg
.
sId
=
htobe64
(
1
);
fetchMsg
.
queryId
=
htobe64
(
1
);
fetchMsg
.
queryId
=
htobe64
(
1
);
fetchMsg
.
taskId
=
htobe64
(
1
);
fetchMsg
.
taskId
=
htobe64
(
1
);
fetchRpc
.
pCont
=
&
fetchMsg
;
fetchRpc
.
pCont
=
&
fetchMsg
;
fetchRpc
.
contLen
=
sizeof
(
SResFetchMsg
);
STaskDropMsg
dropMsg
=
{
0
};
STaskDropMsg
dropMsg
=
{
0
};
dropMsg
.
s
cheduler
Id
=
htobe64
(
1
);
dropMsg
.
sId
=
htobe64
(
1
);
dropMsg
.
queryId
=
htobe64
(
1
);
dropMsg
.
queryId
=
htobe64
(
1
);
dropMsg
.
taskId
=
htobe64
(
1
);
dropMsg
.
taskId
=
htobe64
(
1
);
dropRpc
.
pCont
=
&
dropMsg
;
dropRpc
.
pCont
=
&
dropMsg
;
dropRpc
.
contLen
=
sizeof
(
STaskDropMsg
);
stubSetStringToPlan
();
stubSetStringToPlan
();
stubSetRpcSendResponse
();
code
=
qWorkerInit
(
NULL
,
&
mgmt
);
code
=
qWorkerInit
(
NULL
,
&
mgmt
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
@@ -107,7 +131,8 @@ TEST(testCase, normalCase) {
...
@@ -107,7 +131,8 @@ TEST(testCase, normalCase) {
code
=
qWorkerProcessDropMsg
(
mockPointer
,
mgmt
,
&
dropRpc
);
code
=
qWorkerProcessDropMsg
(
mockPointer
,
mgmt
,
&
dropRpc
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
qWorkerDestroy
(
&
mgmt
);
}
}
...
...
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
536e3aeb
...
@@ -38,7 +38,7 @@ enum {
...
@@ -38,7 +38,7 @@ enum {
typedef
struct
SSchedulerMgmt
{
typedef
struct
SSchedulerMgmt
{
uint64_t
taskId
;
uint64_t
taskId
;
uint64_t
s
cheduler
Id
;
uint64_t
sId
;
SSchedulerCfg
cfg
;
SSchedulerCfg
cfg
;
SHashObj
*
jobs
;
// key: queryId, value: SQueryJob*
SHashObj
*
jobs
;
// key: queryId, value: SQueryJob*
}
SSchedulerMgmt
;
}
SSchedulerMgmt
;
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
536e3aeb
...
@@ -343,7 +343,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
...
@@ -343,7 +343,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
SSubQueryMsg
*
pMsg
=
msg
;
SSubQueryMsg
*
pMsg
=
msg
;
pMsg
->
s
chedulerId
=
htobe64
(
schMgmt
.
scheduler
Id
);
pMsg
->
s
Id
=
htobe64
(
schMgmt
.
s
Id
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
pMsg
->
contentLen
=
htonl
(
task
->
msgLen
);
pMsg
->
contentLen
=
htonl
(
task
->
msgLen
);
...
@@ -359,7 +359,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
...
@@ -359,7 +359,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
}
}
SResReadyMsg
*
pMsg
=
msg
;
SResReadyMsg
*
pMsg
=
msg
;
pMsg
->
s
chedulerId
=
htobe64
(
schMgmt
.
scheduler
Id
);
pMsg
->
s
Id
=
htobe64
(
schMgmt
.
s
Id
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
break
;
break
;
...
@@ -376,7 +376,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
...
@@ -376,7 +376,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
}
}
SResFetchMsg
*
pMsg
=
msg
;
SResFetchMsg
*
pMsg
=
msg
;
pMsg
->
s
chedulerId
=
htobe64
(
schMgmt
.
scheduler
Id
);
pMsg
->
s
Id
=
htobe64
(
schMgmt
.
s
Id
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
break
;
break
;
...
@@ -390,7 +390,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
...
@@ -390,7 +390,7 @@ int32_t schAsyncSendMsg(SSchJob *job, SSchTask *task, int32_t msgType) {
}
}
STaskDropMsg
*
pMsg
=
msg
;
STaskDropMsg
*
pMsg
=
msg
;
pMsg
->
s
chedulerId
=
htobe64
(
schMgmt
.
scheduler
Id
);
pMsg
->
s
Id
=
htobe64
(
schMgmt
.
s
Id
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
queryId
=
htobe64
(
job
->
queryId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
pMsg
->
taskId
=
htobe64
(
task
->
taskId
);
break
;
break
;
...
@@ -717,7 +717,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
...
@@ -717,7 +717,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) {
SCH_ERR_LRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
,
"init %d schduler jobs failed"
,
schMgmt
.
cfg
.
maxJobNum
);
SCH_ERR_LRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
,
"init %d schduler jobs failed"
,
schMgmt
.
cfg
.
maxJobNum
);
}
}
schMgmt
.
s
cheduler
Id
=
1
;
//TODO GENERATE A UUID
schMgmt
.
sId
=
1
;
//TODO GENERATE A UUID
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录