Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e1881185
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e1881185
编写于
8月 06, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into refact/tsdb_last
上级
3324f4e5
d556d929
变更
48
展开全部
隐藏空白更改
内联
并排
Showing
48 changed file
with
1755 addition
and
380 deletion
+1755
-380
.gitignore
.gitignore
+1
-0
cmake/taostools_CMakeLists.txt.in
cmake/taostools_CMakeLists.txt.in
+1
-1
cmake/taosws_CMakeLists.txt.in
cmake/taosws_CMakeLists.txt.in
+1
-1
docs/zh/28-releases.md
docs/zh/28-releases.md
+9
-0
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+7
-2
include/libs/executor/executor.h
include/libs/executor/executor.h
+1
-1
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+13
-8
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+14
-5
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+40
-10
source/common/src/systable.c
source/common/src/systable.c
+3
-3
source/dnode/mnode/impl/src/mndQuery.c
source/dnode/mnode/impl/src/mndQuery.c
+6
-0
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+2
-0
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+6
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+50
-5
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+578
-110
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+248
-2
source/libs/catalog/src/ctgRemote.c
source/libs/catalog/src/ctgRemote.c
+156
-71
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+230
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+4
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+3
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+81
-11
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+6
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+40
-18
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+87
-15
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+4
-4
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+28
-15
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+1
-0
source/libs/parser/test/parInsertTest.cpp
source/libs/parser/test/parInsertTest.cpp
+10
-3
source/libs/parser/test/parTestUtil.cpp
source/libs/parser/test/parTestUtil.cpp
+8
-3
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+5
-2
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+2
-0
source/libs/qworker/inc/qwMsg.h
source/libs/qworker/inc/qwMsg.h
+1
-1
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+6
-3
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+4
-1
source/libs/scheduler/src/schStatus.c
source/libs/scheduler/src/schStatus.c
+1
-1
source/libs/scheduler/src/schTask.c
source/libs/scheduler/src/schTask.c
+3
-1
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+4
-3
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+1
-0
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+1
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+77
-72
source/os/src/osSocket.c
source/os/src/osSocket.c
+3
-3
source/util/src/terror.c
source/util/src/terror.c
+1
-0
tests/parallel_test/run_case.sh
tests/parallel_test/run_case.sh
+2
-0
tests/parallel_test/run_container.sh
tests/parallel_test/run_container.sh
+1
-0
未找到文件。
.gitignore
浏览文件 @
e1881185
...
...
@@ -118,3 +118,4 @@ contrib/*
!contrib/test
sql
debug*/
.env
\ No newline at end of file
cmake/taostools_CMakeLists.txt.in
浏览文件 @
e1881185
...
...
@@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG
8a5e336
GIT_TAG
3c7dafe
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
...
...
cmake/taosws_CMakeLists.txt.in
浏览文件 @
e1881185
...
...
@@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
GIT_TAG
648cc62
GIT_TAG
29424d5
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
...
...
docs/zh/28-releases.md
0 → 100644
浏览文件 @
e1881185
---
sidebar_label
:
发布历史
title
:
发布历史
---
import Release from "/components/Release";
<Release
versionPrefix=
"3.0"
/>
include/common/tmsg.h
浏览文件 @
e1881185
...
...
@@ -3055,6 +3055,7 @@ int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
int32_t
tDecodeDeleteRes
(
SDecoder
*
pCoder
,
SDeleteRes
*
pRes
);
typedef
struct
{
int32_t
msgIdx
;
int32_t
msgType
;
int32_t
msgLen
;
void
*
msg
;
...
...
@@ -3068,6 +3069,7 @@ typedef struct {
typedef
struct
{
int32_t
reqType
;
int32_t
msgIdx
;
int32_t
msgLen
;
int32_t
rspCode
;
void
*
msg
;
...
...
include/libs/catalog/catalog.h
浏览文件 @
e1881185
...
...
@@ -58,12 +58,17 @@ typedef struct SDbInfo {
int64_t
dbId
;
}
SDbInfo
;
typedef
struct
STablesReq
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
SArray
*
pTables
;
}
STablesReq
;
typedef
struct
SCatalogReq
{
SArray
*
pDbVgroup
;
// element is db full name
SArray
*
pDbCfg
;
// element is db full name
SArray
*
pDbInfo
;
// element is db full name
SArray
*
pTableMeta
;
// element is S
NAME
SArray
*
pTableHash
;
// element is S
NAME
SArray
*
pTableMeta
;
// element is S
TablesReq
SArray
*
pTableHash
;
// element is S
TablesReq
SArray
*
pUdf
;
// element is udf name
SArray
*
pIndex
;
// element is index name
SArray
*
pUser
;
// element is SUserAuthInfo
...
...
include/libs/executor/executor.h
浏览文件 @
e1881185
...
...
@@ -103,7 +103,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
* @return
*/
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
struct
SSubplan
*
pPlan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
c
onst
c
har
*
sql
,
EOPTR_EXEC_MODEL
model
);
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
char
*
sql
,
EOPTR_EXEC_MODEL
model
);
/**
*
...
...
include/libs/transport/trpc.h
浏览文件 @
e1881185
...
...
@@ -41,12 +41,13 @@ typedef struct {
typedef
struct
SRpcHandleInfo
{
// rpc info
void
*
handle
;
// rpc handle returned to app
int64_t
refId
;
// refid, used by server
int32_t
noResp
;
// has response or not(default 0, 0: resp, 1: no resp);
int32_t
persistHandle
;
// persist handle or not
void
*
handle
;
// rpc handle returned to app
int64_t
refId
;
// refid, used by server
int8_t
noResp
;
// has response or not(default 0, 0: resp, 1: no resp)
int8_t
persistHandle
;
// persist handle or not
int8_t
hasEpSet
;
STraceId
traceId
;
int8_t
hasEpSet
;
// app info
void
*
ahandle
;
// app handle set by client
...
...
@@ -69,8 +70,9 @@ typedef struct SRpcMsg {
SRpcHandleInfo
info
;
}
SRpcMsg
;
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
rf
);
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
epset
);
typedef
bool
(
*
RpcRfp
)(
int32_t
code
,
tmsg_t
msgType
);
typedef
bool
(
*
RpcTfp
)(
int32_t
code
,
tmsg_t
msgType
);
typedef
struct
SRpcInit
{
char
localFqdn
[
TSDB_FQDN_LEN
];
...
...
@@ -84,12 +86,15 @@ typedef struct SRpcInit {
// the following is for client app ecurity only
char
*
user
;
// user name
// call back to process incoming msg
, code shall be ignored by server app
// call back to process incoming msg
RpcCfp
cfp
;
//
user defined retry func
//
retry not not for particular msg
RpcRfp
rfp
;
// set up timeout for particular msg
RpcTfp
tfp
;
void
*
parent
;
}
SRpcInit
;
...
...
include/util/taoserror.h
浏览文件 @
e1881185
...
...
@@ -46,6 +46,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015)
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017)
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018)
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019)
//common & util
#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013)
...
...
source/client/src/clientEnv.c
浏览文件 @
e1881185
...
...
@@ -60,7 +60,7 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
}
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
const
static
int64_t
SLOW_QUERY_INTERVAL
=
3000000L
;
// todo configurable
const
static
int64_t
SLOW_QUERY_INTERVAL
=
3000000L
;
// todo configurable
assert
(
pRequest
!=
NULL
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
...
...
@@ -77,13 +77,13 @@ static void deregisterRequest(SRequestObj *pRequest) {
if
(
QUERY_NODE_VNODE_MODIF_STMT
==
pRequest
->
stmtType
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
insertElapsedTime
,
duration
);
}
else
if
(
QUERY_NODE_SELECT_STMT
==
pRequest
->
stmtType
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
queryElapsedTime
,
duration
);
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
queryElapsedTime
,
duration
);
}
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
}
releaseTscObj
(
pTscObj
->
id
);
}
...
...
@@ -109,6 +109,14 @@ static bool clientRpcRfp(int32_t code, tmsg_t msgType) {
}
}
// start timer for particular msgType
static
bool
clientRpcTfp
(
int32_t
code
,
tmsg_t
msgType
)
{
if
(
msgType
==
TDMT_VND_SUBMIT
||
msgType
==
TDMT_VND_CREATE_TABLE
)
{
return
true
;
}
return
false
;
}
// TODO refactor
void
*
openTransporter
(
const
char
*
user
,
const
char
*
auth
,
int32_t
numOfThread
)
{
SRpcInit
rpcInit
;
...
...
@@ -118,6 +126,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
rpcInit
.
numOfThreads
=
numOfThread
;
rpcInit
.
cfp
=
processMsgFromServer
;
rpcInit
.
rfp
=
clientRpcRfp
;
rpcInit
.
tfp
=
clientRpcTfp
;
rpcInit
.
sessions
=
1024
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
user
=
(
char
*
)
user
;
...
...
@@ -375,7 +384,7 @@ void taos_init_imp(void) {
initQueryModuleMsgHandle
();
taosConvInit
();
rpcInit
();
SCatalogCfg
cfg
=
{.
maxDBCacheNum
=
100
,
.
maxTblCacheNum
=
100
};
...
...
source/client/src/clientImpl.c
浏览文件 @
e1881185
...
...
@@ -1308,8 +1308,8 @@ int32_t doProcessMsgFromServer(void* param) {
char
tbuf
[
40
]
=
{
0
};
TRACE_TO_STR
(
trace
,
tbuf
);
tscDebug
(
"processMsgFromServer handle %p, message: %s, code: %s, gtid: %s"
,
pMsg
->
info
.
handle
,
TMSG_INFO
(
pMsg
->
msgType
),
tstrerror
(
pMsg
->
code
),
tbuf
);
tscDebug
(
"processMsgFromServer handle %p, message: %s,
size:%d,
code: %s, gtid: %s"
,
pMsg
->
info
.
handle
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
contLen
,
tstrerror
(
pMsg
->
code
),
tbuf
);
if
(
pSendInfo
->
requestObjRefId
!=
0
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosAcquireRef
(
clientReqRefPool
,
pSendInfo
->
requestObjRefId
);
...
...
@@ -1922,7 +1922,7 @@ _OVER:
return
code
;
}
int32_t
appendTbToReq
(
S
Array
*
pList
,
int32_t
pos1
,
int32_t
len1
,
int32_t
pos2
,
int32_t
len2
,
const
char
*
str
,
int32_t
appendTbToReq
(
S
HashObj
*
pHash
,
int32_t
pos1
,
int32_t
len1
,
int32_t
pos2
,
int32_t
len2
,
const
char
*
str
,
int32_t
acctId
,
char
*
db
)
{
SName
name
;
...
...
@@ -1957,20 +1957,33 @@ int32_t appendTbToReq(SArray* pList, int32_t pos1, int32_t len1, int32_t pos2, i
return
-
1
;
}
taosArrayPush
(
pList
,
&
name
);
char
dbFName
[
TSDB_DB_FNAME_LEN
];
sprintf
(
dbFName
,
"%d.%.*s"
,
acctId
,
dbLen
,
dbName
);
STablesReq
*
pDb
=
taosHashGet
(
pHash
,
dbFName
,
strlen
(
dbFName
));
if
(
pDb
)
{
taosArrayPush
(
pDb
->
pTables
,
&
name
);
}
else
{
STablesReq
db
;
db
.
pTables
=
taosArrayInit
(
20
,
sizeof
(
SName
));
strcpy
(
db
.
dbFName
,
dbFName
);
taosArrayPush
(
db
.
pTables
,
&
name
);
taosHashPut
(
pHash
,
dbFName
,
strlen
(
dbFName
),
&
db
,
sizeof
(
db
));
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
transferTableNameList
(
const
char
*
tbList
,
int32_t
acctId
,
char
*
dbName
,
SArray
**
pReq
)
{
*
pReq
=
taosArrayInit
(
10
,
sizeof
(
SName
)
);
if
(
NULL
==
*
pReq
)
{
SHashObj
*
pHash
=
taosHashInit
(
3
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
pHash
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
terrno
;
}
bool
inEscape
=
false
;
int32_t
code
=
0
;
void
*
pIter
=
NULL
;
int32_t
vIdx
=
0
;
int32_t
vPos
[
2
];
...
...
@@ -1985,7 +1998,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
code
=
appendTbToReq
(
*
pReq
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
code
=
appendTbToReq
(
pHash
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
if
(
code
)
{
goto
_return
;
}
...
...
@@ -2035,7 +2048,7 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
vLen
[
vIdx
]
=
i
-
vPos
[
vIdx
];
}
code
=
appendTbToReq
(
*
pReq
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
code
=
appendTbToReq
(
pHash
,
vPos
[
0
],
vLen
[
0
],
vPos
[
1
],
vLen
[
1
],
tbList
,
acctId
,
dbName
);
if
(
code
)
{
goto
_return
;
}
...
...
@@ -2067,14 +2080,31 @@ int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName,
goto
_return
;
}
int32_t
dbNum
=
taosHashGetSize
(
pHash
);
*
pReq
=
taosArrayInit
(
dbNum
,
sizeof
(
STablesReq
));
pIter
=
taosHashIterate
(
pHash
,
NULL
);
while
(
pIter
)
{
STablesReq
*
pDb
=
(
STablesReq
*
)
pIter
;
taosArrayPush
(
*
pReq
,
pDb
);
pIter
=
taosHashIterate
(
pHash
,
pIter
);
}
taosHashCleanup
(
pHash
);
return
TSDB_CODE_SUCCESS
;
_return:
terrno
=
TSDB_CODE_TSC_INVALID_OPERATION
;
taosArrayDestroy
(
*
pReq
);
*
pReq
=
NULL
;
pIter
=
taosHashIterate
(
pHash
,
NULL
);
while
(
pIter
)
{
STablesReq
*
pDb
=
(
STablesReq
*
)
pIter
;
taosArrayDestroy
(
pDb
->
pTables
);
pIter
=
taosHashIterate
(
pHash
,
pIter
);
}
taosHashCleanup
(
pHash
);
return
terrno
;
}
...
...
source/common/src/systable.c
浏览文件 @
e1881185
...
...
@@ -308,9 +308,9 @@ static const SSysDbTableSchema offsetSchema[] = {
};
static
const
SSysDbTableSchema
querySchema
[]
=
{
{.
name
=
"
query
_id"
,
.
bytes
=
TSDB_QUERY_ID_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"
req
_id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
},
{.
name
=
"conn
I
d"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UINT
},
{.
name
=
"
kill
_id"
,
.
bytes
=
TSDB_QUERY_ID_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"
query
_id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
},
{.
name
=
"conn
_i
d"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UINT
},
{.
name
=
"app"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
source/dnode/mnode/impl/src/mndQuery.c
浏览文件 @
e1881185
...
...
@@ -84,6 +84,9 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
}
for
(
int32_t
i
=
0
;
i
<
msgNum
;
++
i
)
{
req
.
msgIdx
=
ntohl
(
*
(
int32_t
*
)((
char
*
)
pMsg
->
pCont
+
offset
));
offset
+=
sizeof
(
req
.
msgIdx
);
req
.
msgType
=
ntohl
(
*
(
int32_t
*
)((
char
*
)
pMsg
->
pCont
+
offset
));
offset
+=
sizeof
(
req
.
msgType
);
...
...
@@ -111,6 +114,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
}
else
{
rsp
.
rspCode
=
0
;
}
rsp
.
msgIdx
=
req
.
msgIdx
;
rsp
.
reqType
=
reqMsg
.
msgType
;
rsp
.
msgLen
=
reqMsg
.
info
.
rspLen
;
rsp
.
msg
=
reqMsg
.
info
.
rsp
;
...
...
@@ -136,6 +140,8 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
reqType
);
offset
+=
sizeof
(
p
->
reqType
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
msgIdx
);
offset
+=
sizeof
(
p
->
msgIdx
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
msgLen
);
offset
+=
sizeof
(
p
->
msgLen
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
rspCode
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
e1881185
...
...
@@ -223,6 +223,8 @@ int vnodeCommit(SVnode *pVnode) {
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
pVnode
->
inUse
=
NULL
;
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
// save info
info
.
config
=
pVnode
->
config
;
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
e1881185
...
...
@@ -273,6 +273,9 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
}
for
(
int32_t
i
=
0
;
i
<
msgNum
;
++
i
)
{
req
.
msgIdx
=
ntohl
(
*
(
int32_t
*
)((
char
*
)
pMsg
->
pCont
+
offset
));
offset
+=
sizeof
(
req
.
msgIdx
);
req
.
msgType
=
ntohl
(
*
(
int32_t
*
)((
char
*
)
pMsg
->
pCont
+
offset
));
offset
+=
sizeof
(
req
.
msgType
);
...
...
@@ -301,6 +304,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
break
;
}
rsp
.
msgIdx
=
req
.
msgIdx
;
rsp
.
reqType
=
reqMsg
.
msgType
;
rsp
.
msgLen
=
reqMsg
.
contLen
;
rsp
.
rspCode
=
reqMsg
.
code
;
...
...
@@ -327,6 +331,8 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
reqType
);
offset
+=
sizeof
(
p
->
reqType
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
msgIdx
);
offset
+=
sizeof
(
p
->
msgIdx
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
msgLen
);
offset
+=
sizeof
(
p
->
msgLen
);
*
(
int32_t
*
)((
char
*
)
pRsp
+
offset
)
=
htonl
(
p
->
rspCode
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
e1881185
...
...
@@ -32,6 +32,7 @@ extern "C" {
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
#define CTG_DEFAULT_BATCH_NUM 64
#define CTG_DEFAULT_FETCH_NUM 8
#define CTG_RENT_SLOT_SECOND 1.5
...
...
@@ -80,6 +81,8 @@ typedef enum {
CTG_TASK_GET_UDF
,
CTG_TASK_GET_USER
,
CTG_TASK_GET_SVR_VER
,
CTG_TASK_GET_TB_META_BATCH
,
CTG_TASK_GET_TB_HASH_BATCH
,
}
CTG_TASK_TYPE
;
typedef
enum
{
...
...
@@ -110,6 +113,23 @@ typedef struct SCtgTbMetaCtx {
int32_t
flag
;
}
SCtgTbMetaCtx
;
typedef
struct
SCtgFetch
{
int32_t
dbIdx
;
int32_t
tbIdx
;
int32_t
fetchIdx
;
int32_t
resIdx
;
int32_t
flag
;
SCtgTbCacheInfo
tbInfo
;
int32_t
vgId
;
}
SCtgFetch
;
typedef
struct
SCtgTbMetasCtx
{
int32_t
fetchNum
;
SArray
*
pNames
;
SArray
*
pResList
;
SArray
*
pFetchs
;
}
SCtgTbMetasCtx
;
typedef
struct
SCtgTbIndexCtx
{
SName
*
pName
;
}
SCtgTbIndexCtx
;
...
...
@@ -137,6 +157,14 @@ typedef struct SCtgTbHashCtx {
SName
*
pName
;
}
SCtgTbHashCtx
;
typedef
struct
SCtgTbHashsCtx
{
int32_t
fetchNum
;
SArray
*
pNames
;
SArray
*
pResList
;
SArray
*
pFetchs
;
}
SCtgTbHashsCtx
;
typedef
struct
SCtgIndexCtx
{
char
indexFName
[
TSDB_INDEX_FNAME_LEN
];
}
SCtgIndexCtx
;
...
...
@@ -211,6 +239,7 @@ typedef struct SCtgBatch {
SRequestConnInfo
conn
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
SArray
*
pTaskIds
;
SArray
*
pMsgIdxs
;
}
SCtgBatch
;
typedef
struct
SCtgJob
{
...
...
@@ -218,6 +247,7 @@ typedef struct SCtgJob {
int32_t
batchId
;
SHashObj
*
pBatchs
;
SArray
*
pTasks
;
int32_t
subTaskNum
;
int32_t
taskDone
;
SMetaData
jobRes
;
int32_t
jobResCode
;
...
...
@@ -258,6 +288,7 @@ typedef struct SCtgTaskCallbackParam {
SArray
*
taskId
;
int32_t
reqType
;
int32_t
batchId
;
SArray
*
msgIdx
;
}
SCtgTaskCallbackParam
;
...
...
@@ -276,6 +307,7 @@ typedef struct SCtgTask {
int32_t
taskId
;
SCtgJob
*
pJob
;
void
*
taskCtx
;
SArray
*
msgCtxs
;
SCtgMsgCtx
msgCtx
;
int32_t
code
;
void
*
res
;
...
...
@@ -286,9 +318,14 @@ typedef struct SCtgTask {
SHashObj
*
pBatchs
;
}
SCtgTask
;
typedef
struct
SCtgTaskReq
{
SCtgTask
*
pTask
;
int32_t
msgIdx
;
}
SCtgTaskReq
;
typedef
int32_t
(
*
ctgInitTaskFp
)(
SCtgJob
*
,
int32_t
,
void
*
);
typedef
int32_t
(
*
ctgLanchTaskFp
)(
SCtgTask
*
);
typedef
int32_t
(
*
ctgHandleTaskMsgRspFp
)(
SCtgTask
*
,
int32_t
,
const
SDataBuf
*
,
int32_t
);
typedef
int32_t
(
*
ctgHandleTaskMsgRspFp
)(
SCtgTask
Req
*
,
int32_t
,
const
SDataBuf
*
,
int32_t
);
typedef
int32_t
(
*
ctgDumpTaskResFp
)(
SCtgTask
*
);
typedef
int32_t
(
*
ctgCloneTaskResFp
)(
SCtgTask
*
,
void
**
);
typedef
int32_t
(
*
ctgCompTaskFp
)(
SCtgTask
*
,
void
*
,
bool
*
);
...
...
@@ -487,6 +524,8 @@ typedef struct SCtgOperation {
#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB))
#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE))
#define CTG_GET_TASK_MSGCTX(_task, _id) (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx)
#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema))
#define CTG_TABLE_NOT_EXIST(code) (code == CTG_ERR_CODE_TABLE_NOT_EXIST)
...
...
@@ -586,6 +625,7 @@ int32_t ctgdShowCacheInfo(void);
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
);
int32_t
ctgGetTbMetaFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgGetTbMetasFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetasCtx
*
ctx
,
int32_t
dbIdx
,
int32_t
*
fetchIdx
,
int32_t
baseResIdx
,
SArray
*
pList
);
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
action
);
...
...
@@ -631,7 +671,7 @@ int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVg
int32_t
ctgProcessRspMsg
(
void
*
out
,
int32_t
reqType
,
char
*
msg
,
int32_t
msgSize
,
int32_t
rspCode
,
char
*
target
);
int32_t
ctgGetDBVgInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SBuildUseDBInput
*
input
,
SUseDbOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetDBVgInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SBuildUseDBInput
*
input
,
SUseDbOutput
*
out
,
SCtgTask
Req
*
tReq
);
int32_t
ctgGetQnodeListFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetDnodeListFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
**
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetDBCfgFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
out
,
SCtgTask
*
pTask
);
...
...
@@ -639,9 +679,9 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
int32_t
ctgGetTbIndexFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
name
,
STableIndex
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUdfInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUserDbAuthFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
SGetUserAuthRsp
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
Req
*
tReq
);
int32_t
ctgGetTbMetaFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMetaOutput
*
out
,
SCtgTask
Req
*
tReq
);
int32_t
ctgGetTbMetaFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
out
,
SCtgTask
Req
*
tReq
);
int32_t
ctgGetTableCfgFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableCfg
**
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTableCfgFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetSvrVerFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
**
out
,
SCtgTask
*
pTask
);
...
...
@@ -664,6 +704,7 @@ void ctgFreeJob(void* job);
void
ctgFreeHandleImpl
(
SCatalog
*
pCtg
);
void
ctgFreeVgInfo
(
SDBVgInfo
*
vgInfo
);
int32_t
ctgGetVgInfoFromHashValue
(
SCatalog
*
pCtg
,
SDBVgInfo
*
dbInfo
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
);
int32_t
ctgGetVgInfosFromHashValue
(
SCatalog
*
pCtg
,
SCtgTaskReq
*
tReq
,
SDBVgInfo
*
dbInfo
,
SCtgTbHashsCtx
*
pCtx
,
char
*
dbFName
,
SArray
*
pNames
,
bool
update
);
void
ctgResetTbMetaTask
(
SCtgTask
*
pTask
);
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
);
int32_t
ctgStbVersionSortCompare
(
const
void
*
key1
,
const
void
*
key2
);
...
...
@@ -672,8 +713,11 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
int32_t
ctgDbVgVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
void
ctgFreeSTableMetaOutput
(
STableMetaOutput
*
pOutput
);
int32_t
ctgUpdateMsgCtx
(
SCtgMsgCtx
*
pCtx
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
int32_t
ctgAddMsgCtx
(
SArray
*
pCtxs
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
char
*
ctgTaskTypeStr
(
CTG_TASK_TYPE
type
);
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
char
*
dbFName
,
int32_t
vgId
);
int32_t
ctgGetTablesReqNum
(
SArray
*
pList
);
int32_t
ctgAddFetch
(
SArray
**
pFetchs
,
int32_t
dbIdx
,
int32_t
tbIdx
,
int32_t
*
fetchIdx
,
int32_t
resIdx
,
int32_t
flag
);
int32_t
ctgCloneTableIndex
(
SArray
*
pIndex
,
SArray
**
pRes
);
void
ctgFreeSTableIndex
(
void
*
info
);
void
ctgClearSubTaskRes
(
SCtgSubRes
*
pRes
);
...
...
@@ -682,6 +726,7 @@ void ctgClearHandle(SCatalog* pCtg);
void
ctgFreeTbCacheImpl
(
SCtgTbCache
*
pCache
);
int32_t
ctgRemoveTbMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
);
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
);
SName
*
ctgGetFetchName
(
SArray
*
pNames
,
SCtgFetch
*
pFetch
);
extern
SCatalogMgmt
gCtgMgmt
;
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
e1881185
此差异已折叠。
点击以展开。
source/libs/catalog/src/ctgCache.c
浏览文件 @
e1881185
...
...
@@ -242,7 +242,6 @@ int32_t ctgAcquireTbMetaFromCache(SCatalog* pCtg, char *dbFName, char* tbName, S
goto
_return
;
}
int32_t
sz
=
0
;
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
tbName
,
dbFName
);
...
...
@@ -282,7 +281,6 @@ int32_t ctgAcquireStbMetaFromCache(SCatalog* pCtg, char *dbFName, uint64_t suid,
goto
_return
;
}
int32_t
sz
=
0
;
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
suid
,
dbFName
);
...
...
@@ -2152,6 +2150,254 @@ int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMet
return
TSDB_CODE_SUCCESS
;
}
#if 0
int32_t ctgGetTbMetaBFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, SArray** pResList) {
int32_t tbNum = taosArrayGetSize(ctx->pNames);
SName* fName = taosArrayGet(ctx->pNames, 0);
int32_t fIdx = 0;
for (int32_t i = 0; i < tbNum; ++i) {
SName* pName = taosArrayGet(ctx->pNames, i);
SCtgTbMetaCtx nctx = {0};
nctx.flag = CTG_FLAG_UNKNOWN_STB;
nctx.pName = pName;
if (IS_SYS_DBNAME(pName->dbname)) {
CTG_FLAG_SET_SYS_DB(nctx.flag);
}
STableMeta *pTableMeta = NULL;
CTG_ERR_RET(ctgReadTbMetaFromCache(pCtg, &nctx, &pTableMeta));
SMetaRes res = {0};
if (pTableMeta) {
if (CTG_FLAG_MATCH_STB(nctx.flag, pTableMeta->tableType) &&
((!CTG_FLAG_IS_FORCE_UPDATE(nctx.flag)) || (CTG_FLAG_IS_SYS_DB(nctx.flag)))) {
res.pRes = pTableMeta;
} else {
taosMemoryFreeClear(pTableMeta);
}
}
if (NULL == res.pRes) {
if (NULL == ctx->pFetchs) {
ctx->pFetchs = taosArrayInit(tbNum, sizeof(SCtgFetch));
}
if (CTG_FLAG_IS_UNKNOWN_STB(nctx.flag)) {
CTG_FLAG_SET_STB(nctx.flag, nctx.tbInfo.tbType);
}
SCtgFetch fetch = {0};
fetch.tbIdx = i;
fetch.fetchIdx = fIdx++;
fetch.flag = nctx.flag;
taosArrayPush(ctx->pFetchs, &fetch);
}
taosArrayPush(ctx->pResList, &res);
}
if (NULL == ctx->pFetchs) {
TSWAP(*pResList, ctx->pResList);
}
return TSDB_CODE_SUCCESS;
}
#endif
int32_t
ctgGetTbMetasFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetasCtx
*
ctx
,
int32_t
dbIdx
,
int32_t
*
fetchIdx
,
int32_t
baseResIdx
,
SArray
*
pList
)
{
int32_t
tbNum
=
taosArrayGetSize
(
pList
);
SName
*
pName
=
taosArrayGet
(
pList
,
0
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
int32_t
flag
=
CTG_FLAG_UNKNOWN_STB
;
uint64_t
lastSuid
=
0
;
STableMeta
*
lastTableMeta
=
NULL
;
if
(
IS_SYS_DBNAME
(
pName
->
dbname
))
{
CTG_FLAG_SET_SYS_DB
(
flag
);
strcpy
(
dbFName
,
pName
->
dbname
);
}
else
{
tNameGetFullDbName
(
pName
,
dbFName
);
}
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
pCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
}
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
SName
*
pName
=
taosArrayGet
(
pList
,
i
);
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
pName
->
tname
,
strlen
(
pName
->
tname
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
continue
;
}
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
if
(
NULL
==
pCache
->
pMeta
)
{
ctgDebug
(
"tb %s meta not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
continue
;
}
STableMeta
*
tbMeta
=
pCache
->
pMeta
;
SCtgTbMetaCtx
nctx
=
{
0
};
nctx
.
flag
=
flag
;
nctx
.
tbInfo
.
inCache
=
true
;
nctx
.
tbInfo
.
dbId
=
dbCache
->
dbId
;
nctx
.
tbInfo
.
suid
=
tbMeta
->
suid
;
nctx
.
tbInfo
.
tbType
=
tbMeta
->
tableType
;
SMetaRes
res
=
{
0
};
STableMeta
*
pTableMeta
=
NULL
;
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
int32_t
metaSize
=
CTG_META_SIZE
(
tbMeta
);
pTableMeta
=
taosMemoryCalloc
(
1
,
metaSize
);
if
(
NULL
==
pTableMeta
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
pTableMeta
,
tbMeta
,
metaSize
);
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgDebug
(
"Got tb %s meta from cache, type:%d, dbFName:%s"
,
pName
->
tname
,
tbMeta
->
tableType
,
dbFName
);
res
.
pRes
=
pTableMeta
;
taosArrayPush
(
ctx
->
pResList
,
&
res
);
continue
;
}
// PROCESS FOR CHILD TABLE
if
(
lastSuid
&&
tbMeta
->
suid
==
lastSuid
&&
lastTableMeta
)
{
cloneTableMeta
(
lastTableMeta
,
&
pTableMeta
);
memcpy
(
pTableMeta
,
tbMeta
,
sizeof
(
SCTableMeta
));
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgDebug
(
"Got tb %s meta from cache, type:%d, dbFName:%s"
,
pName
->
tname
,
tbMeta
->
tableType
,
dbFName
);
res
.
pRes
=
pTableMeta
;
taosArrayPush
(
ctx
->
pResList
,
&
res
);
continue
;
}
int32_t
metaSize
=
sizeof
(
SCTableMeta
);
pTableMeta
=
taosMemoryCalloc
(
1
,
metaSize
);
if
(
NULL
==
pTableMeta
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
pTableMeta
,
tbMeta
,
metaSize
);
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgDebug
(
"Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s"
,
pName
->
tname
,
nctx
.
tbInfo
.
tbType
,
dbFName
);
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
pTableMeta
->
suid
,
sizeof
(
pTableMeta
->
suid
));
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" not in cache, dbFName:%s"
,
pTableMeta
->
suid
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
}
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
stName
,
strlen
(
stName
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" name %s not in cache, dbFName:%s"
,
pTableMeta
->
suid
,
stName
,
dbFName
);
taosHashRelease
(
dbCache
->
stbCache
,
stName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
}
taosHashRelease
(
dbCache
->
stbCache
,
stName
);
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
if
(
NULL
==
pCache
->
pMeta
)
{
ctgDebug
(
"stb 0x%"
PRIx64
" meta not in cache, dbFName:%s"
,
pTableMeta
->
suid
,
dbFName
);
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
}
STableMeta
*
stbMeta
=
pCache
->
pMeta
;
if
(
stbMeta
->
suid
!=
nctx
.
tbInfo
.
suid
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
ctgError
(
"stb suid 0x%"
PRIx64
" in stbCache mis-match, expected suid 0x%"
PRIx64
,
stbMeta
->
suid
,
nctx
.
tbInfo
.
suid
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosMemoryFreeClear
(
pTableMeta
);
continue
;
}
metaSize
=
CTG_META_SIZE
(
stbMeta
);
pTableMeta
=
taosMemoryRealloc
(
pTableMeta
,
metaSize
);
if
(
NULL
==
pTableMeta
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
&
pTableMeta
->
sversion
,
&
stbMeta
->
sversion
,
metaSize
-
sizeof
(
SCTableMeta
));
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
res
.
pRes
=
pTableMeta
;
taosArrayPush
(
ctx
->
pResList
,
&
res
);
lastSuid
=
pTableMeta
->
suid
;
lastTableMeta
=
pTableMeta
;
}
ctgReleaseDBCache
(
pCtg
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
)
{
int32_t
code
=
0
;
...
...
source/libs/catalog/src/ctgRemote.c
浏览文件 @
e1881185
此差异已折叠。
点击以展开。
source/libs/catalog/src/ctgUtil.c
浏览文件 @
e1881185
...
...
@@ -26,6 +26,7 @@ void ctgFreeMsgSendParam(void* param) {
SCtgTaskCallbackParam
*
pParam
=
(
SCtgTaskCallbackParam
*
)
param
;
taosArrayDestroy
(
pParam
->
taskId
);
taosArrayDestroy
(
pParam
->
msgIdx
);
taosMemoryFree
(
param
);
}
...
...
@@ -88,6 +89,10 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
return
"[get user]"
;
case
CTG_TASK_GET_SVR_VER
:
return
"[get svr ver]"
;
case
CTG_TASK_GET_TB_META_BATCH
:
return
"[bget table meta]"
;
case
CTG_TASK_GET_TB_HASH_BATCH
:
return
"[bget table hash]"
;
default:
return
"unknown"
;
}
...
...
@@ -460,6 +465,25 @@ void ctgResetTbMetaTask(SCtgTask* pTask) {
taosMemoryFreeClear
(
pTask
->
res
);
}
void
ctgFreeBatchMeta
(
void
*
meta
)
{
if
(
NULL
==
meta
)
{
return
;
}
SMetaRes
*
pRes
=
(
SMetaRes
*
)
meta
;
taosMemoryFreeClear
(
pRes
->
pRes
);
}
void
ctgFreeBatchHash
(
void
*
hash
)
{
if
(
NULL
==
hash
)
{
return
;
}
SMetaRes
*
pRes
=
(
SMetaRes
*
)
hash
;
taosMemoryFreeClear
(
pRes
->
pRes
);
}
void
ctgFreeTaskRes
(
CTG_TASK_TYPE
type
,
void
**
pRes
)
{
switch
(
type
)
{
case
CTG_TASK_GET_QNODE
:
...
...
@@ -500,6 +524,24 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) {
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_META_BATCH
:
{
SArray
*
pArray
=
(
SArray
*
)
*
pRes
;
int32_t
num
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
ctgFreeBatchMeta
(
taosArrayGet
(
pArray
,
i
));
}
*
pRes
=
NULL
;
// no need to free it
break
;
}
case
CTG_TASK_GET_TB_HASH_BATCH
:
{
SArray
*
pArray
=
(
SArray
*
)
*
pRes
;
int32_t
num
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
ctgFreeBatchHash
(
taosArrayGet
(
pArray
,
i
));
}
*
pRes
=
NULL
;
// no need to free it
break
;
}
default:
qError
(
"invalid task type %d"
,
type
);
break
;
...
...
@@ -554,6 +596,16 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) {
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_META_BATCH
:
{
taosArrayDestroyEx
(
*
pRes
,
ctgFreeBatchMeta
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_TB_HASH_BATCH
:
{
taosArrayDestroyEx
(
*
pRes
,
ctgFreeBatchHash
);
*
pRes
=
NULL
;
break
;
}
default:
qError
(
"invalid task type %d"
,
type
);
break
;
...
...
@@ -583,12 +635,38 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
}
case
CTG_TASK_GET_TB_META_BATCH
:
{
SCtgTbMetasCtx
*
taskCtx
=
(
SCtgTbMetasCtx
*
)
pTask
->
taskCtx
;
taosArrayDestroyEx
(
taskCtx
->
pResList
,
ctgFreeBatchMeta
);
taosArrayDestroy
(
taskCtx
->
pFetchs
);
// NO NEED TO FREE pNames
taosArrayDestroyEx
(
pTask
->
msgCtxs
,
(
FDelete
)
ctgFreeMsgCtx
);
if
(
pTask
->
msgCtx
.
lastOut
)
{
ctgFreeSTableMetaOutput
((
STableMetaOutput
*
)
pTask
->
msgCtx
.
lastOut
);
pTask
->
msgCtx
.
lastOut
=
NULL
;
}
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
}
case
CTG_TASK_GET_TB_HASH
:
{
SCtgTbHashCtx
*
taskCtx
=
(
SCtgTbHashCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
}
case
CTG_TASK_GET_TB_HASH_BATCH
:
{
SCtgTbHashsCtx
*
taskCtx
=
(
SCtgTbHashsCtx
*
)
pTask
->
taskCtx
;
taosArrayDestroyEx
(
taskCtx
->
pResList
,
ctgFreeBatchHash
);
taosArrayDestroy
(
taskCtx
->
pFetchs
);
// NO NEED TO FREE pNames
taosArrayDestroyEx
(
pTask
->
msgCtxs
,
(
FDelete
)
ctgFreeMsgCtx
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
}
case
CTG_TASK_GET_TB_INDEX
:
{
SCtgTbIndexCtx
*
taskCtx
=
(
SCtgTbIndexCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
...
...
@@ -679,6 +757,23 @@ int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* targ
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgAddMsgCtx
(
SArray
*
pCtxs
,
int32_t
reqType
,
void
*
out
,
char
*
target
)
{
SCtgMsgCtx
ctx
=
{
0
};
ctx
.
reqType
=
reqType
;
ctx
.
out
=
out
;
if
(
target
)
{
ctx
.
target
=
strdup
(
target
);
if
(
NULL
==
ctx
.
target
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
taosArrayPush
(
pCtxs
,
&
ctx
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetHashFunction
(
int8_t
hashMethod
,
tableNameHashFp
*
fp
)
{
switch
(
hashMethod
)
{
...
...
@@ -780,6 +875,104 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_RET
(
code
);
}
int32_t
ctgGetVgInfosFromHashValue
(
SCatalog
*
pCtg
,
SCtgTaskReq
*
tReq
,
SDBVgInfo
*
dbInfo
,
SCtgTbHashsCtx
*
pCtx
,
char
*
dbFName
,
SArray
*
pNames
,
bool
update
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SMetaRes
res
=
{
0
};
int32_t
vgNum
=
taosHashGetSize
(
dbInfo
->
vgHash
);
if
(
vgNum
<=
0
)
{
ctgError
(
"db vgroup cache invalid, db:%s, vgroup number:%d"
,
dbFName
,
vgNum
);
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
}
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
int32_t
tbNum
=
taosArrayGetSize
(
pNames
);
if
(
1
==
vgNum
)
{
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
vgInfo
=
taosMemoryMalloc
(
sizeof
(
SVgroupInfo
));
if
(
NULL
==
vgInfo
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
*
vgInfo
=
*
(
SVgroupInfo
*
)
pIter
;
ctgDebug
(
"Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d"
,
vgInfo
->
vgId
,
vgInfo
->
epSet
.
numOfEps
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
fqdn
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
port
);
if
(
update
)
{
SCtgFetch
*
pFetch
=
taosArrayGet
(
pCtx
->
pFetchs
,
tReq
->
msgIdx
);
SMetaRes
*
pRes
=
taosArrayGet
(
pCtx
->
pResList
,
pFetch
->
resIdx
+
i
);
pRes
->
pRes
=
vgInfo
;
}
else
{
res
.
pRes
=
vgInfo
;
taosArrayPush
(
pCtx
->
pResList
,
&
res
);
}
}
return
TSDB_CODE_SUCCESS
;
}
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
sprintf
(
tbFullName
,
"%s."
,
dbFName
);
int32_t
offset
=
strlen
(
tbFullName
);
SName
*
pName
=
NULL
;
int32_t
tbNameLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
tbNum
;
++
i
)
{
pName
=
taosArrayGet
(
pNames
,
i
);
tbNameLen
=
offset
+
strlen
(
pName
->
tname
);
strcpy
(
tbFullName
+
offset
,
pName
->
tname
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
tbNameLen
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
vgInfo
=
pIter
;
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
taosHashCancelIterate
(
dbInfo
->
vgHash
,
pIter
);
break
;
}
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
pIter
);
vgInfo
=
NULL
;
}
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
dbFName
,
taosHashGetSize
(
dbInfo
->
vgHash
));
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
SVgroupInfo
*
pNewVg
=
taosMemoryMalloc
(
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pNewVg
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
*
pNewVg
=
*
vgInfo
;
ctgDebug
(
"Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d"
,
tbFullName
,
vgInfo
->
vgId
,
vgInfo
->
epSet
.
numOfEps
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
fqdn
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
port
);
if
(
update
)
{
SCtgFetch
*
pFetch
=
taosArrayGet
(
pCtx
->
pFetchs
,
tReq
->
msgIdx
);
SMetaRes
*
pRes
=
taosArrayGet
(
pCtx
->
pResList
,
pFetch
->
resIdx
+
i
);
pRes
->
pRes
=
pNewVg
;
}
else
{
res
.
pRes
=
pNewVg
;
taosArrayPush
(
pCtx
->
pResList
,
&
res
);
}
}
CTG_RET
(
code
);
}
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
uint64_t
*
)
key1
<
((
SSTableVersion
*
)
key2
)
->
suid
)
{
return
-
1
;
...
...
@@ -921,4 +1114,41 @@ int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, cha
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetTablesReqNum
(
SArray
*
pList
)
{
if
(
NULL
==
pList
)
{
return
0
;
}
int32_t
total
=
0
;
int32_t
n
=
taosArrayGetSize
(
pList
);
for
(
int32_t
i
=
0
;
i
<
n
;
++
i
)
{
STablesReq
*
pReq
=
taosArrayGet
(
pList
,
i
);
total
+=
taosArrayGetSize
(
pReq
->
pTables
);
}
return
total
;
}
int32_t
ctgAddFetch
(
SArray
**
pFetchs
,
int32_t
dbIdx
,
int32_t
tbIdx
,
int32_t
*
fetchIdx
,
int32_t
resIdx
,
int32_t
flag
)
{
if
(
NULL
==
(
*
pFetchs
))
{
*
pFetchs
=
taosArrayInit
(
CTG_DEFAULT_FETCH_NUM
,
sizeof
(
SCtgFetch
));
}
SCtgFetch
fetch
=
{
0
};
fetch
.
dbIdx
=
dbIdx
;
fetch
.
tbIdx
=
tbIdx
;
fetch
.
fetchIdx
=
(
*
fetchIdx
)
++
;
fetch
.
resIdx
=
resIdx
;
fetch
.
flag
=
flag
;
taosArrayPush
(
*
pFetchs
,
&
fetch
);
return
TSDB_CODE_SUCCESS
;
}
SName
*
ctgGetFetchName
(
SArray
*
pNames
,
SCtgFetch
*
pFetch
)
{
STablesReq
*
pReq
=
(
STablesReq
*
)
taosArrayGet
(
pNames
,
pFetch
->
dbIdx
);
return
(
SName
*
)
taosArrayGet
(
pReq
->
pTables
,
pFetch
->
tbIdx
);
}
source/libs/executor/inc/executorimpl.h
浏览文件 @
e1881185
...
...
@@ -737,6 +737,9 @@ typedef struct STimeSliceOperatorInfo {
SInterval
interval
;
int64_t
current
;
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pNextRow
;
// SArray<SGroupValue>
bool
isPrevRowSet
;
bool
isNextRowSet
;
int32_t
fillType
;
// fill type
SColumn
tsCol
;
// primary timestamp column
SExprSupp
scalarSup
;
// scalar calculation
...
...
@@ -987,7 +990,7 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length);
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
);
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
taskId
,
c
onst
c
har
*
sql
,
EOPTR_EXEC_MODEL
model
);
char
*
sql
,
EOPTR_EXEC_MODEL
model
);
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
qTaskInfo_t
*
pTaskInfo
,
SReadHandle
*
readHandle
);
int32_t
getOperatorExplainExecInfo
(
SOperatorInfo
*
operatorInfo
,
SArray
*
pExecInfoList
);
...
...
source/libs/executor/src/executor.c
浏览文件 @
e1881185
...
...
@@ -341,7 +341,7 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
}
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
c
onst
c
har
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
char
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
assert
(
pSubplan
!=
NULL
);
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e1881185
...
...
@@ -4492,7 +4492,7 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pT
}
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
taskId
,
c
onst
c
har
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
char
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
uint64_t
queryId
=
pPlan
->
id
.
queryId
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -4503,6 +4503,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
}
(
*
pTaskInfo
)
->
sql
=
sql
;
sql
=
NULL
;
(
*
pTaskInfo
)
->
pSubplan
=
pPlan
;
(
*
pTaskInfo
)
->
pRoot
=
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
&
(
*
pTaskInfo
)
->
tableqinfoList
,
pPlan
->
pTagCond
,
pPlan
->
pTagIndexCond
,
pPlan
->
user
);
...
...
@@ -4515,6 +4516,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
return
code
;
_complete:
taosMemoryFree
(
sql
);
doDestroyTask
(
*
pTaskInfo
);
terrno
=
code
;
return
code
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e1881185
...
...
@@ -2065,10 +2065,30 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
pSliceInfo
->
isPrevRowSet
=
true
;
}
static
void
doKeepNextRows
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
,
int32_t
rowIndex
)
{
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
// null data should not be kept since it can not be used to perform interpolation
if
(
!
colDataIsNull_s
(
pColInfoData
,
i
))
{
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pNextRow
,
i
);
pkey
->
isNull
=
false
;
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
pSliceInfo
->
isNextRowSet
=
true
;
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
SSDataBlock
*
pResBlock
)
{
SSDataBlock
*
pResBlock
)
{
int32_t
rows
=
pResBlock
->
info
.
rows
;
// todo set the correct primary timestamp column
...
...
@@ -2144,6 +2164,10 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
break
;
}
case
TSDB_FILL_PREV
:
{
if
(
!
pSliceInfo
->
isPrevRowSet
)
{
break
;
}
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pPrevRow
,
srcSlot
);
colDataAppend
(
pDst
,
rows
,
pkey
->
pData
,
false
);
pResBlock
->
info
.
rows
+=
1
;
...
...
@@ -2151,8 +2175,12 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
}
case
TSDB_FILL_NEXT
:
{
char
*
p
=
colDataGetData
(
pSrc
,
rowIndex
);
colDataAppend
(
pDst
,
rows
,
p
,
colDataIsNull_s
(
pSrc
,
rowIndex
));
if
(
!
pSliceInfo
->
isNextRowSet
)
{
break
;
}
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pNextRow
,
srcSlot
);
colDataAppend
(
pDst
,
rows
,
pkey
->
pData
,
false
);
pResBlock
->
info
.
rows
+=
1
;
break
;
}
...
...
@@ -2186,6 +2214,35 @@ static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
taosArrayPush
(
pInfo
->
pPrevRow
,
&
key
);
}
pInfo
->
isPrevRowSet
=
false
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
initNextRowsKeeper
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
if
(
pInfo
->
pNextRow
!=
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
pInfo
->
pNextRow
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
if
(
pInfo
->
pNextRow
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pColInfo
->
info
.
bytes
;
key
.
type
=
pColInfo
->
info
.
type
;
key
.
isNull
=
false
;
key
.
pData
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
taosArrayPush
(
pInfo
->
pNextRow
,
&
key
);
}
pInfo
->
isNextRowSet
=
false
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2215,14 +2272,19 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
blockDataCleanup
(
pResBlock
);
//int32_t numOfRows = 0;
while
(
1
)
{
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
break
;
}
int32_t
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
int32_t
code
;
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
code
=
initNextRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -2244,7 +2306,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
SColumnInfoData
*
pDst
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
dstSlot
);
char
*
v
=
colDataGetData
(
pSrc
,
i
);
//colDataAppend(pDst, numOfRows, v, false);
colDataAppend
(
pDst
,
pResBlock
->
info
.
rows
,
v
,
false
);
}
...
...
@@ -2262,11 +2323,16 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break
;
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
// in case interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
// in case interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
+
1
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
@@ -2285,8 +2351,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
else
{
// ts > pSliceInfo->current
// in case interpolation window starts and ends between two datapoints, fill(next) need to interpolate
doKeepNextRows
(
pSliceInfo
,
pBlock
,
i
);
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
@@ -2326,9 +2395,10 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
}
}
//check if need to interpolate after ts range
while
(
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pBlock
->
info
.
rows
-
1
,
pResBlock
);
// check if need to interpolate after ts range
// except for fill(next)
while
(
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
&&
pSliceInfo
->
fillType
!=
TSDB_FILL_NEXT
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
e1881185
...
...
@@ -39,6 +39,11 @@ typedef struct SMsgBuf {
char
*
buf
;
}
SMsgBuf
;
typedef
struct
SParseTablesMetaReq
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
SHashObj
*
pTables
;
}
SParseTablesMetaReq
;
typedef
struct
SParseMetaCache
{
SHashObj
*
pTableMeta
;
// key is tbFName, element is STableMeta*
SHashObj
*
pDbVgroup
;
// key is dbFName, element is SArray<SVgroupInfo>*
...
...
@@ -95,7 +100,7 @@ int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFun
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableCfg
**
pOutput
);
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
,
bool
request
);
#ifdef __cplusplus
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e1881185
...
...
@@ -1253,20 +1253,21 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p
if
(
!
fmIsRepeatScanFunc
(
pFunc
->
funcId
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
// select percentile() without from clause is also valid
if
(
NULL
==
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
pFromTable
)
{
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pTable
=
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
pFromTable
;
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
)
&&
(
TSDB_CHILD_TABLE
==
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
tableType
||
TSDB_NORMAL_TABLE
==
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
tableType
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isSelectStmt
(
pCxt
->
pCurrStmt
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE
,
"%s is only supported in single table query"
,
pFunc
->
functionName
);
}
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE
,
"%s is only supported in single table query"
,
pFunc
->
functionName
);
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
SNode
*
pTable
=
pSelect
->
pFromTable
;
// select percentile() without from clause is also valid
if
((
NULL
!=
pTable
&&
(
QUERY_NODE_REAL_TABLE
!=
nodeType
(
pTable
)
||
(
TSDB_CHILD_TABLE
!=
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
tableType
)))
||
NULL
!=
pSelect
->
pPartitionByList
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE
,
"%s is only supported in single table query"
,
pFunc
->
functionName
);
}
return
TSDB_CODE_SUCCESS
;
}
static
bool
isStar
(
SNode
*
pNode
)
{
...
...
@@ -2509,9 +2510,31 @@ static EDealRes checkStateExpr(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
int32_t
translateStateWindow
(
STranslateContext
*
pCxt
,
SStateWindowNode
*
pState
)
{
static
bool
isPartitionByTbname
(
SNodeList
*
pPartitionByList
)
{
if
(
1
!=
LIST_LENGTH
(
pPartitionByList
))
{
return
false
;
}
SNode
*
pPartKey
=
nodesListGetNode
(
pPartitionByList
,
0
);
return
QUERY_NODE_FUNCTION
!=
nodeType
(
pPartKey
)
||
FUNCTION_TYPE_TBNAME
!=
((
SFunctionNode
*
)
pPartKey
)
->
funcType
;
}
static
int32_t
checkStateWindowForStream
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
!
pCxt
->
createStream
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
TSDB_SUPER_TABLE
==
((
SRealTableNode
*
)
pSelect
->
pFromTable
)
->
pMeta
->
tableType
&&
!
isPartitionByTbname
(
pSelect
->
pPartitionByList
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"Unsupported stream query"
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateStateWindow
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pSelect
->
pWindow
;
nodesWalkExprPostOrder
(
pState
->
pExpr
,
checkStateExpr
,
pCxt
);
// todo check for "function not support for state_window"
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
errCode
=
checkStateWindowForStream
(
pCxt
,
pSelect
);
}
return
pCxt
->
errCode
;
}
...
...
@@ -2522,14 +2545,13 @@ static int32_t translateSessionWindow(STranslateContext* pCxt, SSessionWindowNod
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
!=
pSession
->
pCol
->
colId
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_SESSION_COL
);
}
// todo check for "function not support for session"
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSpecificWindow
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
switch
(
nodeType
(
pSelect
->
pWindow
))
{
case
QUERY_NODE_STATE_WINDOW
:
return
translateStateWindow
(
pCxt
,
(
SStateWindowNode
*
)
pSelect
->
pWindow
);
return
translateStateWindow
(
pCxt
,
pSelect
);
case
QUERY_NODE_SESSION_WINDOW
:
return
translateSessionWindow
(
pCxt
,
(
SSessionWindowNode
*
)
pSelect
->
pWindow
);
case
QUERY_NODE_INTERVAL_WINDOW
:
...
...
@@ -4708,7 +4730,7 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
}
}
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
);
return
generateSyntaxErrMsg
Ext
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"Unsupported stream query"
);
}
static
void
getSourceDatabase
(
SNode
*
pStmt
,
int32_t
acctId
,
char
*
pDbFName
)
{
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
e1881185
...
...
@@ -474,6 +474,24 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildTableReqFromDb
(
SHashObj
*
pDbsHash
,
SArray
**
pDbs
)
{
if
(
NULL
!=
pDbsHash
)
{
*
pDbs
=
taosArrayInit
(
taosHashGetSize
(
pDbsHash
),
sizeof
(
STablesReq
));
if
(
NULL
==
*
pDbs
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SParseTablesMetaReq
*
p
=
taosHashIterate
(
pDbsHash
,
NULL
);
while
(
NULL
!=
p
)
{
STablesReq
req
=
{
0
};
strcpy
(
req
.
dbFName
,
p
->
dbFName
);
buildTableReq
(
p
->
pTables
,
&
req
.
pTables
);
taosArrayPush
(
*
pDbs
,
&
req
);
p
=
taosHashIterate
(
pDbsHash
,
p
);
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildUserAuthReq
(
SHashObj
*
pUserAuthHash
,
SArray
**
pUserAuth
)
{
if
(
NULL
!=
pUserAuthHash
)
{
*
pUserAuth
=
taosArrayInit
(
taosHashGetSize
(
pUserAuthHash
),
sizeof
(
SUserAuthInfo
));
...
...
@@ -513,12 +531,12 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
}
int32_t
buildCatalogReq
(
const
SParseMetaCache
*
pMetaCache
,
SCatalogReq
*
pCatalogReq
)
{
int32_t
code
=
buildTableReq
(
pMetaCache
->
pTableMeta
,
&
pCatalogReq
->
pTableMeta
);
int32_t
code
=
buildTableReq
FromDb
(
pMetaCache
->
pTableMeta
,
&
pCatalogReq
->
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildDbReq
(
pMetaCache
->
pDbVgroup
,
&
pCatalogReq
->
pDbVgroup
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildTableReq
(
pMetaCache
->
pTableVgroup
,
&
pCatalogReq
->
pTableHash
);
code
=
buildTableReq
FromDb
(
pMetaCache
->
pTableVgroup
,
&
pCatalogReq
->
pTableHash
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildDbReq
(
pMetaCache
->
pDbCfg
,
&
pCatalogReq
->
pDbCfg
);
...
...
@@ -587,6 +605,24 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
putDbTableDataToCache
(
const
SArray
*
pDbReq
,
const
SArray
*
pTableData
,
SHashObj
**
pTable
)
{
int32_t
ndbs
=
taosArrayGetSize
(
pDbReq
);
int32_t
tableNo
=
0
;
for
(
int32_t
i
=
0
;
i
<
ndbs
;
++
i
)
{
STablesReq
*
pReq
=
taosArrayGet
(
pDbReq
,
i
);
int32_t
ntables
=
taosArrayGetSize
(
pReq
->
pTables
);
for
(
int32_t
j
=
0
;
j
<
ntables
;
++
j
)
{
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
taosArrayGet
(
pReq
->
pTables
,
j
),
fullName
);
if
(
TSDB_CODE_SUCCESS
!=
putMetaDataToHash
(
fullName
,
strlen
(
fullName
),
pTableData
,
tableNo
,
pTable
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
++
tableNo
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
putUserAuthToCache
(
const
SArray
*
pUserAuthReq
,
const
SArray
*
pUserAuthData
,
SHashObj
**
pUserAuth
)
{
int32_t
nvgs
=
taosArrayGetSize
(
pUserAuthReq
);
for
(
int32_t
i
=
0
;
i
<
nvgs
;
++
i
)
{
...
...
@@ -612,12 +648,12 @@ static int32_t putUdfToCache(const SArray* pUdfReq, const SArray* pUdfData, SHas
}
int32_t
putMetaDataToCache
(
const
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
SParseMetaCache
*
pMetaCache
)
{
int32_t
code
=
putTableDataToCache
(
pCatalogReq
->
pTableMeta
,
pMetaData
->
pTableMeta
,
&
pMetaCache
->
pTableMeta
);
int32_t
code
=
put
Db
TableDataToCache
(
pCatalogReq
->
pTableMeta
,
pMetaData
->
pTableMeta
,
&
pMetaCache
->
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
putDbDataToCache
(
pCatalogReq
->
pDbVgroup
,
pMetaData
->
pDbVgroup
,
&
pMetaCache
->
pDbVgroup
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
putTableDataToCache
(
pCatalogReq
->
pTableHash
,
pMetaData
->
pTableHash
,
&
pMetaCache
->
pTableVgroup
);
code
=
put
Db
TableDataToCache
(
pCatalogReq
->
pTableHash
,
pMetaData
->
pTableHash
,
&
pMetaCache
->
pTableVgroup
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
putDbDataToCache
(
pCatalogReq
->
pDbCfg
,
pMetaData
->
pDbCfg
,
&
pMetaCache
->
pDbCfg
);
...
...
@@ -657,14 +693,38 @@ static int32_t reserveTableReqInCache(int32_t acctId, const char* pDb, const cha
return
reserveTableReqInCacheImpl
(
fullName
,
len
,
pTables
);
}
static
int32_t
reserveTableReqInDbCacheImpl
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SHashObj
*
pDbs
)
{
SParseTablesMetaReq
req
=
{
0
};
int32_t
len
=
snprintf
(
req
.
dbFName
,
sizeof
(
req
.
dbFName
),
"%d.%s"
,
acctId
,
pDb
);
int32_t
code
=
reserveTableReqInCache
(
acctId
,
pDb
,
pTable
,
&
req
.
pTables
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
taosHashPut
(
pDbs
,
req
.
dbFName
,
len
,
&
req
,
sizeof
(
SParseTablesMetaReq
));
}
return
code
;
}
static
int32_t
reserveTableReqInDbCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SHashObj
**
pDbs
)
{
if
(
NULL
==
*
pDbs
)
{
*
pDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
if
(
NULL
==
*
pDbs
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
char
fullName
[
TSDB_DB_FNAME_LEN
];
int32_t
len
=
snprintf
(
fullName
,
sizeof
(
fullName
),
"%d.%s"
,
acctId
,
pDb
);
SParseTablesMetaReq
*
pReq
=
taosHashGet
(
*
pDbs
,
fullName
,
len
);
if
(
NULL
==
pReq
)
{
return
reserveTableReqInDbCacheImpl
(
acctId
,
pDb
,
pTable
,
*
pDbs
);
}
return
reserveTableReqInCache
(
acctId
,
pDb
,
pTable
,
&
pReq
->
pTables
);
}
int32_t
reserveTableMetaInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
)
{
return
reserveTableReqInCache
(
acctId
,
pDb
,
pTable
,
&
pMetaCache
->
pTableMeta
);
return
reserveTableReqIn
Db
Cache
(
acctId
,
pDb
,
pTable
,
&
pMetaCache
->
pTableMeta
);
}
int32_t
reserveTableMetaInCacheExt
(
const
SName
*
pName
,
SParseMetaCache
*
pMetaCache
)
{
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pName
,
fullName
);
return
reserveTableReqInCacheImpl
(
fullName
,
strlen
(
fullName
),
&
pMetaCache
->
pTableMeta
);
return
reserveTableReqInDbCache
(
pName
->
acctId
,
pName
->
dbname
,
pName
->
tname
,
&
pMetaCache
->
pTableMeta
);
}
int32_t
getTableMetaFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableMeta
**
pMeta
)
{
...
...
@@ -711,13 +771,11 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
}
int32_t
reserveTableVgroupInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
)
{
return
reserveTableReqInCache
(
acctId
,
pDb
,
pTable
,
&
pMetaCache
->
pTableVgroup
);
return
reserveTableReqIn
Db
Cache
(
acctId
,
pDb
,
pTable
,
&
pMetaCache
->
pTableVgroup
);
}
int32_t
reserveTableVgroupInCacheExt
(
const
SName
*
pName
,
SParseMetaCache
*
pMetaCache
)
{
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pName
,
fullName
);
return
reserveTableReqInCacheImpl
(
fullName
,
strlen
(
fullName
),
&
pMetaCache
->
pTableVgroup
);
return
reserveTableReqInDbCache
(
pName
->
acctId
,
pName
->
dbname
,
pName
->
tname
,
&
pMetaCache
->
pTableVgroup
);
}
int32_t
getTableVgroupFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SVgroupInfo
*
pVgroup
)
{
...
...
@@ -919,10 +977,24 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
return
TSDB_CODE_SUCCESS
;
}
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
)
{
taosHashCleanup
(
pMetaCache
->
pTableMeta
);
void
destoryParseTablesMetaReqHash
(
SHashObj
*
pHash
)
{
SParseTablesMetaReq
*
p
=
taosHashIterate
(
pHash
,
NULL
);
while
(
NULL
!=
p
)
{
taosHashCleanup
(
p
->
pTables
);
p
=
taosHashIterate
(
pHash
,
p
);
}
taosHashCleanup
(
pHash
);
}
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
,
bool
request
)
{
if
(
request
)
{
destoryParseTablesMetaReqHash
(
pMetaCache
->
pTableMeta
);
destoryParseTablesMetaReqHash
(
pMetaCache
->
pTableVgroup
);
}
else
{
taosHashCleanup
(
pMetaCache
->
pTableMeta
);
taosHashCleanup
(
pMetaCache
->
pTableVgroup
);
}
taosHashCleanup
(
pMetaCache
->
pDbVgroup
);
taosHashCleanup
(
pMetaCache
->
pTableVgroup
);
taosHashCleanup
(
pMetaCache
->
pDbCfg
);
taosHashCleanup
(
pMetaCache
->
pDbInfo
);
taosHashCleanup
(
pMetaCache
->
pUserAuth
);
...
...
source/libs/parser/src/parser.c
浏览文件 @
e1881185
...
...
@@ -85,13 +85,13 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
if
(
IS_VAR_DATA_TYPE
(
pVal
->
node
.
resType
.
type
))
{
taosMemoryFreeClear
(
pVal
->
datum
.
p
);
}
if
(
pParam
->
is_null
&&
1
==
*
(
pParam
->
is_null
))
{
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
pVal
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_NULL
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
inputSize
=
(
NULL
!=
pParam
->
length
?
*
(
pParam
->
length
)
:
tDataTypes
[
pParam
->
buffer_type
].
bytes
);
pVal
->
node
.
resType
.
type
=
pParam
->
buffer_type
;
pVal
->
node
.
resType
.
bytes
=
inputSize
;
...
...
@@ -187,7 +187,7 @@ int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCatalogReq
(
&
metaCache
,
pCatalogReq
);
}
destoryParseMetaCache
(
&
metaCache
);
destoryParseMetaCache
(
&
metaCache
,
true
);
terrno
=
code
;
return
code
;
}
...
...
@@ -203,7 +203,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata
code
=
analyseSemantic
(
pCxt
,
pQuery
,
&
metaCache
);
}
}
destoryParseMetaCache
(
&
metaCache
);
destoryParseMetaCache
(
&
metaCache
,
false
);
terrno
=
code
;
return
code
;
}
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
e1881185
...
...
@@ -472,12 +472,16 @@ class MockCatalogServiceImpl {
int32_t
getAllTableMeta
(
SArray
*
pTableMetaReq
,
SArray
**
pTableMetaData
)
const
{
if
(
NULL
!=
pTableMetaReq
)
{
int32_t
ntables
=
taosArrayGetSize
(
pTableMetaReq
);
*
pTableMetaData
=
taosArrayInit
(
ntables
,
sizeof
(
SMetaRes
));
for
(
int32_t
i
=
0
;
i
<
ntables
;
++
i
)
{
SMetaRes
res
=
{
0
};
res
.
code
=
catalogGetTableMeta
((
const
SName
*
)
taosArrayGet
(
pTableMetaReq
,
i
),
(
STableMeta
**
)
&
res
.
pRes
);
taosArrayPush
(
*
pTableMetaData
,
&
res
);
int32_t
ndbs
=
taosArrayGetSize
(
pTableMetaReq
);
*
pTableMetaData
=
taosArrayInit
(
ndbs
,
sizeof
(
SMetaRes
));
for
(
int32_t
i
=
0
;
i
<
ndbs
;
++
i
)
{
STablesReq
*
pReq
=
(
STablesReq
*
)
taosArrayGet
(
pTableMetaReq
,
i
);
int32_t
ntables
=
taosArrayGetSize
(
pReq
->
pTables
);
for
(
int32_t
j
=
0
;
j
<
ntables
;
++
j
)
{
SMetaRes
res
=
{
0
};
res
.
code
=
catalogGetTableMeta
((
const
SName
*
)
taosArrayGet
(
pReq
->
pTables
,
j
),
(
STableMeta
**
)
&
res
.
pRes
);
taosArrayPush
(
*
pTableMetaData
,
&
res
);
}
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -485,13 +489,17 @@ class MockCatalogServiceImpl {
int32_t
getAllTableVgroup
(
SArray
*
pTableVgroupReq
,
SArray
**
pTableVgroupData
)
const
{
if
(
NULL
!=
pTableVgroupReq
)
{
int32_t
ntables
=
taosArrayGetSize
(
pTableVgroupReq
);
*
pTableVgroupData
=
taosArrayInit
(
ntables
,
sizeof
(
SMetaRes
));
for
(
int32_t
i
=
0
;
i
<
ntables
;
++
i
)
{
SMetaRes
res
=
{
0
};
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupInfo
));
res
.
code
=
catalogGetTableHashVgroup
((
const
SName
*
)
taosArrayGet
(
pTableVgroupReq
,
i
),
(
SVgroupInfo
*
)
res
.
pRes
);
taosArrayPush
(
*
pTableVgroupData
,
&
res
);
int32_t
ndbs
=
taosArrayGetSize
(
pTableVgroupReq
);
*
pTableVgroupData
=
taosArrayInit
(
ndbs
,
sizeof
(
SMetaRes
));
for
(
int32_t
i
=
0
;
i
<
ndbs
;
++
i
)
{
STablesReq
*
pReq
=
(
STablesReq
*
)
taosArrayGet
(
pTableVgroupReq
,
i
);
int32_t
ntables
=
taosArrayGetSize
(
pReq
->
pTables
);
for
(
int32_t
j
=
0
;
j
<
ntables
;
++
j
)
{
SMetaRes
res
=
{
0
};
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupInfo
));
res
.
code
=
catalogGetTableHashVgroup
((
const
SName
*
)
taosArrayGet
(
pReq
->
pTables
,
j
),
(
SVgroupInfo
*
)
res
.
pRes
);
taosArrayPush
(
*
pTableVgroupData
,
&
res
);
}
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -677,12 +685,17 @@ int32_t MockCatalogService::catalogGetAllMeta(const SCatalogReq* pCatalogReq, SM
return
impl_
->
catalogGetAllMeta
(
pCatalogReq
,
pMetaData
);
}
void
MockCatalogService
::
destoryTablesReq
(
void
*
p
)
{
STablesReq
*
pRes
=
(
STablesReq
*
)
p
;
taosArrayDestroy
(
pRes
->
pTables
);
}
void
MockCatalogService
::
destoryCatalogReq
(
SCatalogReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pDbVgroup
);
taosArrayDestroy
(
pReq
->
pDbCfg
);
taosArrayDestroy
(
pReq
->
pDbInfo
);
taosArrayDestroy
(
pReq
->
pTableMeta
);
taosArrayDestroy
(
pReq
->
pTableHash
);
taosArrayDestroy
Ex
(
pReq
->
pTableMeta
,
destoryTablesReq
);
taosArrayDestroy
Ex
(
pReq
->
pTableHash
,
destoryTablesReq
);
taosArrayDestroy
(
pReq
->
pUdf
);
taosArrayDestroy
(
pReq
->
pIndex
);
taosArrayDestroy
(
pReq
->
pUser
);
...
...
source/libs/parser/test/mockCatalogService.h
浏览文件 @
e1881185
...
...
@@ -50,6 +50,7 @@ struct MockTableMeta {
class
MockCatalogServiceImpl
;
class
MockCatalogService
{
public:
static
void
destoryTablesReq
(
void
*
p
);
static
void
destoryCatalogReq
(
SCatalogReq
*
pReq
);
static
void
destoryMetaRes
(
void
*
p
);
static
void
destoryMetaArrayRes
(
void
*
p
);
...
...
source/libs/parser/test/parInsertTest.cpp
浏览文件 @
e1881185
...
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <functional>
#include <gtest/gtest.h>
#include "mockCatalogService.h"
...
...
@@ -20,6 +22,7 @@
#include "parInt.h"
using
namespace
std
;
using
namespace
std
::
placeholders
;
using
namespace
testing
;
namespace
{
...
...
@@ -63,7 +66,9 @@ class InsertTest : public Test {
int32_t
runAsync
()
{
cxt_
.
async
=
true
;
unique_ptr
<
SParseMetaCache
,
void
(
*
)(
SParseMetaCache
*
)
>
metaCache
(
new
SParseMetaCache
(),
_destoryParseMetaCache
);
bool
request
=
true
;
unique_ptr
<
SParseMetaCache
,
function
<
void
(
SParseMetaCache
*
)
>
>
metaCache
(
new
SParseMetaCache
(),
std
::
bind
(
_destoryParseMetaCache
,
_1
,
cref
(
request
)));
code_
=
parseInsertSyntax
(
&
cxt_
,
&
res_
,
metaCache
.
get
());
if
(
code_
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"parseInsertSyntax code:"
<<
toString
(
code_
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
...
...
@@ -81,6 +86,8 @@ class InsertTest : public Test {
unique_ptr
<
SMetaData
,
void
(
*
)(
SMetaData
*
)
>
metaData
(
new
SMetaData
(),
MockCatalogService
::
destoryMetaData
);
g_mockCatalogService
->
catalogGetAllMeta
(
catalogReq
.
get
(),
metaData
.
get
());
metaCache
.
reset
(
new
SParseMetaCache
());
request
=
false
;
code_
=
putMetaDataToCache
(
catalogReq
.
get
(),
metaData
.
get
(),
metaCache
.
get
());
if
(
code_
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"putMetaDataToCache code:"
<<
toString
(
code_
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
...
...
@@ -144,8 +151,8 @@ class InsertTest : public Test {
static
const
int
max_err_len
=
1024
;
static
const
int
max_sql_len
=
1024
*
1024
;
static
void
_destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
)
{
destoryParseMetaCache
(
pMetaCache
);
static
void
_destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
,
bool
request
)
{
destoryParseMetaCache
(
pMetaCache
,
request
);
delete
pMetaCache
;
}
...
...
source/libs/parser/test/parTestUtil.cpp
浏览文件 @
e1881185
...
...
@@ -24,6 +24,7 @@
#include "parInt.h"
using
namespace
std
;
using
namespace
std
::
placeholders
;
using
namespace
testing
;
namespace
ParserTest
{
...
...
@@ -118,8 +119,8 @@ class ParserTestBaseImpl {
TEST_INTERFACE_ASYNC_API
};
static
void
_destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
)
{
destoryParseMetaCache
(
pMetaCache
);
static
void
_destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
,
bool
request
)
{
destoryParseMetaCache
(
pMetaCache
,
request
);
delete
pMetaCache
;
}
...
...
@@ -340,7 +341,9 @@ class ParserTestBaseImpl {
doParse
(
&
cxt
,
query
.
get
());
SQuery
*
pQuery
=
*
(
query
.
get
());
unique_ptr
<
SParseMetaCache
,
void
(
*
)(
SParseMetaCache
*
)
>
metaCache
(
new
SParseMetaCache
(),
_destoryParseMetaCache
);
bool
request
=
true
;
unique_ptr
<
SParseMetaCache
,
function
<
void
(
SParseMetaCache
*
)
>
>
metaCache
(
new
SParseMetaCache
(),
bind
(
_destoryParseMetaCache
,
_1
,
cref
(
request
)));
doCollectMetaKey
(
&
cxt
,
pQuery
,
metaCache
.
get
());
unique_ptr
<
SCatalogReq
,
void
(
*
)(
SCatalogReq
*
)
>
catalogReq
(
new
SCatalogReq
(),
...
...
@@ -353,6 +356,8 @@ class ParserTestBaseImpl {
unique_ptr
<
SMetaData
,
void
(
*
)(
SMetaData
*
)
>
metaData
(
new
SMetaData
(),
MockCatalogService
::
destoryMetaData
);
doGetAllMeta
(
catalogReq
.
get
(),
metaData
.
get
());
metaCache
.
reset
(
new
SParseMetaCache
());
request
=
false
;
doPutMetaDataToCache
(
catalogReq
.
get
(),
metaData
.
get
(),
metaCache
.
get
());
doAuthenticate
(
&
cxt
,
pQuery
,
metaCache
.
get
());
...
...
source/libs/planner/src/planner.c
浏览文件 @
e1881185
...
...
@@ -85,7 +85,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
}
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
)
{
planDebug
(
"QID:0x%"
PRIx64
" set subplan execution node, groupId:%d"
,
subplan
->
id
.
group
Id
,
groupId
);
planDebug
(
"QID:0x%"
PRIx64
" set subplan execution node, groupId:%d"
,
subplan
->
id
.
query
Id
,
groupId
);
return
setSubplanExecutionNode
(
subplan
->
pNode
,
groupId
,
pSource
);
}
...
...
@@ -104,7 +104,10 @@ static void clearSubplanExecutionNode(SPhysiNode* pNode) {
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
clearSubplanExecutionNode
((
SPhysiNode
*
)
pChild
);
}
}
void
qClearSubplanExecutionNode
(
SSubplan
*
pSubplan
)
{
clearSubplanExecutionNode
(
pSubplan
->
pNode
);
}
void
qClearSubplanExecutionNode
(
SSubplan
*
pSubplan
)
{
planDebug
(
"QID:0x%"
PRIx64
" clear subplan execution node, groupId:%d"
,
pSubplan
->
id
.
queryId
,
pSubplan
->
id
.
groupId
);
clearSubplanExecutionNode
(
pSubplan
->
pNode
);
}
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
)
{
if
(
SUBPLAN_TYPE_MODIFY
==
pSubplan
->
subplanType
&&
NULL
==
pSubplan
->
pNode
)
{
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
e1881185
...
...
@@ -462,3 +462,5 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) {
return
TSDB_CODE_SUCCESS
;
}
source/libs/qworker/inc/qwMsg.h
浏览文件 @
e1881185
...
...
@@ -25,7 +25,7 @@ extern "C" {
int32_t
qwAbortPrerocessQuery
(
QW_FPARAMS_DEF
);
int32_t
qwPreprocessQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
);
int32_t
qwProcessQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
,
c
onst
c
har
*
sql
);
int32_t
qwProcessQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
,
char
*
sql
);
int32_t
qwProcessCQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
);
int32_t
qwProcessReady
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
);
int32_t
qwProcessFetch
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
);
...
...
source/libs/qworker/src/qwMsg.c
浏览文件 @
e1881185
...
...
@@ -387,10 +387,13 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int
char
*
sql
=
strndup
(
msg
->
msg
,
msg
->
sqlLen
);
QW_SCH_TASK_DLOG
(
"processQuery start, node:%p, type:%s, handle:%p, SQL:%s"
,
node
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
info
.
handle
,
sql
);
QW_ERR_RET
(
qwProcessQuery
(
QW_FPARAMS
(),
&
qwMsg
,
sql
));
QW_SCH_TASK_DLOG
(
"processQuery end, node:%p"
,
node
);
QW_ERR_JRET
(
qwProcessQuery
(
QW_FPARAMS
(),
&
qwMsg
,
sql
));
return
TSDB_CODE_SUCCESS
;
_return:
QW_SCH_TASK_DLOG
(
"processQuery end, node:%p, code:%d"
,
node
,
code
);
return
code
;
}
int32_t
qWorkerProcessCQueryMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
,
int64_t
ts
)
{
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
e1881185
...
...
@@ -508,7 +508,7 @@ _return:
}
int32_t
qwProcessQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
,
c
onst
c
har
*
sql
)
{
int32_t
qwProcessQuery
(
QW_FPARAMS_DEF
,
SQWMsg
*
qwMsg
,
char
*
sql
)
{
int32_t
code
=
0
;
bool
queryRsped
=
false
;
SSubplan
*
plan
=
NULL
;
...
...
@@ -536,6 +536,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
}
code
=
qCreateExecTask
(
qwMsg
->
node
,
mgmt
->
nodeId
,
tId
,
plan
,
&
pTaskInfo
,
&
sinkHandle
,
sql
,
OPTR_EXEC_MODEL_BATCH
);
sql
=
NULL
;
if
(
code
)
{
QW_TASK_ELOG
(
"qCreateExecTask failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_ERR_JRET
(
code
);
...
...
@@ -561,6 +562,8 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, const char* sql) {
_return:
taosMemoryFree
(
sql
);
input
.
code
=
code
;
input
.
msgType
=
qwMsg
->
msgType
;
code
=
qwHandlePostPhaseEvents
(
QW_FPARAMS
(),
QW_PHASE_POST_QUERY
,
&
input
,
NULL
);
...
...
source/libs/scheduler/src/schStatus.c
浏览文件 @
e1881185
...
...
@@ -64,7 +64,7 @@ _return:
int32_t
schHandleOpBeginEvent
(
int64_t
jobId
,
SSchJob
**
job
,
SCH_OP_TYPE
type
,
SSchedulerReq
*
pReq
)
{
SSchJob
*
pJob
=
schAcquireJob
(
jobId
);
if
(
NULL
==
pJob
)
{
q
Error
(
"Acquire sch job failed, may be dropped, jobId:0x%"
PRIx64
,
jobId
);
q
Warn
(
"Acquire sch job failed, may be dropped, jobId:0x%"
PRIx64
,
jobId
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
source/libs/scheduler/src/schTask.c
浏览文件 @
e1881185
...
...
@@ -284,7 +284,6 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
for
(
int32_t
i
=
0
;
i
<
parentNum
;
++
i
)
{
SSchTask
*
parent
=
*
(
SSchTask
**
)
taosArrayGet
(
pTask
->
parents
,
i
);
int32_t
readyNum
=
atomic_add_fetch_32
(
&
parent
->
childReady
,
1
);
SCH_LOCK
(
SCH_WRITE
,
&
parent
->
planLock
);
SDownstreamSourceNode
source
=
{
...
...
@@ -298,6 +297,8 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
qSetSubplanExecutionNode
(
parent
->
plan
,
pTask
->
plan
->
id
.
groupId
,
&
source
);
SCH_UNLOCK
(
SCH_WRITE
,
&
parent
->
planLock
);
int32_t
readyNum
=
atomic_add_fetch_32
(
&
parent
->
childReady
,
1
);
if
(
SCH_TASK_READY_FOR_LAUNCH
(
readyNum
,
parent
))
{
SCH_TASK_DLOG
(
"all %d children task done, start to launch parent task 0x%"
PRIx64
,
readyNum
,
parent
->
taskId
);
SCH_ERR_RET
(
schLaunchTask
(
pJob
,
parent
));
...
...
@@ -536,6 +537,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) {
int32_t
schTaskCheckSetRetry
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
int32_t
errCode
,
bool
*
needRetry
)
{
if
(
TSDB_CODE_SCH_TIMEOUT_ERROR
==
errCode
)
{
pTask
->
maxExecTimes
++
;
pTask
->
maxRetryTimes
++
;
if
(
pTask
->
timeoutUsec
<
SCH_MAX_TASK_TIMEOUT_USEC
)
{
pTask
->
timeoutUsec
*=
2
;
if
(
pTask
->
timeoutUsec
>
SCH_MAX_TASK_TIMEOUT_USEC
)
{
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
e1881185
...
...
@@ -150,7 +150,7 @@ void schedulerFreeJob(int64_t* jobId, int32_t errCode) {
SSchJob
*
pJob
=
schAcquireJob
(
*
jobId
);
if
(
NULL
==
pJob
)
{
q
Error
(
"Acquire sch job failed, may be dropped, jobId:0x%"
PRIx64
,
*
jobId
);
q
Warn
(
"Acquire sch job failed, may be dropped, jobId:0x%"
PRIx64
,
*
jobId
);
return
;
}
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
e1881185
...
...
@@ -94,9 +94,10 @@ typedef void* queue[2];
/* Return the structure holding the given element. */
#define QUEUE_DATA(e, type, field) ((type*)((void*)((char*)(e)-offsetof(type, field))))
#define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit
#define TRANS_RETRY_INTERVAL 15 // ms retry interval
#define TRANS_CONN_TIMEOUT 3 // connect timeout
#define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit
#define TRANS_RETRY_INTERVAL 15 // retry interval (ms)
#define TRANS_CONN_TIMEOUT 3 // connect timeout (s)
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
typedef
SRpcMsg
STransMsg
;
typedef
SRpcCtx
STransCtx
;
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
e1881185
...
...
@@ -53,6 +53,7 @@ typedef struct {
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
bool
(
*
retry
)(
int32_t
code
,
tmsg_t
msgType
);
bool
(
*
startTimer
)(
int32_t
code
,
tmsg_t
msgType
);
int
index
;
void
*
parent
;
...
...
source/libs/transport/src/trans.c
浏览文件 @
e1881185
...
...
@@ -48,6 +48,7 @@ void* rpcOpen(const SRpcInit* pInit) {
// register callback handle
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
retry
=
pInit
->
rfp
;
pRpc
->
startTimer
=
pInit
->
tfp
;
if
(
pInit
->
connType
==
TAOS_CONN_SERVER
)
{
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
...
...
source/libs/transport/src/transCli.c
浏览文件 @
e1881185
...
...
@@ -24,6 +24,7 @@ typedef struct SCliConn {
uv_connect_t
connReq
;
uv_stream_t
*
stream
;
queue
wreqQueue
;
uv_timer_t
*
timer
;
void
*
hostThrd
;
...
...
@@ -65,12 +66,13 @@ typedef struct SCliThrd {
int64_t
pid
;
// pid
uv_loop_t
*
loop
;
SAsyncPool
*
asyncPool
;
uv_idle_t
*
idle
;
uv_prepare_t
*
prepare
;
uv_timer_t
timer
;
void
*
pool
;
// conn pool
SArray
*
timerList
;
// msg queue
queue
msg
;
TdThreadMutex
msgMtx
;
SDelayQueue
*
delayQueue
;
...
...
@@ -108,6 +110,8 @@ static int sockDebugInfo(struct sockaddr* sockname, char* dst) {
sprintf
(
dst
,
"%s:%d"
,
buf
,
ntohs
(
addr
.
sin_port
));
return
r
;
}
// register timer for read
static
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
);
// register timer in each thread to clear expire conn
// static void cliTimeoutCb(uv_timer_t* handle);
// alloc buf for recv
...
...
@@ -330,6 +334,16 @@ void cliHandleResp(SCliConn* conn) {
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
if
(
conn
->
timer
)
{
if
(
uv_is_active
((
uv_handle_t
*
)
conn
->
timer
))
{
tDebug
(
"%s conn %p stop timer"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
uv_timer_stop
(
conn
->
timer
);
}
conn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
=
NULL
;
}
STransMsgHead
*
pHead
=
NULL
;
transDumpFromBuffer
(
&
conn
->
readBuf
,
(
char
**
)
&
pHead
);
pHead
->
code
=
htonl
(
pHead
->
code
);
...
...
@@ -409,7 +423,7 @@ void cliHandleResp(SCliConn* conn) {
uv_read_start
((
uv_stream_t
*
)
conn
->
stream
,
cliAllocRecvBufferCb
,
cliRecvCb
);
}
void
cliHandleExcept
(
SCliConn
*
pConn
)
{
void
cliHandleExcept
Impl
(
SCliConn
*
pConn
,
int32_t
code
)
{
if
(
transQueueEmpty
(
&
pConn
->
cliMsgs
))
{
if
(
pConn
->
broken
==
true
&&
CONN_NO_PERSIST_BY_APP
(
pConn
))
{
tTrace
(
"%s conn %p handle except, persist:0"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
...
...
@@ -428,7 +442,7 @@ void cliHandleExcept(SCliConn* pConn) {
STransConnCtx
*
pCtx
=
pMsg
?
pMsg
->
ctx
:
NULL
;
STransMsg
transMsg
=
{
0
};
transMsg
.
code
=
pConn
->
broken
?
TSDB_CODE_RPC_BROKEN_LINK
:
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
transMsg
.
code
=
code
==
-
1
?
(
pConn
->
broken
?
TSDB_CODE_RPC_BROKEN_LINK
:
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
:
code
;
transMsg
.
msgType
=
pMsg
?
pMsg
->
msg
.
msgType
+
1
:
0
;
transMsg
.
info
.
ahandle
=
NULL
;
...
...
@@ -459,31 +473,17 @@ void cliHandleExcept(SCliConn* pConn) {
}
while
(
!
transQueueEmpty
(
&
pConn
->
cliMsgs
));
transUnrefCliHandle
(
pConn
);
}
void
cliHandleExcept
(
SCliConn
*
conn
)
{
tTrace
(
"%s conn %p except ref:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
T_REF_VAL_GET
(
conn
));
cliHandleExceptImpl
(
conn
,
-
1
);
}
// void cliTimeoutCb(uv_timer_t* handle) {
// SCliThrd* pThrd = handle->data;
// STrans* pTransInst = pThrd->pTransInst;
// int64_t currentTime = pThrd->nextTimeout;
// tTrace("%s conn timeout, try to remove expire conn from conn pool", pTransInst->label);
//
// SConnList* p = taosHashIterate((SHashObj*)pThrd->pool, NULL);
// while (p != NULL) {
// while (!QUEUE_IS_EMPTY(&p->conn)) {
// queue* h = QUEUE_HEAD(&p->conn);
// SCliConn* c = QUEUE_DATA(h, SCliConn, q);
// if (c->expireTime < currentTime) {
// QUEUE_REMOVE(h);
// transUnrefCliHandle(c);
// } else {
// break;
// }
// }
// p = taosHashIterate((SHashObj*)pThrd->pool, p);
// }
//
// pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime);
// uv_timer_start(handle, cliTimeoutCb, CONN_PERSIST_TIME(pTransInst->idleTime) / 2, 0);
// }
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
)
{
// set up timeout cb
SCliConn
*
conn
=
handle
->
data
;
tTrace
(
"%s conn %p timeout, ref:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
T_REF_VAL_GET
(
conn
));
cliHandleExceptImpl
(
conn
,
TSDB_CODE_RPC_TIMEOUT
);
}
void
*
createConnPool
(
int
size
)
{
// thread local, no lock
...
...
@@ -654,13 +654,23 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
return
conn
;
}
static
void
cliDestroyConn
(
SCliConn
*
conn
,
bool
clear
)
{
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
tTrace
(
"%s conn %p remove from conn pool"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
QUEUE_REMOVE
(
&
conn
->
q
);
QUEUE_INIT
(
&
conn
->
q
);
transRemoveExHandle
(
transGetRefMgt
(),
conn
->
refId
);
conn
->
refId
=
-
1
;
if
(
conn
->
task
!=
NULL
)
transDQCancel
(((
SCliThrd
*
)
conn
->
hostThrd
)
->
timeoutQueue
,
conn
->
task
);
if
(
conn
->
task
!=
NULL
)
{
transDQCancel
(
pThrd
->
timeoutQueue
,
conn
->
task
);
conn
->
task
=
NULL
;
}
if
(
conn
->
timer
!=
NULL
)
{
uv_timer_stop
(
conn
->
timer
);
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
->
data
=
NULL
;
conn
->
timer
=
NULL
;
}
if
(
clear
)
{
if
(
!
uv_is_closing
((
uv_handle_t
*
)
conn
->
stream
))
{
...
...
@@ -673,8 +683,15 @@ static void cliDestroy(uv_handle_t* handle) {
if
(
uv_handle_get_type
(
handle
)
!=
UV_TCP
||
handle
->
data
==
NULL
)
{
return
;
}
SCliConn
*
conn
=
handle
->
data
;
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
if
(
conn
->
timer
!=
NULL
)
{
uv_timer_stop
(
conn
->
timer
);
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
->
data
=
NULL
;
conn
->
timer
=
NULL
;
}
transRemoveExHandle
(
transGetRefMgt
(),
conn
->
refId
);
taosMemoryFree
(
conn
->
ip
);
conn
->
stream
->
data
=
NULL
;
...
...
@@ -764,6 +781,19 @@ void cliSend(SCliConn* pConn) {
CONN_SET_PERSIST_BY_APP
(
pConn
);
}
if
(
pTransInst
->
startTimer
!=
NULL
&&
pTransInst
->
startTimer
(
0
,
pMsg
->
msgType
))
{
uv_timer_t
*
timer
=
taosArrayGetSize
(
pThrd
->
timerList
)
>
0
?
*
(
uv_timer_t
**
)
taosArrayPop
(
pThrd
->
timerList
)
:
NULL
;
if
(
timer
==
NULL
)
{
tDebug
(
"no avaiable timer, create"
);
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
uv_timer_init
(
pThrd
->
loop
,
timer
);
}
timer
->
data
=
pConn
;
pConn
->
timer
=
timer
;
tGTrace
(
"%s conn %p start timer for msg:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
TMSG_INFO
(
pMsg
->
msgType
));
uv_timer_start
((
uv_timer_t
*
)
pConn
->
timer
,
cliReadTimeoutCb
,
TRANS_READ_TIMEOUT
,
0
);
}
uv_write_t
*
req
=
transReqQueuePush
(
&
pConn
->
wreqQueue
);
uv_write
(
req
,
(
uv_stream_t
*
)
pConn
->
stream
,
&
wb
,
1
,
cliSendCb
);
return
;
...
...
@@ -781,8 +811,8 @@ void cliConnCb(uv_connect_t* req, int status) {
}
// int addrlen = sizeof(pConn->addr);
struct
sockaddr
peername
,
sockname
;
int
addrlen
=
sizeof
(
peername
);
int
addrlen
=
sizeof
(
peername
);
uv_tcp_getpeername
((
uv_tcp_t
*
)
pConn
->
stream
,
&
peername
,
&
addrlen
);
transGetSockDebugInfo
(
&
peername
,
pConn
->
dst
);
...
...
@@ -806,7 +836,6 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrd* pThrd) {
tDebug
(
"cli work thread %p start to quit"
,
pThrd
);
destroyCmsg
(
pMsg
);
destroyConnPool
(
pThrd
->
pool
);
uv_timer_stop
(
&
pThrd
->
timer
);
uv_walk
(
pThrd
->
loop
,
cliWalkCb
,
NULL
);
}
static
void
cliHandleRelease
(
SCliMsg
*
pMsg
,
SCliThrd
*
pThrd
)
{
...
...
@@ -879,8 +908,8 @@ void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) {
}
}
void
cliHandleReq
(
SCliMsg
*
pMsg
,
SCliThrd
*
pThrd
)
{
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
cliMayCvtFqdnToIp
(
&
pCtx
->
epSet
,
&
pThrd
->
cvtAddr
);
if
(
!
EPSET_IS_VALID
(
&
pCtx
->
epSet
))
{
...
...
@@ -966,36 +995,6 @@ static void cliAsyncCb(uv_async_t* handle) {
}
if
(
pThrd
->
stopMsg
!=
NULL
)
cliHandleQuit
(
pThrd
->
stopMsg
,
pThrd
);
}
static
void
cliIdleCb
(
uv_idle_t
*
handle
)
{
SCliThrd
*
thrd
=
handle
->
data
;
tTrace
(
"do idle work"
);
SAsyncPool
*
pool
=
thrd
->
asyncPool
;
for
(
int
i
=
0
;
i
<
pool
->
nAsync
;
i
++
)
{
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
i
]);
SAsyncItem
*
item
=
async
->
data
;
queue
wq
;
taosThreadMutexLock
(
&
item
->
mtx
);
QUEUE_MOVE
(
&
item
->
qmsg
,
&
wq
);
taosThreadMutexUnlock
(
&
item
->
mtx
);
int
count
=
0
;
while
(
!
QUEUE_IS_EMPTY
(
&
wq
))
{
queue
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
SCliMsg
*
pMsg
=
QUEUE_DATA
(
h
,
SCliMsg
,
q
);
if
(
pMsg
==
NULL
)
{
continue
;
}
(
*
cliAsyncHandle
[
pMsg
->
type
])(
pMsg
,
thrd
);
count
++
;
}
}
tTrace
(
"prepare work end"
);
if
(
thrd
->
stopMsg
!=
NULL
)
cliHandleQuit
(
thrd
->
stopMsg
,
thrd
);
}
static
void
cliPrepareCb
(
uv_prepare_t
*
handle
)
{
SCliThrd
*
thrd
=
handle
->
data
;
tTrace
(
"prepare work start"
);
...
...
@@ -1085,19 +1084,20 @@ static SCliThrd* createThrdObj() {
uv_loop_init
(
pThrd
->
loop
);
pThrd
->
asyncPool
=
transAsyncPoolCreate
(
pThrd
->
loop
,
5
,
pThrd
,
cliAsyncCb
);
uv_timer_init
(
pThrd
->
loop
,
&
pThrd
->
timer
);
pThrd
->
timer
.
data
=
pThrd
;
// pThrd->idle = taosMemoryCalloc(1, sizeof(uv_idle_t));
// uv_idle_init(pThrd->loop, pThrd->idle);
// pThrd->idle->data = pThrd;
// uv_idle_start(pThrd->idle, cliIdleCb);
pThrd
->
prepare
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_prepare_t
));
uv_prepare_init
(
pThrd
->
loop
,
pThrd
->
prepare
);
pThrd
->
prepare
->
data
=
pThrd
;
uv_prepare_start
(
pThrd
->
prepare
,
cliPrepareCb
);
int32_t
timerSize
=
512
;
pThrd
->
timerList
=
taosArrayInit
(
timerSize
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
timerSize
;
i
++
)
{
uv_timer_t
*
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
uv_timer_init
(
pThrd
->
loop
,
timer
);
taosArrayPush
(
pThrd
->
timerList
,
&
timer
);
}
pThrd
->
pool
=
createConnPool
(
4
);
transDQCreate
(
pThrd
->
loop
,
&
pThrd
->
delayQueue
);
...
...
@@ -1120,7 +1120,12 @@ static void destroyThrdObj(SCliThrd* pThrd) {
transDQDestroy
(
pThrd
->
delayQueue
,
destroyCmsg
);
transDQDestroy
(
pThrd
->
timeoutQueue
,
NULL
);
taosMemoryFree
(
pThrd
->
idle
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pThrd
->
timerList
);
i
++
)
{
uv_timer_t
*
timer
=
taosArrayGetP
(
pThrd
->
timerList
,
i
);
taosMemoryFree
(
timer
);
}
taosArrayDestroy
(
pThrd
->
timerList
);
taosMemoryFree
(
pThrd
->
prepare
);
taosMemoryFree
(
pThrd
->
loop
);
taosMemoryFree
(
pThrd
);
...
...
source/os/src/osSocket.c
浏览文件 @
e1881185
...
...
@@ -333,7 +333,7 @@ int32_t taosWriteMsg(TdSocketPtr pSocket, void *buf, int32_t nbytes) {
return
-
1
;
}
int32_t
nleft
,
nwritten
;
char
*
ptr
=
(
char
*
)
buf
;
char
*
ptr
=
(
char
*
)
buf
;
nleft
=
nbytes
;
...
...
@@ -362,7 +362,7 @@ int32_t taosReadMsg(TdSocketPtr pSocket, void *buf, int32_t nbytes) {
return
-
1
;
}
int32_t
nleft
,
nread
;
char
*
ptr
=
(
char
*
)
buf
;
char
*
ptr
=
(
char
*
)
buf
;
nleft
=
nbytes
;
...
...
@@ -912,7 +912,7 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
int32_t
ret
=
getaddrinfo
(
fqdn
,
NULL
,
&
hints
,
&
result
);
if
(
result
)
{
struct
sockaddr
*
sa
=
result
->
ai_addr
;
struct
sockaddr
*
sa
=
result
->
ai_addr
;
struct
sockaddr_in
*
si
=
(
struct
sockaddr_in
*
)
sa
;
struct
in_addr
ia
=
si
->
sin_addr
;
uint32_t
ip
=
ia
.
s_addr
;
...
...
source/util/src/terror.c
浏览文件 @
e1881185
...
...
@@ -52,6 +52,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, "Unable to establish c
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_FQDN_ERROR
,
"Unable to resolve FQDN"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_PORT_EADDRINUSE
,
"Port already in use"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_BROKEN_LINK
,
"Conn is broken"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_TIMEOUT
,
"Conn read timeout"
)
//common & util
TAOS_DEFINE_ERROR
(
TSDB_CODE_TIME_UNSYNCED
,
"Client and server's time is not synchronized"
)
...
...
tests/parallel_test/run_case.sh
浏览文件 @
e1881185
...
...
@@ -49,11 +49,13 @@ if [ $ent -eq 0 ]; then
export
PATH
=
$PATH
:/home/TDengine/debug/build/bin
export
LD_LIBRARY_PATH
=
/home/TDengine/debug/build/lib
ln
-s
/home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
ln
-s
/home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null
CONTAINER_TESTDIR
=
/home/TDengine
else
export
PATH
=
$PATH
:/home/TDinternal/debug/build/bin
export
LD_LIBRARY_PATH
=
/home/TDinternal/debug/build/lib
ln
-s
/home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
ln
-s
/home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null
CONTAINER_TESTDIR
=
/home/TDinternal/community
fi
mkdir
-p
/var/lib/taos/subscribe
...
...
tests/parallel_test/run_container.sh
浏览文件 @
e1881185
...
...
@@ -100,6 +100,7 @@ docker run \
-v
"
$TMP_DIR
/thread_volume/
$thread_no
/sim:
${
SIM_DIR
}
"
\
-v
${
TMP_DIR
}
/thread_volume/
$thread_no
/coredump:
$coredump_dir
\
-v
$WORKDIR
/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro
\
-v
$WORKDIR
/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro
\
--rm
--ulimit
core
=
-1
taos_test:v1.0
$CONTAINER_TESTDIR
/tests/parallel_test/run_case.sh
-d
"
$exec_dir
"
-c
"
$cmd
"
$extra_param
ret
=
$?
exit
$ret
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录