Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6f12bc10
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
6f12bc10
编写于
4月 11, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
abd60582
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
59 addition
and
32 deletion
+59
-32
include/libs/command/command.h
include/libs/command/command.h
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+4
-4
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+3
-3
source/client/src/clientHb.c
source/client/src/clientHb.c
+5
-11
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-3
source/libs/command/inc/commandInt.h
source/libs/command/inc/commandInt.h
+10
-4
source/libs/command/src/explain.c
source/libs/command/src/explain.c
+27
-3
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+6
-3
未找到文件。
include/libs/command/command.h
浏览文件 @
6f12bc10
...
...
@@ -22,7 +22,7 @@ typedef struct SExplainCtx SExplainCtx;
int32_t
qExecCommand
(
SNode
*
pStmt
,
SRetrieveTableRsp
**
pRsp
);
int32_t
qExecStaticExplain
(
SQueryPlan
*
pDag
,
SRetrieveTableRsp
**
pRsp
);
int32_t
qExecExplainBegin
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
,
int
32
_t
startTs
);
int32_t
qExecExplainBegin
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
,
int
64
_t
startTs
);
int32_t
qExecExplainEnd
(
SExplainCtx
*
pCtx
,
SRetrieveTableRsp
**
pRsp
);
int32_t
qExplainUpdateExecInfo
(
SExplainCtx
*
pCtx
,
SExplainRsp
*
pRspMsg
,
int32_t
groupId
,
SRetrieveTableRsp
**
pRsp
);
void
qExplainFreeCtx
(
SExplainCtx
*
pCtx
);
...
...
source/client/inc/clientInt.h
浏览文件 @
6f12bc10
...
...
@@ -84,10 +84,10 @@ typedef struct {
}
SClientHbMgr
;
typedef
struct
SQueryExecMetric
{
int64_t
start
;
// start timestamp
int64_t
parsed
;
// start to parse
int64_t
send
;
// start to send to server
int64_t
rsp
;
// receive response from server
int64_t
start
;
// start timestamp
, us
int64_t
parsed
;
// start to parse
, us
int64_t
send
;
// start to send to server
, us
int64_t
rsp
;
// receive response from server
, us
}
SQueryExecMetric
;
typedef
struct
SInstanceSummary
{
...
...
source/client/src/clientEnv.c
浏览文件 @
6f12bc10
...
...
@@ -65,10 +65,10 @@ static void deregisterRequest(SRequestObj *pRequest) {
int32_t
currentInst
=
atomic_sub_fetch_64
(
&
pActivity
->
currentRequests
,
1
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
int64_t
duration
=
taosGetTimestamp
M
s
()
-
pRequest
->
metric
.
start
;
int64_t
duration
=
taosGetTimestamp
U
s
()
-
pRequest
->
metric
.
start
;
tscDebug
(
"0x%"
PRIx64
" free Request from connObj: 0x%"
PRIx64
", reqId:0x%"
PRIx64
" elapsed:%"
PRIu64
" ms, current:%d, app current:%d"
,
pRequest
->
self
,
pTscObj
->
id
,
pRequest
->
requestId
,
duration
,
num
,
currentInst
);
pRequest
->
self
,
pTscObj
->
id
,
pRequest
->
requestId
,
duration
/
1000
,
num
,
currentInst
);
taosReleaseRef
(
clientConnRefPool
,
pTscObj
->
id
);
}
...
...
@@ -151,7 +151,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
pRequest
->
pDb
=
getDbOfConnection
(
pObj
);
pRequest
->
requestId
=
generateRequestId
();
pRequest
->
metric
.
start
=
taosGetTimestamp
M
s
();
pRequest
->
metric
.
start
=
taosGetTimestamp
U
s
();
pRequest
->
type
=
type
;
pRequest
->
pTscObj
=
pObj
;
...
...
source/client/src/clientHb.c
浏览文件 @
6f12bc10
...
...
@@ -435,11 +435,11 @@ static int32_t hbCreateThread() {
taosThreadAttrInit
(
&
thAttr
);
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
//
if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) {
//
terrno = TAOS_SYSTEM_ERROR(errno);
//
return -1;
//
}
//
taosThreadAttrDestroy(&thAttr);
if
(
taosThreadCreate
(
&
clientHbMgr
.
thread
,
&
thAttr
,
hbThreadFunc
,
NULL
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
taosThreadAttrDestroy
(
&
thAttr
);
return
0
;
}
...
...
@@ -500,8 +500,6 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
}
void
appHbMgrCleanup
(
void
)
{
taosThreadMutexLock
(
&
clientHbMgr
.
lock
);
int
sz
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SAppHbMgr
*
pTarget
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
...
...
@@ -510,8 +508,6 @@ void appHbMgrCleanup(void) {
taosHashCleanup
(
pTarget
->
connInfo
);
pTarget
->
connInfo
=
NULL
;
}
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
}
int
hbMgrInit
()
{
...
...
@@ -532,7 +528,6 @@ int hbMgrInit() {
}
void
hbMgrCleanUp
()
{
#if 0
hbStopThread
();
// destroy all appHbMgr
...
...
@@ -545,7 +540,6 @@ void hbMgrCleanUp() {
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
clientHbMgr
.
appHbMgrs
=
NULL
;
#endif
}
int
hbRegisterConnImpl
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
SHbConnInfo
*
info
)
{
...
...
source/client/src/clientImpl.c
浏览文件 @
6f12bc10
...
...
@@ -520,7 +520,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosAcquireRef
(
clientReqRefPool
,
pSendInfo
->
requestObjRefId
);
assert
(
pRequest
->
self
==
pSendInfo
->
requestObjRefId
);
pRequest
->
metric
.
rsp
=
taosGetTimestamp
M
s
();
pRequest
->
metric
.
rsp
=
taosGetTimestamp
U
s
();
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
if
(
pEpSet
)
{
...
...
@@ -536,10 +536,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
int32_t
elapsed
=
pRequest
->
metric
.
rsp
-
pRequest
->
metric
.
start
;
if
(
pMsg
->
code
==
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"0x%"
PRIx64
" message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%"
PRIx64
,
pRequest
->
self
,
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
,
pRequest
->
requestId
);
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
/
1000
,
pRequest
->
requestId
);
}
else
{
tscError
(
"0x%"
PRIx64
" SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%"
PRIx64
,
pRequest
->
self
,
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
,
pRequest
->
requestId
);
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
,
elapsed
/
1000
,
pRequest
->
requestId
);
}
taosReleaseRef
(
clientReqRefPool
,
pSendInfo
->
requestObjRefId
);
...
...
source/libs/command/inc/commandInt.h
浏览文件 @
6f12bc10
...
...
@@ -44,6 +44,9 @@ extern "C" {
#define EXPLAIN_OUTPUT_FORMAT "Output: "
#define EXPLAIN_TIME_WINDOWS_FORMAT "Time Window: interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c"
#define EXPLAIN_WINDOW_FORMAT "Window: gap=%" PRId64
#define EXPLAIN_RATIO_TIME_FORMAT "Ratio: %f"
#define EXPLAIN_PLANNING_TIME_FORMAT "Planning Time: %.3f ms"
#define EXPLAIN_EXEC_TIME_FORMAT "Execution Time: %.3f ms"
//append area
#define EXPLAIN_LEFT_PARENTHESIS_FORMAT " ("
...
...
@@ -108,16 +111,19 @@ typedef struct SExplainCtx {
#define EXPLAIN_ROW_NEW(level, ...) \
do { \
if (isVerboseLine) { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE
- VARSTR_HEADER_SIZE
, "%*s", (level) * 2 + 3, ""); \
} else { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE
- VARSTR_HEADER_SIZE
, "%*s%s", (level) * 2, "", "-> "); \
} \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE -
VARSTR_HEADER_SIZE -
tlen, __VA_ARGS__); \
} while (0)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE -
VARSTR_HEADER_SIZE -
tlen, __VA_ARGS__)
#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0)
#define EXPLAIN_SUM_ROW_NEW(...) tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, __VA_ARGS__)
#define EXPLAIN_SUM_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; } while (0)
#ifdef __cplusplus
}
#endif
...
...
source/libs/command/src/explain.c
浏览文件 @
6f12bc10
...
...
@@ -894,10 +894,34 @@ _return:
QRY_RET
(
code
);
}
int32_t
qExplainAppendPlanRows
(
SExplainCtx
*
pCtx
)
{
if
(
EXPLAIN_MODE_ANALYZE
!=
pCtx
->
mode
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
tlen
=
0
;
char
*
tbuf
=
pCtx
->
tbuf
;
EXPLAIN_SUM_ROW_NEW
(
EXPLAIN_RATIO_TIME_FORMAT
,
pCtx
->
ratio
);
EXPLAIN_SUM_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
pCtx
,
tbuf
,
tlen
,
0
));
EXPLAIN_SUM_ROW_NEW
(
EXPLAIN_PLANNING_TIME_FORMAT
,
(
double
)(
pCtx
->
jobStartTs
-
pCtx
->
reqStartTs
)
/
1000
.
0
);
EXPLAIN_SUM_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
pCtx
,
tbuf
,
tlen
,
0
));
EXPLAIN_SUM_ROW_NEW
(
EXPLAIN_EXEC_TIME_FORMAT
,
(
double
)(
pCtx
->
jobDoneTs
-
pCtx
->
jobStartTs
)
/
1000
.
0
);
EXPLAIN_SUM_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
pCtx
,
tbuf
,
tlen
,
0
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
qExplainGenerateRsp
(
SExplainCtx
*
pCtx
,
SRetrieveTableRsp
**
pRsp
)
{
QRY_ERR_RET
(
qExplainAppendGroupResRows
(
pCtx
,
pCtx
->
rootGroupId
,
0
));
QRY_ERR_RET
(
qExplainAppendPlanRows
(
pCtx
));
QRY_ERR_RET
(
qExplainGetRspFromCtx
(
pCtx
,
pRsp
));
return
TSDB_CODE_SUCCESS
;
...
...
@@ -977,18 +1001,18 @@ _return:
QRY_RET
(
code
);
}
int32_t
qExecExplainBegin
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
,
int
32
_t
startTs
)
{
int32_t
qExecExplainBegin
(
SQueryPlan
*
pDag
,
SExplainCtx
**
pCtx
,
int
64
_t
startTs
)
{
QRY_ERR_RET
(
qExplainPrepareCtx
(
pDag
,
pCtx
));
(
*
pCtx
)
->
reqStartTs
=
startTs
;
(
*
pCtx
)
->
jobStartTs
=
taosGetTimestamp
M
s
();
(
*
pCtx
)
->
jobStartTs
=
taosGetTimestamp
U
s
();
return
TSDB_CODE_SUCCESS
;
}
int32_t
qExecExplainEnd
(
SExplainCtx
*
pCtx
,
SRetrieveTableRsp
**
pRsp
)
{
int32_t
code
=
0
;
pCtx
->
jobDoneTs
=
taosGetTimestamp
M
s
();
pCtx
->
jobDoneTs
=
taosGetTimestamp
U
s
();
atomic_store_8
((
int8_t
*
)
&
pCtx
->
execDone
,
true
);
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
6f12bc10
...
...
@@ -207,7 +207,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
CHECK_RAW_EXPR_NODE
(
pNode
);
SRawExprNode
*
pRawExpr
=
(
SRawExprNode
*
)
pNode
;
SNode
*
pExpr
=
pRawExpr
->
pNode
;
if
(
nodesIsExprNode
(
pExpr
))
{
strncpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
pRawExpr
->
p
,
pRawExpr
->
n
);
}
taosMemoryFreeClear
(
pNode
);
return
pExpr
;
}
...
...
@@ -498,8 +500,9 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p
if
(
NULL
==
pNode
||
!
pCxt
->
valid
)
{
return
pNode
;
}
uint32_t
maxLen
=
sizeof
(((
SExprNode
*
)
pNode
)
->
aliasName
);
strncpy
(((
SExprNode
*
)
pNode
)
->
aliasName
,
pAlias
->
z
,
pAlias
->
n
>
maxLen
?
maxLen
:
pAlias
->
n
);
int32_t
len
=
TMIN
(
sizeof
(((
SExprNode
*
)
pNode
)
->
aliasName
)
-
1
,
pAlias
->
n
);
strncpy
(((
SExprNode
*
)
pNode
)
->
aliasName
,
pAlias
->
z
,
len
);
((
SExprNode
*
)
pNode
)
->
aliasName
[
len
]
=
'\0'
;
return
pNode
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录