Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5cf4edac
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看板
提交
5cf4edac
编写于
1月 12, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
0a281a4f
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
383 addition
and
139 deletion
+383
-139
include/common/tmsg.h
include/common/tmsg.h
+7
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+2
-0
include/libs/qworker/qworker.h
include/libs/qworker/qworker.h
+17
-2
source/dnode/vnode/impl/inc/vnodeQuery.h
source/dnode/vnode/impl/inc/vnodeQuery.h
+1
-0
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+14
-3
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+4
-2
source/libs/qworker/inc/qworkerInt.h
source/libs/qworker/inc/qworkerInt.h
+52
-24
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+277
-104
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+9
-4
未找到文件。
include/common/tmsg.h
浏览文件 @
5cf4edac
...
...
@@ -993,6 +993,13 @@ typedef struct {
uint64_t
taskId
;
}
SSinkDataReq
;
typedef
struct
{
SMsgHead
header
;
uint64_t
sId
;
uint64_t
queryId
;
uint64_t
taskId
;
}
SQueryContinueReq
;
typedef
struct
{
SMsgHead
header
;
...
...
include/common/tmsgdef.h
浏览文件 @
5cf4edac
...
...
@@ -170,6 +170,8 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TOPIC
,
"vnode-drop-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SHOW_TABLES
,
"vnode-show-tables"
,
SVShowTablesReq
,
SVShowTablesRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SHOW_TABLES_FETCH
,
"vnode-show-tables-fetch"
,
SVShowTablesFetchReq
,
SVShowTablesFetchRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_QUERY_CONTINUE
,
"vnode-query-continue"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SCHEDULE_DATA_SINK
,
"vnode-schedule-data-sink"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBSCRIBE
,
"vnode-subscribe"
,
SMVSubscribeReq
,
SMVSubscribeRsp
)
...
...
include/libs/qworker/qworker.h
浏览文件 @
5cf4edac
...
...
@@ -22,9 +22,18 @@ extern "C" {
#include "trpc.h"
enum
{
NODE_TYPE_VNODE
=
1
,
NODE_TYPE_QNODE
,
NODE_TYPE_SNODE
,
};
typedef
struct
SQWorkerCfg
{
uint32_t
maxSchedulerNum
;
uint32_t
max
ResCache
Num
;
uint32_t
max
Task
Num
;
uint32_t
maxSchTaskNum
;
}
SQWorkerCfg
;
...
...
@@ -39,11 +48,17 @@ typedef struct {
uint64_t
numOfErrors
;
}
SQWorkerStat
;
typedef
int32_t
(
*
putReqToQueryQFp
)(
void
*
,
struct
SRpcMsg
*
);
int32_t
qWorkerInit
(
SQWorkerCfg
*
cfg
,
void
**
qWorkerMgmt
);
int32_t
qWorkerInit
(
int8_t
nodeType
,
int32_t
nodeId
,
SQWorkerCfg
*
cfg
,
void
**
qWorkerMgmt
,
void
*
nodeObj
,
putReqToQueryQFp
fp
);
int32_t
qWorkerProcessQueryMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerProcessQueryContinueMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerProcessDataSinkMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerProcessReadyMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerProcessStatusMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/vnode/impl/inc/vnodeQuery.h
浏览文件 @
5cf4edac
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "vnodeInt.h"
#include "qworker.h"
typedef
struct
SQWorkerMgmt
SQHandle
;
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
5cf4edac
...
...
@@ -19,11 +19,22 @@
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
N
ULL
,
&
pVnode
->
pQuery
);
}
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
N
ODE_TYPE_VNODE
,
pVnode
->
vgId
,
NULL
,
&
pVnode
->
pQuery
,
pVnode
,
vnodePutReqToVQueryQ
);
}
int
vnodeProcessQueryReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
vTrace
(
"query message is processed"
);
return
qWorkerProcessQueryMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
vTrace
(
"query message is processing"
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_QUERY
:
return
qWorkerProcessQueryMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_QUERY_CONTINUE
:
return
qWorkerProcessQueryContinueMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_SCHEDULE_DATA_SINK
:
return
qWorkerProcessDataSinkMsg
(
pVnode
->
pTsdb
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
}
}
int
vnodeProcessFetchReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
5cf4edac
...
...
@@ -178,8 +178,10 @@ int32_t qExecTask(qTaskInfo_t tinfo, DataSinkHandle* handle) {
publishOperatorProfEvent
(
pTaskInfo
->
pRoot
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
int64_t
st
=
0
;
*
handle
=
pTaskInfo
->
dsHandle
;
if
(
handle
)
{
*
handle
=
pTaskInfo
->
dsHandle
;
}
while
(
1
)
{
st
=
taosGetTimestampUs
();
SSDataBlock
*
pRes
=
pTaskInfo
->
pRoot
->
exec
(
pTaskInfo
->
pRoot
,
&
newgroup
);
...
...
source/libs/qworker/inc/qworkerInt.h
浏览文件 @
5cf4edac
...
...
@@ -23,7 +23,7 @@ extern "C" {
#include "tlockfree.h"
#define QWORKER_DEFAULT_SCHEDULER_NUMBER 10000
#define QWORKER_DEFAULT_
RES_CACHE
_NUMBER 10000
#define QWORKER_DEFAULT_
TASK
_NUMBER 10000
#define QWORKER_DEFAULT_SCH_TASK_NUMBER 10000
enum
{
...
...
@@ -57,7 +57,6 @@ enum {
QW_ADD_ACQUIRE
,
};
typedef
struct
SQWTaskStatus
{
SRWLatch
lock
;
int32_t
code
;
...
...
@@ -67,12 +66,14 @@ typedef struct SQWTaskStatus {
bool
drop
;
}
SQWTaskStatus
;
typedef
struct
SQW
orkerTaskHandlesCache
{
typedef
struct
SQW
TaskCtx
{
SRWLatch
lock
;
int8_t
sinkScheduled
;
int8_t
queryScheduled
;
bool
needRsp
;
qTaskInfo_t
taskHandle
;
DataSinkHandle
sinkHandle
;
}
SQW
orkerTaskHandlesCache
;
}
SQW
TaskCtx
;
typedef
struct
SQWSchStatus
{
int32_t
lastAccessTs
;
// timestamp in second
...
...
@@ -82,11 +83,15 @@ typedef struct SQWSchStatus {
// Qnode/Vnode level task management
typedef
struct
SQWorkerMgmt
{
SQWorkerCfg
cfg
;
SRWLatch
schLock
;
SRWLatch
resLock
;
SHashObj
*
schHash
;
//key: schedulerId, value: SQWSchStatus
SHashObj
*
resHash
;
//key: queryId+taskId, value: SQWorkerResCache
SQWorkerCfg
cfg
;
int8_t
nodeType
;
int32_t
nodeId
;
SRWLatch
schLock
;
SRWLatch
ctxLock
;
SHashObj
*
schHash
;
//key: schedulerId, value: SQWSchStatus
SHashObj
*
ctxHash
;
//key: queryId+taskId, value: SQWTaskCtx
void
*
nodeObj
;
putReqToQueryQFp
putToQueueFp
;
}
SQWorkerMgmt
;
#define QW_GOT_RES_DATA(data) (true)
...
...
@@ -95,40 +100,63 @@ typedef struct SQWorkerMgmt {
#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code))
#define QW_TASK_ALREADY_EXIST(code) (TSDB_CODE_QRY_TASK_ALREADY_EXIST == (code))
#define QW_TASK_READY_RESP(status) (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || status == JOB_TASK_STATUS_PARTIAL_SUCCEED)
#define QW_SET_QTID(id, q
id, tid) do { *(uint64_t *)(id) = (qid); *(uint64_t *)((char *)(id) + sizeof(qid)) = (ti
d); } while (0)
#define QW_GET_QTID(id, q
id, tid) do { (qid) = *(uint64_t *)(id); (tid) = *(uint64_t *)((char *)(id) + sizeof(qi
d)); } while (0)
#define QW_SET_QTID(id, q
Id, tId) do { *(uint64_t *)(id) = (qId); *(uint64_t *)((char *)(id) + sizeof(qId)) = (tI
d); } while (0)
#define QW_GET_QTID(id, q
Id, tId) do { (qId) = *(uint64_t *)(id); (tId) = *(uint64_t *)((char *)(id) + sizeof(qI
d)); } while (0)
#define QW_IDS() sId, qId, tId
#define QW_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define QW_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define QW_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { qError(__VA_ARGS__); terrno = _code; return _code; } } while (0)
#define QW_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#define QW_ELOG(param, ...) qError("QW:%p " param, mgmt, __VA_ARGS__)
#define QW_DLOG(param, ...) qDebug("QW:%p " param, mgmt, __VA_ARGS__)
#define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%"PRIx64 param, mgmt, sId, __VA_ARGS__)
#define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%"PRIx64 param, mgmt, sId, __VA_ARGS__)
#define QW_TASK_ELOG(param, ...) qError("QW:%p SID:%"PRIx64",QID:%"PRIx64",TID:%"PRIx64 param, mgmt, sId, qId, tId, __VA_ARGS__)
#define QW_TASK_WLOG(param, ...) qWarn("QW:%p SID:%"PRIx64",QID:%"PRIx64",TID:%"PRIx64 param, mgmt, sId, qId, tId, __VA_ARGS__)
#define QW_TASK_DLOG(param, ...) qDebug("QW:%p SID:%"PRIx64",QID:%"PRIx64",TID:%"PRIx64 param, mgmt, sId, qId, tId, __VA_ARGS__)
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
#define QW_LOCK(type, _lock) do { \
if (QW_READ == (type)) { \
if ((*(_lock)) < 0) assert(0); \
taosRLockLatch(_lock); \
qDebug("QW RLOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
assert(atomic_load_32((_lock)) >= 0); \
qDebug("QW RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
taosRLockLatch(_lock); \
qDebug("QW RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
assert(atomic_load_32((_lock)) > 0); \
} else { \
if ((*(_lock)) < 0) assert(0); \
assert(atomic_load_32((_lock)) >= 0); \
qDebug("QW WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
taosWLockLatch(_lock); \
qDebug("QW WLOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
qDebug("QW WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
} \
} while (0)
#define QW_UNLOCK(type, _lock) do { \
if (QW_READ == (type)) { \
if ((*(_lock)) <= 0) assert(0); \
assert(atomic_load_32((_lock)) > 0); \
qDebug("QW RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
taosRUnLockLatch(_lock); \
qDebug("QW RULOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
qDebug("QW RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
assert(atomic_load_32((_lock)) >= 0); \
} else { \
if ((*(_lock)) <= 0) assert(0); \
assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
qDebug("QW WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
taosWUnLockLatch(_lock); \
qDebug("QW WULOCK%p, %s:%d", (_lock), __FILE__, __LINE__); \
qDebug("QW WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \
assert(atomic_load_32((_lock)) >= 0); \
} \
} while (0)
static
int32_t
qwAcquireScheduler
(
int32_t
rwType
,
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
SQWSchStatus
**
sch
,
int32_t
nOpt
);
static
int32_t
qwAcquireScheduler
(
int32_t
rwType
,
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
SQWSchStatus
**
sch
);
static
int32_t
qwAddAcquireScheduler
(
int32_t
rwType
,
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
SQWSchStatus
**
sch
);
#ifdef __cplusplus
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
5cf4edac
此差异已折叠。
点击以展开。
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
5cf4edac
...
...
@@ -42,6 +42,11 @@ int32_t qwtStringToPlan(const char* str, SSubplan** subplan) {
return
0
;
}
int32_t
qwtPutReqToQueue
(
void
*
node
,
struct
SRpcMsg
*
pMsg
)
{
return
0
;
}
void
qwtRpcSendResponse
(
const
SRpcMsg
*
pRsp
)
{
if
(
TDMT_VND_TASKS_STATUS_RSP
==
pRsp
->
msgType
)
{
SSchedulerStatusRsp
*
rsp
=
(
SSchedulerStatusRsp
*
)
pRsp
->
pCont
;
...
...
@@ -258,7 +263,7 @@ TEST(seqTest, normalCase) {
stubSetStringToPlan
();
stubSetRpcSendResponse
();
code
=
qWorkerInit
(
N
ULL
,
&
mgmt
);
code
=
qWorkerInit
(
N
ODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
mockPointer
,
qwtPutReqToQueue
);
ASSERT_EQ
(
code
,
0
);
statusMsg
.
sId
=
htobe64
(
1
);
...
...
@@ -328,7 +333,7 @@ TEST(seqTest, cancelFirst) {
stubSetStringToPlan
();
stubSetRpcSendResponse
();
code
=
qWorkerInit
(
N
ULL
,
&
mgmt
);
code
=
qWorkerInit
(
N
ODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
mockPointer
,
qwtPutReqToQueue
);
ASSERT_EQ
(
code
,
0
);
statusMsg
.
sId
=
htobe64
(
1
);
...
...
@@ -402,7 +407,7 @@ TEST(seqTest, randCase) {
srand
(
time
(
NULL
));
code
=
qWorkerInit
(
N
ULL
,
&
mgmt
);
code
=
qWorkerInit
(
N
ODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
mockPointer
,
qwtPutReqToQueue
);
ASSERT_EQ
(
code
,
0
);
int32_t
t
=
0
;
...
...
@@ -446,7 +451,7 @@ TEST(seqTest, multithreadRand) {
srand
(
time
(
NULL
));
code
=
qWorkerInit
(
N
ULL
,
&
mgmt
);
code
=
qWorkerInit
(
N
ODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
mockPointer
,
qwtPutReqToQueue
);
ASSERT_EQ
(
code
,
0
);
pthread_attr_t
thattr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录