Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb7a06e0
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看板
未验证
提交
fb7a06e0
编写于
5月 17, 2023
作者:
D
dapan1121
提交者:
GitHub
5月 17, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21271 from taosdata/enh/tsbsPerf.4
Enh/tsbs perf.4
上级
d457b84a
3e2c8a91
变更
47
显示空白变更内容
内联
并排
Showing
47 changed file
with
1186 addition
and
439 deletion
+1186
-439
cmake/cmake.define
cmake/cmake.define
+3
-0
cmake/cmake.options
cmake/cmake.options
+5
-0
include/common/tmsg.h
include/common/tmsg.h
+18
-5
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+6
-4
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+1
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-0
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+3
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+37
-31
source/common/src/tmsg.c
source/common/src/tmsg.c
+164
-85
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+5
-0
source/dnode/mnode/impl/inc/mndDb.h
source/dnode/mnode/impl/inc/mndDb.h
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+118
-92
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+1
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+7
-1
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+209
-2
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+4
-0
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+12
-0
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+36
-5
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+30
-10
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+37
-5
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+19
-3
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+167
-28
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+19
-0
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+14
-8
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+4
-4
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+19
-1
source/libs/executor/inc/executorInt.h
source/libs/executor/inc/executorInt.h
+1
-0
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+14
-9
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+0
-3
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+72
-41
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+2
-2
source/libs/executor/src/executorInt.c
source/libs/executor/src/executorInt.c
+18
-15
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+39
-6
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+1
-1
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+10
-14
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+8
-0
source/libs/qworker/inc/qwInt.h
source/libs/qworker/inc/qwInt.h
+2
-1
source/libs/qworker/src/qwDbg.c
source/libs/qworker/src/qwDbg.c
+4
-4
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+52
-36
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+1
-1
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+2
-2
source/util/src/tarray.c
source/util/src/tarray.c
+4
-0
source/util/src/tcompression.c
source/util/src/tcompression.c
+12
-15
source/util/src/tlog.c
source/util/src/tlog.c
+1
-1
未找到文件。
cmake/cmake.define
浏览文件 @
fb7a06e0
...
@@ -119,6 +119,9 @@ ELSE ()
...
@@ -119,6 +119,9 @@ ELSE ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
MESSAGE(STATUS "Compile with Address Sanitizer!")
MESSAGE(STATUS "Compile with Address Sanitizer!")
ELSEIF (${BUILD_RELEASE})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -O3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
ELSE ()
ELSE ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
...
...
cmake/cmake.options
浏览文件 @
fb7a06e0
...
@@ -171,3 +171,8 @@ option(
...
@@ -171,3 +171,8 @@ option(
ON
ON
)
)
option(
BUILD_RELEASE
"If build release version"
OFF
)
include/common/tmsg.h
浏览文件 @
fb7a06e0
...
@@ -942,6 +942,9 @@ int32_t tSerializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq
...
@@ -942,6 +942,9 @@ int32_t tSerializeSVDropTtlTableReq(void* buf, int32_t bufLen, SVDropTtlTableReq
int32_t
tDeserializeSVDropTtlTableReq
(
void
*
buf
,
int32_t
bufLen
,
SVDropTtlTableReq
*
pReq
);
int32_t
tDeserializeSVDropTtlTableReq
(
void
*
buf
,
int32_t
bufLen
,
SVDropTtlTableReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int32_t
cfgVersion
;
int32_t
numOfVgroups
;
int32_t
numOfVgroups
;
int32_t
numOfStables
;
int32_t
numOfStables
;
int32_t
buffer
;
int32_t
buffer
;
...
@@ -974,8 +977,13 @@ typedef struct {
...
@@ -974,8 +977,13 @@ typedef struct {
int16_t
sstTrigger
;
int16_t
sstTrigger
;
}
SDbCfgRsp
;
}
SDbCfgRsp
;
typedef
SDbCfgRsp
SDbCfgInfo
;
int32_t
tSerializeSDbCfgRspImpl
(
SEncoder
*
encoder
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
);
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
);
int32_t
tDeserializeSDbCfgRspImpl
(
SDecoder
*
decoder
,
SDbCfgRsp
*
pRsp
);
void
tFreeSDbCfgRsp
(
SDbCfgRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int32_t
rowNum
;
int32_t
rowNum
;
...
@@ -1032,12 +1040,17 @@ int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp
...
@@ -1032,12 +1040,17 @@ int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp
void
tFreeSDnodeListRsp
(
SDnodeListRsp
*
pRsp
);
void
tFreeSDnodeListRsp
(
SDnodeListRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
SArray
*
pArray
;
// Array of SUseDbRsp
SUseDbRsp
*
useDbRsp
;
}
SUseDbBatchRsp
;
SDbCfgRsp
*
cfgRsp
;
}
SDbHbRsp
;
typedef
struct
{
SArray
*
pArray
;
// Array of SDbHbRsp
}
SDbHbBatchRsp
;
int32_t
tSerializeS
UseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseD
bBatchRsp
*
pRsp
);
int32_t
tSerializeS
DbHbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbH
bBatchRsp
*
pRsp
);
int32_t
tDeserializeS
UseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseD
bBatchRsp
*
pRsp
);
int32_t
tDeserializeS
DbHbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbH
bBatchRsp
*
pRsp
);
void
tFreeS
UseDbBatchRsp
(
SUseD
bBatchRsp
*
pRsp
);
void
tFreeS
DbHbBatchRsp
(
SDbH
bBatchRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
SArray
*
pArray
;
// Array of SGetUserAuthRsp
SArray
*
pArray
;
// Array of SGetUserAuthRsp
...
...
include/libs/catalog/catalog.h
浏览文件 @
fb7a06e0
...
@@ -129,13 +129,14 @@ typedef struct SSTableVersion {
...
@@ -129,13 +129,14 @@ typedef struct SSTableVersion {
int32_t
smaVer
;
int32_t
smaVer
;
}
SSTableVersion
;
}
SSTableVersion
;
typedef
struct
SDb
VgVersion
{
typedef
struct
SDb
CacheInfo
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int64_t
dbId
;
int32_t
vgVersion
;
int32_t
vgVersion
;
int32_t
cfgVersion
;
int32_t
numOfTable
;
// unit is TSDB_TABLE_NUM_UNIT
int32_t
numOfTable
;
// unit is TSDB_TABLE_NUM_UNIT
int64_t
stateTs
;
int64_t
stateTs
;
}
SDb
VgVersion
;
}
SDb
CacheInfo
;
typedef
struct
STbSVersion
{
typedef
struct
STbSVersion
{
char
*
tbFName
;
char
*
tbFName
;
...
@@ -148,7 +149,6 @@ typedef struct SUserAuthVersion {
...
@@ -148,7 +149,6 @@ typedef struct SUserAuthVersion {
int32_t
version
;
int32_t
version
;
}
SUserAuthVersion
;
}
SUserAuthVersion
;
typedef
SDbCfgRsp
SDbCfgInfo
;
typedef
SUserIndexRsp
SIndexInfo
;
typedef
SUserIndexRsp
SIndexInfo
;
typedef
void
(
*
catalogCallback
)(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
);
typedef
void
(
*
catalogCallback
)(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
);
...
@@ -180,6 +180,8 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
...
@@ -180,6 +180,8 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
int32_t
catalogUpdateDBVgInfo
(
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
,
SDBVgInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgInfo
(
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
,
SDBVgInfo
*
dbInfo
);
int32_t
catalogUpdateDbCfg
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
,
SDbCfgInfo
*
cfgInfo
);
int32_t
catalogRemoveDB
(
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
);
int32_t
catalogRemoveDB
(
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
);
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
);
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
);
...
@@ -304,7 +306,7 @@ int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray*
...
@@ -304,7 +306,7 @@ int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray*
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTableVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTableVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDb
VgVersion
**
dbs
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDb
CacheInfo
**
dbs
,
uint32_t
*
num
);
int32_t
catalogGetExpiredUsers
(
SCatalog
*
pCtg
,
SUserAuthVersion
**
users
,
uint32_t
*
num
);
int32_t
catalogGetExpiredUsers
(
SCatalog
*
pCtg
,
SUserAuthVersion
**
users
,
uint32_t
*
num
);
...
...
include/libs/function/functionMgt.h
浏览文件 @
fb7a06e0
...
@@ -230,6 +230,7 @@ typedef enum EFuncDataRequired {
...
@@ -230,6 +230,7 @@ typedef enum EFuncDataRequired {
FUNC_DATA_REQUIRED_SMA_LOAD
,
FUNC_DATA_REQUIRED_SMA_LOAD
,
FUNC_DATA_REQUIRED_NOT_LOAD
,
FUNC_DATA_REQUIRED_NOT_LOAD
,
FUNC_DATA_REQUIRED_FILTEROUT
,
FUNC_DATA_REQUIRED_FILTEROUT
,
FUNC_DATA_REQUIRED_ALL_FILTEROUT
,
}
EFuncDataRequired
;
}
EFuncDataRequired
;
EFuncDataRequired
fmFuncDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
EFuncDataRequired
fmFuncDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
...
...
include/libs/nodes/nodes.h
浏览文件 @
fb7a06e0
...
@@ -307,6 +307,7 @@ void nodesDestroyAllocator(int64_t allocatorId);
...
@@ -307,6 +307,7 @@ void nodesDestroyAllocator(int64_t allocatorId);
SNode
*
nodesMakeNode
(
ENodeType
type
);
SNode
*
nodesMakeNode
(
ENodeType
type
);
void
nodesDestroyNode
(
SNode
*
pNode
);
void
nodesDestroyNode
(
SNode
*
pNode
);
void
nodesFree
(
void
*
p
);
SNodeList
*
nodesMakeList
();
SNodeList
*
nodesMakeList
();
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNode
*
pNode
);
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNode
*
pNode
);
...
...
include/libs/qcom/query.h
浏览文件 @
fb7a06e0
...
@@ -260,6 +260,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
...
@@ -260,6 +260,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
int32_t
cloneDbVgInfo
(
SDBVgInfo
*
pSrc
,
SDBVgInfo
**
pDst
);
int32_t
cloneDbVgInfo
(
SDBVgInfo
*
pSrc
,
SDBVgInfo
**
pDst
);
int32_t
cloneSVreateTbReq
(
SVCreateTbReq
*
pSrc
,
SVCreateTbReq
**
pDst
);
int32_t
cloneSVreateTbReq
(
SVCreateTbReq
*
pSrc
,
SVCreateTbReq
**
pDst
);
void
freeVgInfo
(
SDBVgInfo
*
vgInfo
);
void
freeVgInfo
(
SDBVgInfo
*
vgInfo
);
void
freeDbCfgInfo
(
SDbCfgInfo
*
pInfo
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int64_t
));
void
*
(
*
mallocFp
)(
int64_t
));
...
...
source/client/inc/clientLog.h
浏览文件 @
fb7a06e0
...
@@ -25,6 +25,7 @@ extern "C" {
...
@@ -25,6 +25,7 @@ extern "C" {
// clang-format off
// clang-format off
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscErrorL(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLongString("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarnL(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLongString("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarnL(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLongString("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
...
@@ -32,6 +33,8 @@ extern "C" {
...
@@ -32,6 +33,8 @@ extern "C" {
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscPerf(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", 0, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscPerf(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", 0, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscLog(...) do { taosPrintLog("TSC ", 0, DEBUG_FILE, __VA_ARGS__); } while(0)
#define tscLogL(...) do { taosPrintLongString("TSC ", 0, DEBUG_FILE, __VA_ARGS__); } while(0)
// clang-format on
// clang-format on
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/client/src/clientEnv.c
浏览文件 @
fb7a06e0
...
@@ -107,7 +107,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
...
@@ -107,7 +107,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
tsc
Warn
L
(
"slow query: %s, duration:%"
PRId64
,
pRequest
->
sqlstr
,
duration
);
tsc
Log
L
(
"slow query: %s, duration:%"
PRId64
,
pRequest
->
sqlstr
,
duration
);
}
}
releaseTscObj
(
pTscObj
->
id
);
releaseTscObj
(
pTscObj
->
id
);
...
...
source/client/src/clientHb.c
浏览文件 @
fb7a06e0
...
@@ -94,47 +94,52 @@ _return:
...
@@ -94,47 +94,52 @@ _return:
static
int32_t
hbProcessDBInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
static
int32_t
hbProcessDBInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
S
UseDbBatchRsp
batchUse
Rsp
=
{
0
};
S
DbHbBatchRsp
batch
Rsp
=
{
0
};
if
(
tDeserializeS
UseDbBatchRsp
(
value
,
valueLen
,
&
batchUse
Rsp
)
!=
0
)
{
if
(
tDeserializeS
DbHbBatchRsp
(
value
,
valueLen
,
&
batch
Rsp
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
code
=
terrno
;
goto
_return
;
}
}
int32_t
numOfBatchs
=
taosArrayGetSize
(
batch
Use
Rsp
.
pArray
);
int32_t
numOfBatchs
=
taosArrayGetSize
(
batchRsp
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
SUseDbRsp
*
rsp
=
taosArrayGet
(
batchUseRsp
.
pArray
,
i
);
SDbHbRsp
*
rsp
=
taosArrayGet
(
batchRsp
.
pArray
,
i
);
tscDebug
(
"hb db rsp, db:%s, vgVersion:%d, stateTs:%"
PRId64
", uid:%"
PRIx64
,
rsp
->
db
,
rsp
->
vgVersion
,
rsp
->
stateTs
,
if
(
rsp
->
useDbRsp
)
{
rsp
->
uid
);
tscDebug
(
"hb use db rsp, db:%s, vgVersion:%d, stateTs:%"
PRId64
", uid:%"
PRIx64
,
rsp
->
useDbRsp
->
db
,
rsp
->
useDbRsp
->
vgVersion
,
rsp
->
useDbRsp
->
stateTs
,
rsp
->
useDbRsp
->
uid
);
if
(
r
sp
->
vgVersion
<
0
)
{
if
(
rsp
->
useDbR
sp
->
vgVersion
<
0
)
{
code
=
catalogRemoveDB
(
pCatalog
,
rsp
->
db
,
r
sp
->
uid
);
code
=
catalogRemoveDB
(
pCatalog
,
rsp
->
useDbRsp
->
db
,
rsp
->
useDbR
sp
->
uid
);
}
else
{
}
else
{
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
code
=
hbGenerateVgInfoFromRsp
(
&
vgInfo
,
r
sp
);
code
=
hbGenerateVgInfoFromRsp
(
&
vgInfo
,
rsp
->
useDbR
sp
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
goto
_return
;
goto
_return
;
}
}
catalogUpdateDBVgInfo
(
pCatalog
,
rsp
->
db
,
r
sp
->
uid
,
vgInfo
);
catalogUpdateDBVgInfo
(
pCatalog
,
rsp
->
useDbRsp
->
db
,
rsp
->
useDbR
sp
->
uid
,
vgInfo
);
if
(
IS_SYS_DBNAME
(
r
sp
->
db
))
{
if
(
IS_SYS_DBNAME
(
rsp
->
useDbR
sp
->
db
))
{
code
=
hbGenerateVgInfoFromRsp
(
&
vgInfo
,
r
sp
);
code
=
hbGenerateVgInfoFromRsp
(
&
vgInfo
,
rsp
->
useDbR
sp
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
goto
_return
;
goto
_return
;
}
}
catalogUpdateDBVgInfo
(
pCatalog
,
(
rsp
->
db
[
0
]
==
'i'
)
?
TSDB_PERFORMANCE_SCHEMA_DB
:
TSDB_INFORMATION_SCHEMA_DB
,
rsp
->
uid
,
vgInfo
);
catalogUpdateDBVgInfo
(
pCatalog
,
(
rsp
->
useDbRsp
->
db
[
0
]
==
'i'
)
?
TSDB_PERFORMANCE_SCHEMA_DB
:
TSDB_INFORMATION_SCHEMA_DB
,
rsp
->
useDbRsp
->
uid
,
vgInfo
);
}
}
}
}
}
if
(
code
)
{
if
(
rsp
->
cfgRsp
)
{
goto
_return
;
tscDebug
(
"hb db cfg rsp, db:%s, cfgVersion:%d"
,
rsp
->
cfgRsp
->
db
,
rsp
->
cfgRsp
->
cfgVersion
);
catalogUpdateDbCfg
(
pCatalog
,
rsp
->
cfgRsp
->
db
,
rsp
->
cfgRsp
->
dbId
,
rsp
->
cfgRsp
);
rsp
->
cfgRsp
=
NULL
;
}
}
}
}
_return:
_return:
tFreeS
UseDbBatchRsp
(
&
batchUse
Rsp
);
tFreeS
DbHbBatchRsp
(
&
batch
Rsp
);
return
code
;
return
code
;
}
}
...
@@ -510,7 +515,7 @@ int32_t hbGetExpiredUserInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
...
@@ -510,7 +515,7 @@ int32_t hbGetExpiredUserInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
}
}
int32_t
hbGetExpiredDBInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
int32_t
hbGetExpiredDBInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
SDb
VgVersion
*
dbs
=
NULL
;
SDb
CacheInfo
*
dbs
=
NULL
;
uint32_t
dbNum
=
0
;
uint32_t
dbNum
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -525,19 +530,20 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
...
@@ -525,19 +530,20 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
}
}
for
(
int32_t
i
=
0
;
i
<
dbNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
dbNum
;
++
i
)
{
SDb
VgVersion
*
db
=
&
dbs
[
i
];
SDb
CacheInfo
*
db
=
&
dbs
[
i
];
tscDebug
(
"the %dth expired dbFName:%s, dbId:%"
PRId64
", vgVersion:%d, numOfTable:%d, startTs:%"
PRId64
,
tscDebug
(
"the %dth expired dbFName:%s, dbId:%"
PRId64
", vgVersion:%d,
cfgVersion:%d,
numOfTable:%d, startTs:%"
PRId64
,
i
,
db
->
dbFName
,
db
->
dbId
,
db
->
vgVersion
,
db
->
numOfTable
,
db
->
stateTs
);
i
,
db
->
dbFName
,
db
->
dbId
,
db
->
vgVersion
,
db
->
cfgVersion
,
db
->
numOfTable
,
db
->
stateTs
);
db
->
dbId
=
htobe64
(
db
->
dbId
);
db
->
dbId
=
htobe64
(
db
->
dbId
);
db
->
vgVersion
=
htonl
(
db
->
vgVersion
);
db
->
vgVersion
=
htonl
(
db
->
vgVersion
);
db
->
cfgVersion
=
htonl
(
db
->
cfgVersion
);
db
->
numOfTable
=
htonl
(
db
->
numOfTable
);
db
->
numOfTable
=
htonl
(
db
->
numOfTable
);
db
->
stateTs
=
htobe64
(
db
->
stateTs
);
db
->
stateTs
=
htobe64
(
db
->
stateTs
);
}
}
SKv
kv
=
{
SKv
kv
=
{
.
key
=
HEARTBEAT_KEY_DBINFO
,
.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
sizeof
(
SDb
VgVersion
)
*
dbNum
,
.
valueLen
=
sizeof
(
SDb
CacheInfo
)
*
dbNum
,
.
value
=
dbs
,
.
value
=
dbs
,
};
};
...
...
source/common/src/tmsg.c
浏览文件 @
fb7a06e0
...
@@ -2778,7 +2778,26 @@ int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, const SUseDbRsp *pRsp) {
...
@@ -2778,7 +2778,26 @@ int32_t tSerializeSUseDbRsp(void *buf, int32_t bufLen, const SUseDbRsp *pRsp) {
return
tlen
;
return
tlen
;
}
}
int32_t
tSerializeSUseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseDbBatchRsp
*
pRsp
)
{
int32_t
tSerializeSDbHbRspImp
(
SEncoder
*
pEncoder
,
const
SDbHbRsp
*
pRsp
)
{
if
(
pRsp
->
useDbRsp
)
{
if
(
tEncodeI8
(
pEncoder
,
1
)
<
0
)
return
-
1
;
if
(
tSerializeSUseDbRspImp
(
pEncoder
,
pRsp
->
useDbRsp
)
<
0
)
return
-
1
;
}
else
{
if
(
tEncodeI8
(
pEncoder
,
0
)
<
0
)
return
-
1
;
}
if
(
pRsp
->
cfgRsp
)
{
if
(
tEncodeI8
(
pEncoder
,
1
)
<
0
)
return
-
1
;
if
(
tSerializeSDbCfgRspImpl
(
pEncoder
,
pRsp
->
cfgRsp
)
<
0
)
return
-
1
;
}
else
{
if
(
tEncodeI8
(
pEncoder
,
0
)
<
0
)
return
-
1
;
}
return
0
;
}
int32_t
tSerializeSDbHbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbHbBatchRsp
*
pRsp
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
@@ -2787,8 +2806,8 @@ int32_t tSerializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pRsp
...
@@ -2787,8 +2806,8 @@ int32_t tSerializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pRsp
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
if
(
tEncodeI32
(
&
encoder
,
numOfBatch
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
numOfBatch
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
S
UseDbRsp
*
pUsed
bRsp
=
taosArrayGet
(
pRsp
->
pArray
,
i
);
S
DbHbRsp
*
pD
bRsp
=
taosArrayGet
(
pRsp
->
pArray
,
i
);
if
(
tSerializeS
UseDbRspImp
(
&
encoder
,
pUsed
bRsp
)
<
0
)
return
-
1
;
if
(
tSerializeS
DbHbRspImp
(
&
encoder
,
pD
bRsp
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -2841,7 +2860,25 @@ int32_t tDeserializeSUseDbRsp(void *buf, int32_t bufLen, SUseDbRsp *pRsp) {
...
@@ -2841,7 +2860,25 @@ int32_t tDeserializeSUseDbRsp(void *buf, int32_t bufLen, SUseDbRsp *pRsp) {
return
0
;
return
0
;
}
}
int32_t
tDeserializeSUseDbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SUseDbBatchRsp
*
pRsp
)
{
int32_t
tDeserializeSDbHbRspImp
(
SDecoder
*
decoder
,
SDbHbRsp
*
pRsp
)
{
int8_t
flag
=
0
;
if
(
tDecodeI8
(
decoder
,
&
flag
)
<
0
)
return
-
1
;
if
(
flag
)
{
pRsp
->
useDbRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SUseDbRsp
));
if
(
NULL
==
pRsp
->
useDbRsp
)
return
-
1
;
if
(
tDeserializeSUseDbRspImp
(
decoder
,
pRsp
->
useDbRsp
)
<
0
)
return
-
1
;
}
if
(
tDecodeI8
(
decoder
,
&
flag
)
<
0
)
return
-
1
;
if
(
flag
)
{
pRsp
->
cfgRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgRsp
));
if
(
NULL
==
pRsp
->
cfgRsp
)
return
-
1
;
if
(
tDeserializeSDbCfgRspImpl
(
decoder
,
pRsp
->
cfgRsp
)
<
0
)
return
-
1
;
}
return
0
;
}
int32_t
tDeserializeSDbHbBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbHbBatchRsp
*
pRsp
)
{
SDecoder
decoder
=
{
0
};
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
...
@@ -2850,19 +2887,19 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
...
@@ -2850,19 +2887,19 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
if
(
tDecodeI32
(
&
decoder
,
&
numOfBatch
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfBatch
)
<
0
)
return
-
1
;
pRsp
->
pArray
=
taosArrayInit
(
numOfBatch
,
sizeof
(
S
UseD
bRsp
));
pRsp
->
pArray
=
taosArrayInit
(
numOfBatch
,
sizeof
(
S
DbH
bRsp
));
if
(
pRsp
->
pArray
==
NULL
)
{
if
(
pRsp
->
pArray
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
S
UseDbRsp
usedbR
sp
=
{
0
};
S
DbHbRsp
r
sp
=
{
0
};
if
(
tDeserializeS
UseDbRspImp
(
&
decoder
,
&
usedbR
sp
)
<
0
)
{
if
(
tDeserializeS
DbHbRspImp
(
&
decoder
,
&
r
sp
)
<
0
)
{
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
-
1
;
return
-
1
;
}
}
taosArrayPush
(
pRsp
->
pArray
,
&
usedbR
sp
);
taosArrayPush
(
pRsp
->
pArray
,
&
r
sp
);
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -2872,11 +2909,27 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
...
@@ -2872,11 +2909,27 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
void
tFreeSUsedbRsp
(
SUseDbRsp
*
pRsp
)
{
taosArrayDestroy
(
pRsp
->
pVgroupInfos
);
}
void
tFreeSUsedbRsp
(
SUseDbRsp
*
pRsp
)
{
taosArrayDestroy
(
pRsp
->
pVgroupInfos
);
}
void
tFreeSUseDbBatchRsp
(
SUseDbBatchRsp
*
pRsp
)
{
void
tFreeSDbHbRsp
(
SDbHbRsp
*
pDbRsp
)
{
if
(
NULL
==
pDbRsp
)
{
return
;
}
if
(
pDbRsp
->
useDbRsp
)
{
tFreeSUsedbRsp
(
pDbRsp
->
useDbRsp
);
taosMemoryFree
(
pDbRsp
->
useDbRsp
);
}
if
(
pDbRsp
->
cfgRsp
)
{
tFreeSDbCfgRsp
(
pDbRsp
->
cfgRsp
);
taosMemoryFree
(
pDbRsp
->
cfgRsp
);
}
}
void
tFreeSDbHbBatchRsp
(
SDbHbBatchRsp
*
pRsp
)
{
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
S
UseDbRsp
*
pUsed
bRsp
=
taosArrayGet
(
pRsp
->
pArray
,
i
);
S
DbHbRsp
*
pD
bRsp
=
taosArrayGet
(
pRsp
->
pArray
,
i
);
tFreeS
UsedbRsp
(
pUsed
bRsp
);
tFreeS
DbHbRsp
(
pD
bRsp
);
}
}
taosArrayDestroy
(
pRsp
->
pArray
);
taosArrayDestroy
(
pRsp
->
pArray
);
...
@@ -3039,85 +3092,93 @@ int32_t tDeserializeSVDropTtlTableReq(void *buf, int32_t bufLen, SVDropTtlTableR
...
@@ -3039,85 +3092,93 @@ int32_t tDeserializeSVDropTtlTableReq(void *buf, int32_t bufLen, SVDropTtlTableR
return
0
;
return
0
;
}
}
int32_t
tSerializeSDbCfgRspImpl
(
SEncoder
*
encoder
,
const
SDbCfgRsp
*
pRsp
)
{
if
(
tEncodeCStr
(
encoder
,
pRsp
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pRsp
->
dbId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
cfgVersion
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
numOfStables
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
buffer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
cacheSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
pageSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
pages
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
daysPerFile
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
daysToKeep0
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
daysToKeep1
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
daysToKeep2
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
minRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
maxRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
walFsyncPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
encoder
,
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
encoder
,
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
walLevel
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
precision
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
compression
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
replications
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRsp
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
tsdbPageSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pRsp
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pRsp
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pRsp
->
pRetensions
,
i
);
if
(
tEncodeI64
(
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
if
(
tEncodeI8
(
encoder
,
pRsp
->
schemaless
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
encoder
,
pRsp
->
sstTrigger
)
<
0
)
return
-
1
;
return
0
;
}
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
)
{
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
numOfVgroups
)
<
0
)
return
-
1
;
tSerializeSDbCfgRspImpl
(
&
encoder
,
pRsp
);
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
numOfStables
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
buffer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
cacheSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
pageSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
pages
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
daysPerFile
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
daysToKeep0
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
daysToKeep1
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
daysToKeep2
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
minRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
maxRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
walFsyncPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
walLevel
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
precision
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
compression
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
replications
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
tsdbPageSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pRsp
->
pRetensions
,
i
);
if
(
tEncodeI64
(
&
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
schemaless
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
&
encoder
,
pRsp
->
sstTrigger
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
tEncoderClear
(
&
encoder
);
return
tlen
;
return
tlen
;
}
}
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
)
{
int32_t
tDeserializeSDbCfgRspImpl
(
SDecoder
*
decoder
,
SDbCfgRsp
*
pRsp
)
{
SDecoder
decoder
=
{
0
};
if
(
tDecodeCStrTo
(
decoder
,
pRsp
->
db
)
<
0
)
return
-
1
;
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tDecodeI64
(
decoder
,
&
pRsp
->
dbId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
cfgVersion
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
numOfStables
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfStables
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
buffer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
buffer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
cacheSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
cacheSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
pageSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
pageSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
pages
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
pages
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
daysPerFile
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
daysPerFile
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
daysToKeep0
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
daysToKeep0
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
daysToKeep1
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
daysToKeep1
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
daysToKeep2
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
daysToKeep2
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
minRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
minRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
maxRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
maxRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
walFsyncPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
walFsyncPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
decoder
,
&
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
decoder
,
&
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
walLevel
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
walLevel
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
precision
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
precision
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
compression
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
compression
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
replications
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
replications
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
cacheLast
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
tsdbPageSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
tsdbPageSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
walRetentionPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
walRollPeriod
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
decoder
,
&
pRsp
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
walRetentionSize
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
decoder
,
&
pRsp
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
walSegmentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
if
(
pRsp
->
numOfRetensions
>
0
)
{
if
(
pRsp
->
numOfRetensions
>
0
)
{
pRsp
->
pRetensions
=
taosArrayInit
(
pRsp
->
numOfRetensions
,
sizeof
(
SRetention
));
pRsp
->
pRetensions
=
taosArrayInit
(
pRsp
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pRsp
->
pRetensions
==
NULL
)
{
if
(
pRsp
->
pRetensions
==
NULL
)
{
...
@@ -3128,23 +3189,41 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
...
@@ -3128,23 +3189,41 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
SRetention
rentension
=
{
0
};
if
(
tDecodeI64
(
&
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pRsp
->
pRetensions
,
&
rentension
)
==
NULL
)
{
if
(
taosArrayPush
(
pRsp
->
pRetensions
,
&
rentension
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
}
}
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
schemaless
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
decoder
,
&
pRsp
->
schemaless
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
&
decoder
,
&
pRsp
->
sstTrigger
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
decoder
,
&
pRsp
->
sstTrigger
)
<
0
)
return
-
1
;
return
0
;
}
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDeserializeSDbCfgRspImpl
(
&
decoder
,
pRsp
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
void
tFreeSDbCfgRsp
(
SDbCfgRsp
*
pRsp
)
{
if
(
NULL
==
pRsp
)
{
return
;
}
taosArrayDestroy
(
pRsp
->
pRetensions
);
}
int32_t
tSerializeSUserIndexReq
(
void
*
buf
,
int32_t
bufLen
,
SUserIndexReq
*
pReq
)
{
int32_t
tSerializeSUserIndexReq
(
void
*
buf
,
int32_t
bufLen
,
SUserIndexReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
fb7a06e0
...
@@ -120,6 +120,11 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -120,6 +120,11 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
}
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
if
(
NULL
==
pMgmt
->
pMnode
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGError
(
"msg:%p, stop to pre-process in mnode since mnode is NULL, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
return
-
1
;
}
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
if
(
mndPreProcessQueryMsg
(
pMsg
)
!=
0
)
{
if
(
mndPreProcessQueryMsg
(
pMsg
)
!=
0
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
...
...
source/dnode/mnode/impl/inc/mndDb.h
浏览文件 @
fb7a06e0
...
@@ -26,7 +26,7 @@ int32_t mndInitDb(SMnode *pMnode);
...
@@ -26,7 +26,7 @@ int32_t mndInitDb(SMnode *pMnode);
void
mndCleanupDb
(
SMnode
*
pMnode
);
void
mndCleanupDb
(
SMnode
*
pMnode
);
SDbObj
*
mndAcquireDb
(
SMnode
*
pMnode
,
const
char
*
db
);
SDbObj
*
mndAcquireDb
(
SMnode
*
pMnode
,
const
char
*
db
);
void
mndReleaseDb
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
void
mndReleaseDb
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
int32_t
mndValidateDbInfo
(
SMnode
*
pMnode
,
SDb
VgVersion
*
pDbs
,
int32_t
numOfDbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
int32_t
mndValidateDbInfo
(
SMnode
*
pMnode
,
SDb
CacheInfo
*
pDbs
,
int32_t
numOfDbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
int32_t
mndExtractDbInfo
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SUseDbRsp
*
pRsp
,
const
SUseDbReq
*
pReq
);
int32_t
mndExtractDbInfo
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SUseDbRsp
*
pRsp
,
const
SUseDbReq
*
pReq
);
bool
mndIsDbReady
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
bool
mndIsDbReady
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
fb7a06e0
...
@@ -898,6 +898,42 @@ _OVER:
...
@@ -898,6 +898,42 @@ _OVER:
return
code
;
return
code
;
}
}
static
void
mndDumpDbCfgInfo
(
SDbCfgRsp
*
cfgRsp
,
SDbObj
*
pDb
)
{
strcpy
(
cfgRsp
->
db
,
pDb
->
name
);
cfgRsp
->
dbId
=
pDb
->
uid
;
cfgRsp
->
cfgVersion
=
pDb
->
cfgVersion
;
cfgRsp
->
numOfVgroups
=
pDb
->
cfg
.
numOfVgroups
;
cfgRsp
->
numOfStables
=
pDb
->
cfg
.
numOfStables
;
cfgRsp
->
buffer
=
pDb
->
cfg
.
buffer
;
cfgRsp
->
cacheSize
=
pDb
->
cfg
.
cacheLastSize
;
cfgRsp
->
pageSize
=
pDb
->
cfg
.
pageSize
;
cfgRsp
->
pages
=
pDb
->
cfg
.
pages
;
cfgRsp
->
daysPerFile
=
pDb
->
cfg
.
daysPerFile
;
cfgRsp
->
daysToKeep0
=
pDb
->
cfg
.
daysToKeep0
;
cfgRsp
->
daysToKeep1
=
pDb
->
cfg
.
daysToKeep1
;
cfgRsp
->
daysToKeep2
=
pDb
->
cfg
.
daysToKeep2
;
cfgRsp
->
minRows
=
pDb
->
cfg
.
minRows
;
cfgRsp
->
maxRows
=
pDb
->
cfg
.
maxRows
;
cfgRsp
->
walFsyncPeriod
=
pDb
->
cfg
.
walFsyncPeriod
;
cfgRsp
->
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
cfgRsp
->
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
cfgRsp
->
walLevel
=
pDb
->
cfg
.
walLevel
;
cfgRsp
->
precision
=
pDb
->
cfg
.
precision
;
cfgRsp
->
compression
=
pDb
->
cfg
.
compression
;
cfgRsp
->
replications
=
pDb
->
cfg
.
replications
;
cfgRsp
->
strict
=
pDb
->
cfg
.
strict
;
cfgRsp
->
cacheLast
=
pDb
->
cfg
.
cacheLast
;
cfgRsp
->
tsdbPageSize
=
pDb
->
cfg
.
tsdbPageSize
;
cfgRsp
->
walRetentionPeriod
=
pDb
->
cfg
.
walRetentionPeriod
;
cfgRsp
->
walRollPeriod
=
pDb
->
cfg
.
walRollPeriod
;
cfgRsp
->
walRetentionSize
=
pDb
->
cfg
.
walRetentionSize
;
cfgRsp
->
walSegmentSize
=
pDb
->
cfg
.
walSegmentSize
;
cfgRsp
->
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
->
pRetensions
=
pDb
->
cfg
.
pRetensions
;
cfgRsp
->
schemaless
=
pDb
->
cfg
.
schemaless
;
cfgRsp
->
sstTrigger
=
pDb
->
cfg
.
sstTrigger
;
}
static
int32_t
mndProcessGetDbCfgReq
(
SRpcMsg
*
pReq
)
{
static
int32_t
mndProcessGetDbCfgReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -910,41 +946,15 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
...
@@ -910,41 +946,15 @@ static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
if
(
strcasecmp
(
cfgReq
.
db
,
TSDB_INFORMATION_SCHEMA_DB
)
&&
strcasecmp
(
cfgReq
.
db
,
TSDB_PERFORMANCE_SCHEMA_DB
))
{
pDb
=
mndAcquireDb
(
pMnode
,
cfgReq
.
db
);
pDb
=
mndAcquireDb
(
pMnode
,
cfgReq
.
db
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
goto
_OVER
;
goto
_OVER
;
}
}
cfgRsp
.
numOfVgroups
=
pDb
->
cfg
.
numOfVgroups
;
mndDumpDbCfgInfo
(
&
cfgRsp
,
pDb
);
cfgRsp
.
numOfStables
=
pDb
->
cfg
.
numOfStables
;
}
cfgRsp
.
buffer
=
pDb
->
cfg
.
buffer
;
cfgRsp
.
cacheSize
=
pDb
->
cfg
.
cacheLastSize
;
cfgRsp
.
pageSize
=
pDb
->
cfg
.
pageSize
;
cfgRsp
.
pages
=
pDb
->
cfg
.
pages
;
cfgRsp
.
daysPerFile
=
pDb
->
cfg
.
daysPerFile
;
cfgRsp
.
daysToKeep0
=
pDb
->
cfg
.
daysToKeep0
;
cfgRsp
.
daysToKeep1
=
pDb
->
cfg
.
daysToKeep1
;
cfgRsp
.
daysToKeep2
=
pDb
->
cfg
.
daysToKeep2
;
cfgRsp
.
minRows
=
pDb
->
cfg
.
minRows
;
cfgRsp
.
maxRows
=
pDb
->
cfg
.
maxRows
;
cfgRsp
.
walFsyncPeriod
=
pDb
->
cfg
.
walFsyncPeriod
;
cfgRsp
.
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
cfgRsp
.
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
cfgRsp
.
walLevel
=
pDb
->
cfg
.
walLevel
;
cfgRsp
.
precision
=
pDb
->
cfg
.
precision
;
cfgRsp
.
compression
=
pDb
->
cfg
.
compression
;
cfgRsp
.
replications
=
pDb
->
cfg
.
replications
;
cfgRsp
.
strict
=
pDb
->
cfg
.
strict
;
cfgRsp
.
cacheLast
=
pDb
->
cfg
.
cacheLast
;
cfgRsp
.
tsdbPageSize
=
pDb
->
cfg
.
tsdbPageSize
;
cfgRsp
.
walRetentionPeriod
=
pDb
->
cfg
.
walRetentionPeriod
;
cfgRsp
.
walRollPeriod
=
pDb
->
cfg
.
walRollPeriod
;
cfgRsp
.
walRetentionSize
=
pDb
->
cfg
.
walRetentionSize
;
cfgRsp
.
walSegmentSize
=
pDb
->
cfg
.
walSegmentSize
;
cfgRsp
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
cfgRsp
.
schemaless
=
pDb
->
cfg
.
schemaless
;
cfgRsp
.
sstTrigger
=
pDb
->
cfg
.
sstTrigger
;
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
...
@@ -1341,103 +1351,119 @@ _OVER:
...
@@ -1341,103 +1351,119 @@ _OVER:
return
code
;
return
code
;
}
}
int32_t
mndValidateDbInfo
(
SMnode
*
pMnode
,
SDb
VgVersion
*
pDbs
,
int32_t
numOfDbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
)
{
int32_t
mndValidateDbInfo
(
SMnode
*
pMnode
,
SDb
CacheInfo
*
pDbs
,
int32_t
numOfDbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
)
{
S
UseDbBatchRsp
batchUse
Rsp
=
{
0
};
S
DbHbBatchRsp
batch
Rsp
=
{
0
};
batch
UseRsp
.
pArray
=
taosArrayInit
(
numOfDbs
,
sizeof
(
SUseD
bRsp
));
batch
Rsp
.
pArray
=
taosArrayInit
(
numOfDbs
,
sizeof
(
SDbH
bRsp
));
if
(
batch
Use
Rsp
.
pArray
==
NULL
)
{
if
(
batchRsp
.
pArray
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
numOfDbs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfDbs
;
++
i
)
{
SDbVgVersion
*
pDbVgVersion
=
&
pDbs
[
i
];
SDbCacheInfo
*
pDbCacheInfo
=
&
pDbs
[
i
];
pDbVgVersion
->
dbId
=
be64toh
(
pDbVgVersion
->
dbId
);
pDbCacheInfo
->
dbId
=
be64toh
(
pDbCacheInfo
->
dbId
);
pDbVgVersion
->
vgVersion
=
htonl
(
pDbVgVersion
->
vgVersion
);
pDbCacheInfo
->
vgVersion
=
htonl
(
pDbCacheInfo
->
vgVersion
);
pDbVgVersion
->
numOfTable
=
htonl
(
pDbVgVersion
->
numOfTable
);
pDbCacheInfo
->
cfgVersion
=
htonl
(
pDbCacheInfo
->
cfgVersion
);
pDbVgVersion
->
stateTs
=
be64toh
(
pDbVgVersion
->
stateTs
);
pDbCacheInfo
->
numOfTable
=
htonl
(
pDbCacheInfo
->
numOfTable
);
pDbCacheInfo
->
stateTs
=
be64toh
(
pDbCacheInfo
->
stateTs
);
S
UseDbRsp
usedbR
sp
=
{
0
};
S
DbHbRsp
r
sp
=
{
0
};
if
((
0
==
strcasecmp
(
pDbVgVersion
->
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
)
||
if
((
0
==
strcasecmp
(
pDbCacheInfo
->
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
)
||
(
0
==
strcasecmp
(
pDbVgVersion
->
dbFName
,
TSDB_PERFORMANCE_SCHEMA_DB
))))
{
(
0
==
strcasecmp
(
pDbCacheInfo
->
dbFName
,
TSDB_PERFORMANCE_SCHEMA_DB
))))
{
memcpy
(
usedbRsp
.
db
,
pDbVgVersion
->
dbFName
,
TSDB_DB_FNAME_LEN
);
int32_t
vgVersion
=
mndGetGlobalVgroupVersion
(
pMnode
);
int32_t
vgVersion
=
mndGetGlobalVgroupVersion
(
pMnode
);
if
(
pDbVgVersion
->
vgVersion
<
vgVersion
)
{
if
(
pDbCacheInfo
->
vgVersion
>=
vgVersion
)
{
usedbRsp
.
pVgroupInfos
=
taosArrayInit
(
10
,
sizeof
(
SVgroupInfo
));
continue
;
mndBuildDBVgroupInfo
(
NULL
,
pMnode
,
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
vgVersion
=
vgVersion
++
;
}
else
{
usedbRsp
.
vgVersion
=
pDbVgVersion
->
vgVersion
;
}
}
usedbRsp
.
vgNum
=
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
rsp
.
useDbRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SUseDbRsp
));
memcpy
(
rsp
.
useDbRsp
->
db
,
pDbCacheInfo
->
dbFName
,
TSDB_DB_FNAME_LEN
);
rsp
.
useDbRsp
->
pVgroupInfos
=
taosArrayInit
(
10
,
sizeof
(
SVgroupInfo
));
mndBuildDBVgroupInfo
(
NULL
,
pMnode
,
rsp
.
useDbRsp
->
pVgroupInfos
);
rsp
.
useDbRsp
->
vgVersion
=
vgVersion
++
;
rsp
.
useDbRsp
->
vgNum
=
taosArrayGetSize
(
rsp
.
useDbRsp
->
pVgroupInfos
);
taosArrayPush
(
batchRsp
.
pArray
,
&
rsp
);
continue
;
continue
;
}
}
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pDb
VgVersion
->
dbFName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pDb
CacheInfo
->
dbFName
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
mTrace
(
"db:%s, no exist"
,
pDbVgVersion
->
dbFName
);
mTrace
(
"db:%s, no exist"
,
pDbCacheInfo
->
dbFName
);
memcpy
(
usedbRsp
.
db
,
pDbVgVersion
->
dbFName
,
TSDB_DB_FNAME_LEN
);
rsp
.
useDbRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SUseDbRsp
));
usedbRsp
.
uid
=
pDbVgVersion
->
dbId
;
memcpy
(
rsp
.
useDbRsp
->
db
,
pDbCacheInfo
->
dbFName
,
TSDB_DB_FNAME_LEN
);
usedbRsp
.
vgVersion
=
-
1
;
rsp
.
useDbRsp
->
uid
=
pDbCacheInfo
->
dbId
;
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
rsp
.
useDbRsp
->
vgVersion
=
-
1
;
taosArrayPush
(
batchRsp
.
pArray
,
&
rsp
);
continue
;
continue
;
}
}
int32_t
numOfTable
=
mndGetDBTableNum
(
pDb
,
pMnode
);
int32_t
numOfTable
=
mndGetDBTableNum
(
pDb
,
pMnode
);
if
(
pDbVgVersion
->
vgVersion
>=
pDb
->
vgVersion
&&
numOfTable
==
pDbVgVersion
->
numOfTable
&&
if
(
pDbCacheInfo
->
vgVersion
>=
pDb
->
vgVersion
&&
pDbVgVersion
->
stateTs
==
pDb
->
stateTs
)
{
pDbCacheInfo
->
cfgVersion
>=
pDb
->
cfgVersion
&&
mTrace
(
"db:%s, valid dbinfo, vgVersion:%d stateTs:%"
PRId64
numOfTable
==
pDbCacheInfo
->
numOfTable
&&
" numOfTables:%d, not changed vgVersion:%d stateTs:%"
PRId64
" numOfTables:%d"
,
pDbCacheInfo
->
stateTs
==
pDb
->
stateTs
)
{
pDbVgVersion
->
dbFName
,
pDbVgVersion
->
vgVersion
,
pDbVgVersion
->
stateTs
,
pDbVgVersion
->
numOfTable
,
mTrace
(
"db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%"
PRId64
pDb
->
vgVersion
,
pDb
->
stateTs
,
numOfTable
);
" numOfTables:%d, not changed vgVersion:%d cfgVersion:%d stateTs:%"
PRId64
" numOfTables:%d"
,
pDbCacheInfo
->
dbFName
,
pDbCacheInfo
->
vgVersion
,
pDbCacheInfo
->
cfgVersion
,
pDbCacheInfo
->
stateTs
,
pDbCacheInfo
->
numOfTable
,
pDb
->
vgVersion
,
pDb
->
cfgVersion
,
pDb
->
stateTs
,
numOfTable
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
continue
;
continue
;
}
else
{
}
else
{
mInfo
(
"db:%s, valid dbinfo, vgVersion:%d stateTs:%"
PRId64
mInfo
(
"db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%"
PRId64
" numOfTables:%d, changed to vgVersion:%d stateTs:%"
PRId64
" numOfTables:%d"
,
" numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%"
PRId64
" numOfTables:%d"
,
pDbVgVersion
->
dbFName
,
pDbVgVersion
->
vgVersion
,
pDbVgVersion
->
stateTs
,
pDbVgVersion
->
numOfTable
,
pDbCacheInfo
->
dbFName
,
pDbCacheInfo
->
vgVersion
,
pDbCacheInfo
->
cfgVersion
,
pDbCacheInfo
->
stateTs
,
pDbCacheInfo
->
numOfTable
,
pDb
->
vgVersion
,
pDb
->
stateTs
,
numOfTable
);
pDb
->
vgVersion
,
pDb
->
cfgVersion
,
pDb
->
stateTs
,
numOfTable
);
}
if
(
pDbCacheInfo
->
cfgVersion
<
pDb
->
cfgVersion
)
{
rsp
.
cfgRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgRsp
));
mndDumpDbCfgInfo
(
rsp
.
cfgRsp
,
pDb
);
}
}
usedbRsp
.
pVgroupInfos
=
taosArrayInit
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgroupInfo
));
if
(
pDbCacheInfo
->
vgVersion
<
pDb
->
vgVersion
||
if
(
usedbRsp
.
pVgroupInfos
==
NULL
)
{
numOfTable
!=
pDbCacheInfo
->
numOfTable
||
pDbCacheInfo
->
stateTs
!=
pDb
->
stateTs
)
{
rsp
.
useDbRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SUseDbRsp
));
rsp
.
useDbRsp
->
pVgroupInfos
=
taosArrayInit
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgroupInfo
));
if
(
rsp
.
useDbRsp
->
pVgroupInfos
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mError
(
"db:%s, failed to malloc usedb response"
,
pDb
->
name
);
mError
(
"db:%s, failed to malloc usedb response"
,
pDb
->
name
);
continue
;
continue
;
}
}
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
usedbRsp
.
pVgroupInfos
);
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
rsp
.
useDbRsp
->
pVgroupInfos
);
memcpy
(
usedbRsp
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
memcpy
(
rsp
.
useDbRsp
->
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
usedbRsp
.
uid
=
pDb
->
uid
;
rsp
.
useDbRsp
->
uid
=
pDb
->
uid
;
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
rsp
.
useDbRsp
->
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
stateTs
=
pDb
->
stateTs
;
rsp
.
useDbRsp
->
stateTs
=
pDb
->
stateTs
;
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
rsp
.
useDbRsp
->
vgNum
=
(
int32_t
)
taosArrayGetSize
(
rsp
.
useDbRsp
->
pVgroupInfos
);
usedbRsp
.
hashMethod
=
pDb
->
cfg
.
hashMethod
;
rsp
.
useDbRsp
->
hashMethod
=
pDb
->
cfg
.
hashMethod
;
usedbRsp
.
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
rsp
.
useDbRsp
->
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
usedbRsp
.
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
rsp
.
useDbRsp
->
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
}
taosArrayPush
(
batch
UseRsp
.
pArray
,
&
usedbR
sp
);
taosArrayPush
(
batch
Rsp
.
pArray
,
&
r
sp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
}
}
int32_t
rspLen
=
tSerializeS
UseDbBatchRsp
(
NULL
,
0
,
&
batchUse
Rsp
);
int32_t
rspLen
=
tSerializeS
DbHbBatchRsp
(
NULL
,
0
,
&
batch
Rsp
);
void
*
pRsp
=
taosMemoryMalloc
(
rspLen
);
void
*
pRsp
=
taosMemoryMalloc
(
rspLen
);
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tFreeS
UseDbBatchRsp
(
&
batchUse
Rsp
);
tFreeS
DbHbBatchRsp
(
&
batch
Rsp
);
return
-
1
;
return
-
1
;
}
}
tSerializeS
UseDbBatchRsp
(
pRsp
,
rspLen
,
&
batchUse
Rsp
);
tSerializeS
DbHbBatchRsp
(
pRsp
,
rspLen
,
&
batch
Rsp
);
*
ppRsp
=
pRsp
;
*
ppRsp
=
pRsp
;
*
pRspLen
=
rspLen
;
*
pRspLen
=
rspLen
;
tFreeS
UseDbBatchRsp
(
&
batchUse
Rsp
);
tFreeS
DbHbBatchRsp
(
&
batch
Rsp
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
fb7a06e0
...
@@ -533,7 +533,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -533,7 +533,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
case
HEARTBEAT_KEY_DBINFO
:
{
case
HEARTBEAT_KEY_DBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDb
VgVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDb
CacheInfo
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
SKv
kv1
=
{.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
SKv
kv1
=
{.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
taosArrayPush
(
hbRsp
.
info
,
&
kv1
);
taosArrayPush
(
hbRsp
.
info
,
&
kv1
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
fb7a06e0
...
@@ -123,6 +123,11 @@ int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, in
...
@@ -123,6 +123,11 @@ int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, in
int32_t
payloadLen
,
double
selectivityRatio
);
int32_t
payloadLen
,
double
selectivityRatio
);
int32_t
metaUidCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
);
int32_t
metaUidCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
);
tb_uid_t
metaGetTableEntryUidByName
(
SMeta
*
pMeta
,
const
char
*
name
);
tb_uid_t
metaGetTableEntryUidByName
(
SMeta
*
pMeta
,
const
char
*
name
);
int32_t
metaTbGroupCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
);
int32_t
metaGetCachedTbGroup
(
SMeta
*
pMeta
,
tb_uid_t
suid
,
const
uint8_t
*
pKey
,
int32_t
keyLen
,
SArray
**
pList
);
int32_t
metaPutTbGroupToCache
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
payloadLen
);
int64_t
metaGetTbNum
(
SMeta
*
pMeta
);
int64_t
metaGetTbNum
(
SMeta
*
pMeta
);
int64_t
metaGetNtbNum
(
SMeta
*
pMeta
);
int64_t
metaGetNtbNum
(
SMeta
*
pMeta
);
typedef
struct
{
typedef
struct
{
...
@@ -176,7 +181,7 @@ typedef struct STsdbReader STsdbReader;
...
@@ -176,7 +181,7 @@ typedef struct STsdbReader STsdbReader;
#define CACHESCAN_RETRIEVE_LAST 0x8
#define CACHESCAN_RETRIEVE_LAST 0x8
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
void
*
pTableList
,
int32_t
numOfTables
,
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
void
*
pTableList
,
int32_t
numOfTables
,
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
,
bool
countOnly
);
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
,
bool
countOnly
,
SHashObj
**
pIgnoreTables
);
void
tsdbReaderClose
(
STsdbReader
*
pReader
);
void
tsdbReaderClose
(
STsdbReader
*
pReader
);
int32_t
tsdbNextDataBlock
(
STsdbReader
*
pReader
,
bool
*
hasNext
);
int32_t
tsdbNextDataBlock
(
STsdbReader
*
pReader
,
bool
*
hasNext
);
int32_t
tsdbRetrieveDatablockSMA
(
STsdbReader
*
pReader
,
SSDataBlock
*
pDataBlock
,
bool
*
allHave
);
int32_t
tsdbRetrieveDatablockSMA
(
STsdbReader
*
pReader
,
SSDataBlock
*
pDataBlock
,
bool
*
allHave
);
...
@@ -192,6 +197,7 @@ int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int3
...
@@ -192,6 +197,7 @@ int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int3
void
tsdbReaderSetId
(
STsdbReader
*
pReader
,
const
char
*
idstr
);
void
tsdbReaderSetId
(
STsdbReader
*
pReader
,
const
char
*
idstr
);
void
tsdbReaderSetCloseFlag
(
STsdbReader
*
pReader
);
void
tsdbReaderSetCloseFlag
(
STsdbReader
*
pReader
);
int32_t
tsdbReuseCacherowsReader
(
void
*
pReader
,
void
*
pTableIdList
,
int32_t
numOfTables
);
int32_t
tsdbCacherowsReaderOpen
(
void
*
pVnode
,
int32_t
type
,
void
*
pTableIdList
,
int32_t
numOfTables
,
int32_t
numOfCols
,
int32_t
tsdbCacherowsReaderOpen
(
void
*
pVnode
,
int32_t
type
,
void
*
pTableIdList
,
int32_t
numOfTables
,
int32_t
numOfCols
,
uint64_t
suid
,
void
**
pReader
,
const
char
*
idstr
);
uint64_t
suid
,
void
**
pReader
,
const
char
*
idstr
);
int32_t
tsdbRetrieveCacheRows
(
void
*
pReader
,
SSDataBlock
*
pResBlock
,
const
int32_t
*
slotIds
,
SArray
*
pTableUids
);
int32_t
tsdbRetrieveCacheRows
(
void
*
pReader
,
SSDataBlock
*
pResBlock
,
const
int32_t
*
slotIds
,
SArray
*
pTableUids
);
...
...
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
fb7a06e0
...
@@ -59,6 +59,13 @@ struct SMetaCache {
...
@@ -59,6 +59,13 @@ struct SMetaCache {
SHashObj
*
pTableEntry
;
SHashObj
*
pTableEntry
;
SLRUCache
*
pUidResCache
;
SLRUCache
*
pUidResCache
;
}
sTagFilterResCache
;
}
sTagFilterResCache
;
struct
STbGroupResCache
{
TdThreadMutex
lock
;
uint32_t
accTimes
;
SHashObj
*
pTableEntry
;
SLRUCache
*
pResCache
;
}
STbGroupResCache
;
};
};
static
void
entryCacheClose
(
SMeta
*
pMeta
)
{
static
void
entryCacheClose
(
SMeta
*
pMeta
)
{
...
@@ -144,6 +151,25 @@ int32_t metaCacheOpen(SMeta* pMeta) {
...
@@ -144,6 +151,25 @@ int32_t metaCacheOpen(SMeta* pMeta) {
taosHashSetFreeFp
(
pCache
->
sTagFilterResCache
.
pTableEntry
,
freeCacheEntryFp
);
taosHashSetFreeFp
(
pCache
->
sTagFilterResCache
.
pTableEntry
,
freeCacheEntryFp
);
taosThreadMutexInit
(
&
pCache
->
sTagFilterResCache
.
lock
,
NULL
);
taosThreadMutexInit
(
&
pCache
->
sTagFilterResCache
.
lock
,
NULL
);
pCache
->
STbGroupResCache
.
pResCache
=
taosLRUCacheInit
(
5
*
1024
*
1024
,
-
1
,
0
.
5
);
if
(
pCache
->
STbGroupResCache
.
pResCache
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err2
;
}
pCache
->
STbGroupResCache
.
accTimes
=
0
;
pCache
->
STbGroupResCache
.
pTableEntry
=
taosHashInit
(
1024
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_VARCHAR
),
false
,
HASH_NO_LOCK
);
if
(
pCache
->
STbGroupResCache
.
pTableEntry
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err2
;
}
taosHashSetFreeFp
(
pCache
->
STbGroupResCache
.
pTableEntry
,
freeCacheEntryFp
);
taosThreadMutexInit
(
&
pCache
->
STbGroupResCache
.
lock
,
NULL
);
pMeta
->
pCache
=
pCache
;
pMeta
->
pCache
=
pCache
;
return
code
;
return
code
;
...
@@ -165,6 +191,10 @@ void metaCacheClose(SMeta* pMeta) {
...
@@ -165,6 +191,10 @@ void metaCacheClose(SMeta* pMeta) {
taosThreadMutexDestroy
(
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
);
taosThreadMutexDestroy
(
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
);
taosHashCleanup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
);
taosHashCleanup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
);
taosLRUCacheCleanup
(
pMeta
->
pCache
->
STbGroupResCache
.
pResCache
);
taosThreadMutexDestroy
(
&
pMeta
->
pCache
->
STbGroupResCache
.
lock
);
taosHashCleanup
(
pMeta
->
pCache
->
STbGroupResCache
.
pTableEntry
);
taosMemoryFree
(
pMeta
->
pCache
);
taosMemoryFree
(
pMeta
->
pCache
);
pMeta
->
pCache
=
NULL
;
pMeta
->
pCache
=
NULL
;
}
}
...
@@ -520,7 +550,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -520,7 +550,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
freePayload
(
const
void
*
key
,
size_t
keyLen
,
void
*
value
)
{
static
void
free
UidCache
Payload
(
const
void
*
key
,
size_t
keyLen
,
void
*
value
)
{
if
(
value
==
NULL
)
{
if
(
value
==
NULL
)
{
return
;
return
;
}
}
...
@@ -626,7 +656,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -626,7 +656,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
}
}
// add to cache.
// add to cache.
taosLRUCacheInsert
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
taosLRUCacheInsert
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
,
pPayload
,
payloadLen
,
free
UidCache
Payload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
TAOS_LRU_PRIORITY_LOW
);
_end:
_end:
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
...
@@ -671,3 +701,180 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
...
@@ -671,3 +701,180 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
metaDebug
(
"vgId:%d suid:%"
PRId64
" cached related tag filter uid list cleared"
,
vgId
,
suid
);
metaDebug
(
"vgId:%d suid:%"
PRId64
" cached related tag filter uid list cleared"
,
vgId
,
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
metaGetCachedTbGroup
(
SMeta
*
pMeta
,
tb_uid_t
suid
,
const
uint8_t
*
pKey
,
int32_t
keyLen
,
SArray
**
pList
)
{
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
// generate the composed key for LRU cache
SLRUCache
*
pCache
=
pMeta
->
pCache
->
STbGroupResCache
.
pResCache
;
SHashObj
*
pTableMap
=
pMeta
->
pCache
->
STbGroupResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
STbGroupResCache
.
lock
;
*
pList
=
NULL
;
uint64_t
key
[
4
];
initCacheKey
(
key
,
pTableMap
,
suid
,
(
const
char
*
)
pKey
,
keyLen
);
taosThreadMutexLock
(
pLock
);
pMeta
->
pCache
->
STbGroupResCache
.
accTimes
+=
1
;
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
);
if
(
pHandle
==
NULL
)
{
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableMap
,
&
suid
,
sizeof
(
uint64_t
));
if
(
NULL
==
pEntry
)
{
metaDebug
(
"suid %"
PRIu64
" not in tb group cache"
,
suid
);
return
TSDB_CODE_FAILED
;
}
*
pList
=
taosArrayDup
(
taosLRUCacheValue
(
pCache
,
pHandle
),
NULL
);
(
*
pEntry
)
->
hitTimes
+=
1
;
uint32_t
acc
=
pMeta
->
pCache
->
STbGroupResCache
.
accTimes
;
if
((
*
pEntry
)
->
hitTimes
%
5000
==
0
&&
(
*
pEntry
)
->
hitTimes
>
0
)
{
metaInfo
(
"vgId:%d tb group cache hit:%d, total acc:%d, rate:%.2f"
,
vgId
,
(
*
pEntry
)
->
hitTimes
,
acc
,
((
double
)(
*
pEntry
)
->
hitTimes
)
/
acc
);
}
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
// unlock meta
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
static
void
freeTbGroupCachePayload
(
const
void
*
key
,
size_t
keyLen
,
void
*
value
)
{
if
(
value
==
NULL
)
{
return
;
}
const
uint64_t
*
p
=
key
;
if
(
keyLen
!=
sizeof
(
int64_t
)
*
4
)
{
metaError
(
"tb group key length is invalid, length:%d, expect:%d"
,
(
int32_t
)
keyLen
,
(
int32_t
)
sizeof
(
uint64_t
)
*
2
);
return
;
}
SHashObj
*
pHashObj
=
(
SHashObj
*
)
p
[
0
];
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pHashObj
,
&
p
[
1
],
sizeof
(
uint64_t
));
if
(
pEntry
!=
NULL
&&
(
*
pEntry
)
!=
NULL
)
{
int64_t
st
=
taosGetTimestampUs
();
SListIter
iter
=
{
0
};
tdListInitIter
((
SList
*
)
&
((
*
pEntry
)
->
list
),
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
uint64_t
*
digest
=
(
uint64_t
*
)
pNode
->
data
;
if
(
digest
[
0
]
==
p
[
2
]
&&
digest
[
1
]
==
p
[
3
])
{
void
*
tmp
=
tdListPopNode
(
&
((
*
pEntry
)
->
list
),
pNode
);
taosMemoryFree
(
tmp
);
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
metaDebug
(
"clear one item in tb group cache, remain cached item:%d, elapsed time:%.2fms"
,
listNEles
(
&
((
*
pEntry
)
->
list
)),
el
);
break
;
}
}
}
taosArrayDestroy
((
SArray
*
)
value
);
}
int32_t
metaPutTbGroupToCache
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
payloadLen
)
{
int32_t
code
=
0
;
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
if
(
payloadLen
>
tsTagFilterResCacheSize
)
{
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" ignore to add to tb group cache, due to payload length %d greater than threshold %d"
,
vgId
,
suid
,
payloadLen
,
tsTagFilterResCacheSize
);
taosArrayDestroy
((
SArray
*
)
pPayload
);
return
TSDB_CODE_SUCCESS
;
}
SLRUCache
*
pCache
=
pMeta
->
pCache
->
STbGroupResCache
.
pResCache
;
SHashObj
*
pTableEntry
=
pMeta
->
pCache
->
STbGroupResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
STbGroupResCache
.
lock
;
uint64_t
key
[
4
]
=
{
0
};
initCacheKey
(
key
,
pTableEntry
,
suid
,
pKey
,
keyLen
);
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
)
{
code
=
addNewEntry
(
pTableEntry
,
pKey
,
keyLen
,
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_end
;
}
}
else
{
// check if it exists or not
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
if
(
size
==
0
)
{
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
}
else
{
SListNode
*
pNode
=
listHead
(
&
(
*
pEntry
)
->
list
);
uint64_t
*
p
=
(
uint64_t
*
)
pNode
->
data
;
if
(
p
[
1
]
==
((
uint64_t
*
)
pKey
)[
1
]
&&
p
[
0
]
==
((
uint64_t
*
)
pKey
)[
0
])
{
// we have already found the existed items, no need to added to cache anymore.
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
else
{
// not equal, append it
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
}
}
}
// add to cache.
taosLRUCacheInsert
(
pCache
,
key
,
TAG_FILTER_RES_KEY_LEN
,
pPayload
,
payloadLen
,
freeTbGroupCachePayload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
_end:
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" tb group added into cache, total:%d, tables:%d"
,
vgId
,
suid
,
(
int32_t
)
taosLRUCacheGetUsage
(
pCache
),
taosHashGetSize
(
pTableEntry
));
return
code
;
}
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
int32_t
metaTbGroupCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
)
{
uint64_t
p
[
4
]
=
{
0
};
int32_t
vgId
=
TD_VID
(
pMeta
->
pVnode
);
SHashObj
*
pEntryHashMap
=
pMeta
->
pCache
->
STbGroupResCache
.
pTableEntry
;
uint64_t
dummy
[
2
]
=
{
0
};
initCacheKey
(
p
,
pEntryHashMap
,
suid
,
(
char
*
)
&
dummy
[
0
],
16
);
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
STbGroupResCache
.
lock
;
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pEntryHashMap
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
||
listNEles
(
&
(
*
pEntry
)
->
list
)
==
0
)
{
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
(
*
pEntry
)
->
hitTimes
=
0
;
SListIter
iter
=
{
0
};
tdListInitIter
(
&
(
*
pEntry
)
->
list
,
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
setMD5DigestInKey
(
p
,
pNode
->
data
,
2
*
sizeof
(
uint64_t
));
taosLRUCacheErase
(
pMeta
->
pCache
->
STbGroupResCache
.
pResCache
,
p
,
TAG_FILTER_RES_KEY_LEN
);
}
tdListEmpty
(
&
(
*
pEntry
)
->
list
);
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d suid:%"
PRId64
" cached related tb group cleared"
,
vgId
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
fb7a06e0
...
@@ -767,6 +767,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
...
@@ -767,6 +767,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
metaWLock
(
pMeta
);
metaWLock
(
pMeta
);
metaUpdateStbStats
(
pMeta
,
me
.
ctbEntry
.
suid
,
1
);
metaUpdateStbStats
(
pMeta
,
me
.
ctbEntry
.
suid
,
1
);
metaUidCacheClear
(
pMeta
,
me
.
ctbEntry
.
suid
);
metaUidCacheClear
(
pMeta
,
me
.
ctbEntry
.
suid
);
metaTbGroupCacheClear
(
pMeta
,
me
.
ctbEntry
.
suid
);
metaULock
(
pMeta
);
metaULock
(
pMeta
);
}
else
{
}
else
{
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
me
.
ntbEntry
.
ctime
=
pReq
->
ctime
;
...
@@ -998,6 +999,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -998,6 +999,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
metaUpdateStbStats
(
pMeta
,
e
.
ctbEntry
.
suid
,
-
1
);
metaUpdateStbStats
(
pMeta
,
e
.
ctbEntry
.
suid
,
-
1
);
metaUidCacheClear
(
pMeta
,
e
.
ctbEntry
.
suid
);
metaUidCacheClear
(
pMeta
,
e
.
ctbEntry
.
suid
);
metaTbGroupCacheClear
(
pMeta
,
e
.
ctbEntry
.
suid
);
}
else
if
(
e
.
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
e
.
type
==
TSDB_NORMAL_TABLE
)
{
// drop schema.db (todo)
// drop schema.db (todo)
...
@@ -1009,6 +1011,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -1009,6 +1011,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
metaStatsCacheDrop
(
pMeta
,
uid
);
metaStatsCacheDrop
(
pMeta
,
uid
);
metaUidCacheClear
(
pMeta
,
uid
);
metaUidCacheClear
(
pMeta
,
uid
);
metaTbGroupCacheClear
(
pMeta
,
uid
);
--
pMeta
->
pVnode
->
config
.
vndStats
.
numOfSTables
;
--
pMeta
->
pVnode
->
config
.
vndStats
.
numOfSTables
;
}
}
...
@@ -1429,6 +1432,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -1429,6 +1432,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
((
STag
*
)(
ctbEntry
.
ctbEntry
.
pTags
))
->
len
,
pMeta
->
txn
);
((
STag
*
)(
ctbEntry
.
ctbEntry
.
pTags
))
->
len
,
pMeta
->
txn
);
metaUidCacheClear
(
pMeta
,
ctbEntry
.
ctbEntry
.
suid
);
metaUidCacheClear
(
pMeta
,
ctbEntry
.
ctbEntry
.
suid
);
metaTbGroupCacheClear
(
pMeta
,
ctbEntry
.
ctbEntry
.
suid
);
metaULock
(
pMeta
);
metaULock
(
pMeta
);
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
fb7a06e0
...
@@ -142,6 +142,18 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id
...
@@ -142,6 +142,18 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tsdbReuseCacherowsReader
(
void
*
reader
,
void
*
pTableIdList
,
int32_t
numOfTables
)
{
SCacheRowsReader
*
pReader
=
(
SCacheRowsReader
*
)
reader
;
pReader
->
pTableList
=
pTableIdList
;
pReader
->
numOfTables
=
numOfTables
;
pReader
->
lastTs
=
INT64_MIN
;
resetLastBlockLoadInfo
(
pReader
->
pLoadInfo
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsdbCacherowsReaderOpen
(
void
*
pVnode
,
int32_t
type
,
void
*
pTableIdList
,
int32_t
numOfTables
,
int32_t
numOfCols
,
int32_t
tsdbCacherowsReaderOpen
(
void
*
pVnode
,
int32_t
type
,
void
*
pTableIdList
,
int32_t
numOfTables
,
int32_t
numOfCols
,
uint64_t
suid
,
void
**
pReader
,
const
char
*
idstr
)
{
uint64_t
suid
,
void
**
pReader
,
const
char
*
idstr
)
{
*
pReader
=
NULL
;
*
pReader
=
NULL
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
fb7a06e0
...
@@ -210,6 +210,7 @@ struct STsdbReader {
...
@@ -210,6 +210,7 @@ struct STsdbReader {
SBlockLoadSuppInfo
suppInfo
;
SBlockLoadSuppInfo
suppInfo
;
STsdbReadSnap
*
pReadSnap
;
STsdbReadSnap
*
pReadSnap
;
SIOCostSummary
cost
;
SIOCostSummary
cost
;
SHashObj
**
pIgnoreTables
;
STSchema
*
pSchema
;
// the newest version schema
STSchema
*
pSchema
;
// the newest version schema
SSHashObj
*
pSchemaMap
;
// keep the retrieved schema info, to avoid the overhead by repeatly load schema
SSHashObj
*
pSchemaMap
;
// keep the retrieved schema info, to avoid the overhead by repeatly load schema
SDataFReader
*
pFileReader
;
// the file reader
SDataFReader
*
pFileReader
;
// the file reader
...
@@ -2785,15 +2786,21 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
...
@@ -2785,15 +2786,21 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
int32_t
step
=
asc
?
1
:
-
1
;
int32_t
step
=
asc
?
1
:
-
1
;
double
el
=
0
;
double
el
=
0
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
STableBlockScanInfo
*
pBlockScanInfo
=
NULL
;
STableBlockScanInfo
*
pBlockScanInfo
=
NULL
;
if
(
pBlockInfo
!=
NULL
)
{
if
(
pBlockInfo
!=
NULL
)
{
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
)))
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
return
code
;
}
pBlockScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
pBlockInfo
->
uid
,
pReader
->
idStr
);
pBlockScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
pBlockInfo
->
uid
,
pReader
->
idStr
);
if
(
pBlockScanInfo
==
NULL
)
{
if
(
pBlockScanInfo
==
NULL
)
{
goto
_end
;
goto
_end
;
}
}
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pBlockScanInfo
,
pReader
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pBlockScanInfo
,
pReader
);
// it is a clean block, load it directly
// it is a clean block, load it directly
...
@@ -2812,9 +2819,12 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
...
@@ -2812,9 +2819,12 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
}
}
}
else
{
// file blocks not exist
}
else
{
// file blocks not exist
pBlockScanInfo
=
*
pReader
->
status
.
pTableIter
;
pBlockScanInfo
=
*
pReader
->
status
.
pTableIter
;
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pBlockScanInfo
->
uid
,
sizeof
(
pBlockScanInfo
->
uid
)))
{
setBlockAllDumped
(
pDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
return
code
;
}
}
}
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
SBlockData
*
pBlockData
=
&
pReader
->
status
.
fileBlockData
;
while
(
1
)
{
while
(
1
)
{
...
@@ -3101,6 +3111,14 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -3101,6 +3111,14 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
// load the last data block of current table
// load the last data block of current table
STableBlockScanInfo
*
pScanInfo
=
*
(
STableBlockScanInfo
**
)
pStatus
->
pTableIter
;
STableBlockScanInfo
*
pScanInfo
=
*
(
STableBlockScanInfo
**
)
pStatus
->
pTableIter
;
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pScanInfo
->
uid
,
sizeof
(
pScanInfo
->
uid
)))
{
bool
hasNexTable
=
moveToNextTable
(
pUidList
,
pStatus
);
if
(
!
hasNexTable
)
{
return
TSDB_CODE_SUCCESS
;
}
continue
;
}
// reset the index in last block when handing a new file
// reset the index in last block when handing a new file
doCleanupTableScanInfo
(
pScanInfo
);
doCleanupTableScanInfo
(
pScanInfo
);
...
@@ -3156,20 +3174,24 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
...
@@ -3156,20 +3174,24 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
static
int32_t
doBuildDataBlock
(
STsdbReader
*
pReader
)
{
static
int32_t
doBuildDataBlock
(
STsdbReader
*
pReader
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SDataBlk
*
pBlock
=
NULL
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
SDataBlockIter
*
pBlockIter
=
&
pStatus
->
blockIter
;
STableBlockScanInfo
*
pScanInfo
=
NULL
;
STableBlockScanInfo
*
pScanInfo
=
NULL
;
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SLastBlockReader
*
pLastBlockReader
=
pReader
->
status
.
fileIter
.
pLastBlockReader
;
SLastBlockReader
*
pLastBlockReader
=
pReader
->
status
.
fileIter
.
pLastBlockReader
;
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
pBlockInfo
->
uid
,
sizeof
(
pBlockInfo
->
uid
)))
{
setBlockAllDumped
(
&
pStatus
->
fBlockDumpInfo
,
pBlock
->
maxKey
.
ts
,
pReader
->
order
);
return
code
;
}
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
pBlockInfo
->
uid
,
pReader
->
idStr
);
pScanInfo
=
getTableBlockScanInfo
(
pReader
->
status
.
pTableMap
,
pBlockInfo
->
uid
,
pReader
->
idStr
);
if
(
pScanInfo
==
NULL
)
{
if
(
pScanInfo
==
NULL
)
{
return
terrno
;
return
terrno
;
}
}
pBlock
=
getCurrentBlock
(
pBlockIter
);
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
initLastBlockReader
(
pLastBlockReader
,
pScanInfo
,
pReader
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pScanInfo
,
pReader
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pScanInfo
,
pReader
);
...
@@ -3402,6 +3424,13 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
...
@@ -3402,6 +3424,13 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
}
}
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
if
(
pReader
->
pIgnoreTables
&&
taosHashGet
(
*
pReader
->
pIgnoreTables
,
&
(
*
pBlockScanInfo
)
->
uid
,
sizeof
((
*
pBlockScanInfo
)
->
uid
)))
{
bool
hasNexTable
=
moveToNextTable
(
pUidList
,
pStatus
);
if
(
!
hasNexTable
)
{
return
TSDB_CODE_SUCCESS
;
}
}
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
initMemDataIterator
(
*
pBlockScanInfo
,
pReader
);
int64_t
endKey
=
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
?
INT64_MAX
:
INT64_MIN
;
int64_t
endKey
=
(
ASCENDING_TRAVERSE
(
pReader
->
order
))
?
INT64_MAX
:
INT64_MIN
;
...
@@ -4356,7 +4385,7 @@ static void freeSchemaFunc(void* param) {
...
@@ -4356,7 +4385,7 @@ static void freeSchemaFunc(void* param) {
// ====================================== EXPOSED APIs ======================================
// ====================================== EXPOSED APIs ======================================
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
void
*
pTableList
,
int32_t
numOfTables
,
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
void
*
pTableList
,
int32_t
numOfTables
,
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
,
bool
countOnly
)
{
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
,
bool
countOnly
,
SHashObj
**
pIgnoreTables
)
{
STimeWindow
window
=
pCond
->
twindows
;
STimeWindow
window
=
pCond
->
twindows
;
int32_t
capacity
=
pVnode
->
config
.
tsdbCfg
.
maxRows
;
int32_t
capacity
=
pVnode
->
config
.
tsdbCfg
.
maxRows
;
...
@@ -4466,6 +4495,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
...
@@ -4466,6 +4495,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
pReader
->
readMode
=
READ_MODE_COUNT_ONLY
;
pReader
->
readMode
=
READ_MODE_COUNT_ONLY
;
}
}
pReader
->
pIgnoreTables
=
pIgnoreTables
;
tsdbDebug
(
"%p total numOfTable:%d in this query %s"
,
pReader
,
numOfTables
,
pReader
->
idStr
);
tsdbDebug
(
"%p total numOfTable:%d in this query %s"
,
pReader
,
numOfTables
,
pReader
->
idStr
);
return
code
;
return
code
;
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
fb7a06e0
...
@@ -82,6 +82,7 @@ enum {
...
@@ -82,6 +82,7 @@ enum {
enum
{
enum
{
CTG_OP_UPDATE_VGROUP
=
0
,
CTG_OP_UPDATE_VGROUP
=
0
,
CTG_OP_UPDATE_DB_CFG
,
CTG_OP_UPDATE_TB_META
,
CTG_OP_UPDATE_TB_META
,
CTG_OP_DROP_DB_CACHE
,
CTG_OP_DROP_DB_CACHE
,
CTG_OP_DROP_DB_VGROUP
,
CTG_OP_DROP_DB_VGROUP
,
...
@@ -248,11 +249,17 @@ typedef struct SCtgVgCache {
...
@@ -248,11 +249,17 @@ typedef struct SCtgVgCache {
SDBVgInfo
*
vgInfo
;
SDBVgInfo
*
vgInfo
;
}
SCtgVgCache
;
}
SCtgVgCache
;
typedef
struct
SCtgCfgCache
{
SRWLatch
cfgLock
;
SDbCfgInfo
*
cfgInfo
;
}
SCtgCfgCache
;
typedef
struct
SCtgDBCache
{
typedef
struct
SCtgDBCache
{
SRWLatch
dbLock
;
// RC between destroy tbCache/stbCache and all reads
SRWLatch
dbLock
;
// RC between destroy tbCache/stbCache and all reads
uint64_t
dbId
;
uint64_t
dbId
;
int8_t
deleted
;
int8_t
deleted
;
SCtgVgCache
vgCache
;
SCtgVgCache
vgCache
;
SCtgCfgCache
cfgCache
;
SHashObj
*
tbCache
;
// key:tbname, value:SCtgTbCache
SHashObj
*
tbCache
;
// key:tbname, value:SCtgTbCache
SHashObj
*
stbCache
;
// key:suid, value:char*
SHashObj
*
stbCache
;
// key:suid, value:char*
uint64_t
dbCacheNum
[
CTG_CI_MAX_VALUE
];
uint64_t
dbCacheNum
[
CTG_CI_MAX_VALUE
];
...
@@ -261,7 +268,7 @@ typedef struct SCtgDBCache {
...
@@ -261,7 +268,7 @@ typedef struct SCtgDBCache {
typedef
struct
SCtgRentSlot
{
typedef
struct
SCtgRentSlot
{
SRWLatch
lock
;
SRWLatch
lock
;
bool
needSort
;
bool
needSort
;
SArray
*
meta
;
// element is SDb
VgVersion
or SSTableVersion
SArray
*
meta
;
// element is SDb
CacheInfo
or SSTableVersion
}
SCtgRentSlot
;
}
SCtgRentSlot
;
typedef
struct
SCtgRentMgmt
{
typedef
struct
SCtgRentMgmt
{
...
@@ -425,6 +432,13 @@ typedef struct SCtgUpdateVgMsg {
...
@@ -425,6 +432,13 @@ typedef struct SCtgUpdateVgMsg {
SDBVgInfo
*
dbInfo
;
SDBVgInfo
*
dbInfo
;
}
SCtgUpdateVgMsg
;
}
SCtgUpdateVgMsg
;
typedef
struct
SCtgUpdateDbCfgMsg
{
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
uint64_t
dbId
;
SDbCfgInfo
*
cfgInfo
;
}
SCtgUpdateDbCfgMsg
;
typedef
struct
SCtgUpdateTbMetaMsg
{
typedef
struct
SCtgUpdateTbMetaMsg
{
SCatalog
*
pCtg
;
SCatalog
*
pCtg
;
STableMetaOutput
*
pMeta
;
STableMetaOutput
*
pMeta
;
...
@@ -815,8 +829,10 @@ int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq
...
@@ -815,8 +829,10 @@ int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq
int32_t
ctgGetTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgGetTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgGetTbMetasFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetasCtx
*
ctx
,
int32_t
dbIdx
,
int32_t
ctgGetTbMetasFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetasCtx
*
ctx
,
int32_t
dbIdx
,
int32_t
*
fetchIdx
,
int32_t
baseResIdx
,
SArray
*
pList
);
int32_t
*
fetchIdx
,
int32_t
baseResIdx
,
SArray
*
pList
);
void
*
ctgCloneDbCfgInfo
(
void
*
pSrc
);
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpUpdateDbCfg
(
SCtgCacheOperation
*
operation
);
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpDropDbCache
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpDropDbCache
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpDropDbVgroup
(
SCtgCacheOperation
*
action
);
int32_t
ctgOpDropDbVgroup
(
SCtgCacheOperation
*
action
);
...
@@ -838,6 +854,7 @@ int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId,
...
@@ -838,6 +854,7 @@ int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId,
bool
syncReq
);
bool
syncReq
);
int32_t
ctgDropTbMetaEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
);
int32_t
ctgDropTbMetaEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
);
int32_t
ctgUpdateVgroupEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
);
int32_t
ctgUpdateVgroupEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
);
int32_t
ctgUpdateDbCfgEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDbCfgInfo
*
cfgInfo
,
bool
syncOp
);
int32_t
ctgUpdateTbMetaEnqueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
);
int32_t
ctgUpdateTbMetaEnqueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
);
int32_t
ctgUpdateUserEnqueue
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
,
bool
syncReq
);
int32_t
ctgUpdateUserEnqueue
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
,
bool
syncReq
);
int32_t
ctgUpdateVgEpsetEnqueue
(
SCatalog
*
pCtg
,
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
pEpSet
);
int32_t
ctgUpdateVgEpsetEnqueue
(
SCatalog
*
pCtg
,
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
pEpSet
);
...
@@ -909,9 +926,9 @@ int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFNam
...
@@ -909,9 +926,9 @@ int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFNam
void
ctgResetTbMetaTask
(
SCtgTask
*
pTask
);
void
ctgResetTbMetaTask
(
SCtgTask
*
pTask
);
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
);
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
);
int32_t
ctgStbVersionSortCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgStbVersionSortCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgDb
VgVersion
SortCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgDb
CacheInfo
SortCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgDb
VgVersion
SearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgDb
CacheInfo
SearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
void
ctgFreeSTableMetaOutput
(
STableMetaOutput
*
pOutput
);
void
ctgFreeSTableMetaOutput
(
STableMetaOutput
*
pOutput
);
int32_t
ctgUpdateMsgCtx
(
SCtgMsgCtx
*
pCtx
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
int32_t
ctgUpdateMsgCtx
(
SCtgMsgCtx
*
pCtx
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
int32_t
ctgAddMsgCtx
(
SArray
*
pCtxs
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
int32_t
ctgAddMsgCtx
(
SArray
*
pCtxs
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
...
@@ -932,6 +949,9 @@ SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
...
@@ -932,6 +949,9 @@ SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
int32_t
ctgdGetOneHandle
(
SCatalog
**
pHandle
);
int32_t
ctgdGetOneHandle
(
SCatalog
**
pHandle
);
int
ctgVgInfoComp
(
const
void
*
lp
,
const
void
*
rp
);
int
ctgVgInfoComp
(
const
void
*
lp
,
const
void
*
rp
);
int32_t
ctgMakeVgArray
(
SDBVgInfo
*
dbInfo
);
int32_t
ctgMakeVgArray
(
SDBVgInfo
*
dbInfo
);
int32_t
ctgChkSetAuthRes
(
SCatalog
*
pCtg
,
SCtgAuthReq
*
req
,
SCtgAuthRsp
*
res
);
int32_t
ctgReadDBCfgFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
);
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
int32_t
ctgAcquireVgMetaFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
);
SCtgTbCache
**
pTb
);
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
int32_t
ctgCopyTbMeta
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
,
STableMeta
**
pTableMeta
,
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
fb7a06e0
...
@@ -668,6 +668,23 @@ _return:
...
@@ -668,6 +668,23 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
CTG_ERR_RET
(
ctgReadDBCfgFromCache
(
pCtg
,
dbFName
,
pDbCfg
));
if
(
pDbCfg
->
cfgVersion
<
0
)
{
CTG_ERR_RET
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
,
NULL
));
SDbCfgInfo
*
pCfg
=
ctgCloneDbCfgInfo
(
pDbCfg
);
if
(
NULL
==
pCfg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
CTG_ERR_RET
(
ctgUpdateDbCfgEnqueue
(
pCtg
,
dbFName
,
pDbCfg
->
dbId
,
pCfg
,
false
));
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
if
(
gCtgMgmt
.
pCluster
)
{
if
(
gCtgMgmt
.
pCluster
)
{
qError
(
"catalog already initialized"
);
qError
(
"catalog already initialized"
);
...
@@ -958,6 +975,23 @@ _return:
...
@@ -958,6 +975,23 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogUpdateDbCfg
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
,
SDbCfgInfo
*
cfgInfo
)
{
CTG_API_ENTER
();
int32_t
code
=
0
;
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
cfgInfo
)
{
freeDbCfgInfo
(
cfgInfo
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
code
=
ctgUpdateDbCfgEnqueue
(
pCtg
,
dbFName
,
dbId
,
cfgInfo
,
false
);
_return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogRemoveDB
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
)
{
int32_t
catalogRemoveDB
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -1371,14 +1405,14 @@ int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion** stables, uint3
...
@@ -1371,14 +1405,14 @@ int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion** stables, uint3
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableVersion
)));
}
}
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDb
VgVersion
**
dbs
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDb
CacheInfo
**
dbs
,
uint32_t
*
num
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
dbs
||
NULL
==
num
)
{
if
(
NULL
==
pCtg
||
NULL
==
dbs
||
NULL
==
num
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
dbRent
,
(
void
**
)
dbs
,
num
,
sizeof
(
SDb
VgVersion
)));
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
dbRent
,
(
void
**
)
dbs
,
num
,
sizeof
(
SDb
CacheInfo
)));
}
}
int32_t
catalogGetExpiredUsers
(
SCatalog
*
pCtg
,
SUserAuthVersion
**
users
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredUsers
(
SCatalog
*
pCtg
,
SUserAuthVersion
**
users
,
uint32_t
*
num
)
{
...
@@ -1426,9 +1460,7 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbF
...
@@ -1426,9 +1460,7 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbF
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_CACHE_NHIT_INC
(
CTG_CI_DB_CFG
,
1
);
CTG_API_LEAVE
(
ctgGetDBCfg
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
));
CTG_API_LEAVE
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
dbFName
,
pDbCfg
,
NULL
));
}
}
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
int32_t
catalogGetIndexMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
pInfo
)
{
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
fb7a06e0
...
@@ -1587,7 +1587,6 @@ int32_t ctgHandleGetTbIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
...
@@ -1587,7 +1587,6 @@ int32_t ctgHandleGetTbIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu
CTG_ERR_JRET
(
ctgCloneTableIndex
(
pOut
->
pIndex
,
&
pInfo
));
CTG_ERR_JRET
(
ctgCloneTableIndex
(
pOut
->
pIndex
,
&
pInfo
));
pTask
->
res
=
pInfo
;
pTask
->
res
=
pInfo
;
SCtgTbIndexCtx
*
ctx
=
pTask
->
taskCtx
;
CTG_ERR_JRET
(
ctgUpdateTbIndexEnqueue
(
pTask
->
pJob
->
pCtg
,
(
STableIndex
**
)
&
pTask
->
msgCtx
.
out
,
false
));
CTG_ERR_JRET
(
ctgUpdateTbIndexEnqueue
(
pTask
->
pJob
->
pCtg
,
(
STableIndex
**
)
&
pTask
->
msgCtx
.
out
,
false
));
_return:
_return:
...
@@ -1660,8 +1659,14 @@ _return:
...
@@ -1660,8 +1659,14 @@ _return:
int32_t
ctgHandleGetDbCfgRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
ctgHandleGetDbCfgRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
SCtgDbCfgCtx
*
ctx
=
pTask
->
taskCtx
;
CTG_ERR_JRET
(
ctgProcessRspMsg
(
pTask
->
msgCtx
.
out
,
reqType
,
pMsg
->
pData
,
pMsg
->
len
,
rspCode
,
pTask
->
msgCtx
.
target
));
CTG_ERR_JRET
(
ctgProcessRspMsg
(
pTask
->
msgCtx
.
out
,
reqType
,
pMsg
->
pData
,
pMsg
->
len
,
rspCode
,
pTask
->
msgCtx
.
target
));
SDbCfgInfo
*
pCfg
=
ctgCloneDbCfgInfo
(
pTask
->
msgCtx
.
out
);
CTG_ERR_RET
(
ctgUpdateDbCfgEnqueue
(
pTask
->
pJob
->
pCtg
,
ctx
->
dbFName
,
pCfg
->
dbId
,
pCfg
,
false
));
TSWAP
(
pTask
->
res
,
pTask
->
msgCtx
.
out
);
TSWAP
(
pTask
->
res
,
pTask
->
msgCtx
.
out
);
_return:
_return:
...
@@ -2195,13 +2200,24 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask* pTask) {
...
@@ -2195,13 +2200,24 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask* pTask) {
SCtgDbCfgCtx
*
pCtx
=
(
SCtgDbCfgCtx
*
)
pTask
->
taskCtx
;
SCtgDbCfgCtx
*
pCtx
=
(
SCtgDbCfgCtx
*
)
pTask
->
taskCtx
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgMsgCtx
*
pMsgCtx
=
CTG_GET_TASK_MSGCTX
(
pTask
,
-
1
);
SCtgMsgCtx
*
pMsgCtx
=
CTG_GET_TASK_MSGCTX
(
pTask
,
-
1
);
SDbCfgInfo
cfgInfo
;
if
(
NULL
==
pMsgCtx
->
pBatchs
)
{
if
(
NULL
==
pMsgCtx
->
pBatchs
)
{
pMsgCtx
->
pBatchs
=
pJob
->
pBatchs
;
pMsgCtx
->
pBatchs
=
pJob
->
pBatchs
;
}
}
CTG_
CACHE_NHIT_INC
(
CTG_CI_DB_CFG
,
1
);
CTG_
ERR_RET
(
ctgReadDBCfgFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
cfgInfo
)
);
if
(
cfgInfo
.
cfgVersion
<
0
)
{
CTG_ERR_RET
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
pCtx
->
dbFName
,
NULL
,
pTask
));
CTG_ERR_RET
(
ctgGetDBCfgFromMnode
(
pCtg
,
pConn
,
pCtx
->
dbFName
,
NULL
,
pTask
));
}
else
{
pTask
->
res
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgInfo
));
if
(
NULL
==
pTask
->
res
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
pTask
->
res
,
&
cfgInfo
,
sizeof
(
cfgInfo
));
CTG_ERR_RET
(
ctgHandleTaskEnd
(
pTask
,
0
));
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
fb7a06e0
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "trpc.h"
#include "trpc.h"
SCtgOperation
gCtgCacheOperation
[
CTG_OP_MAX
]
=
{{
CTG_OP_UPDATE_VGROUP
,
"update vgInfo"
,
ctgOpUpdateVgroup
},
SCtgOperation
gCtgCacheOperation
[
CTG_OP_MAX
]
=
{{
CTG_OP_UPDATE_VGROUP
,
"update vgInfo"
,
ctgOpUpdateVgroup
},
{
CTG_OP_UPDATE_DB_CFG
,
"update dbCfg"
,
ctgOpUpdateDbCfg
},
{
CTG_OP_UPDATE_TB_META
,
"update tbMeta"
,
ctgOpUpdateTbMeta
},
{
CTG_OP_UPDATE_TB_META
,
"update tbMeta"
,
ctgOpUpdateTbMeta
},
{
CTG_OP_DROP_DB_CACHE
,
"drop DB"
,
ctgOpDropDbCache
},
{
CTG_OP_DROP_DB_CACHE
,
"drop DB"
,
ctgOpDropDbCache
},
{
CTG_OP_DROP_DB_VGROUP
,
"drop DBVgroup"
,
ctgOpDropDbVgroup
},
{
CTG_OP_DROP_DB_VGROUP
,
"drop DBVgroup"
,
ctgOpDropDbVgroup
},
...
@@ -89,10 +90,15 @@ int32_t ctgWLockVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache) {
...
@@ -89,10 +90,15 @@ int32_t ctgWLockVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
ctgRUnlockVgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgCache
.
vgLock
);
}
void
ctgRLockDbCfgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
cfgCache
.
cfgLock
);
}
void
ctgWLockDbCfgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
cfgCache
.
cfgLock
);
}
void
ctgRUnlockVgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgCache
.
vgLock
);
}
void
ctgWUnlockVgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgCache
.
vgLock
);
}
void
ctgWUnlockVgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgCache
.
vgLock
);
}
void
ctgRUnlockDbCfgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
cfgCache
.
cfgLock
);
}
void
ctgWUnlockDbCfgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
cfgCache
.
cfgLock
);
}
void
ctgReleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
void
ctgReleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
dbLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
dbLock
);
taosHashRelease
(
pCtg
->
dbCache
,
dbCache
);
taosHashRelease
(
pCtg
->
dbCache
,
dbCache
);
...
@@ -703,6 +709,43 @@ _return:
...
@@ -703,6 +709,43 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgReadDBCfgFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
pDbCfg
->
cfgVersion
=
-
1
;
CTG_CACHE_NHIT_INC
(
CTG_CI_DB_CFG
,
1
);
return
TSDB_CODE_SUCCESS
;
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
cfgCache
.
cfgLock
);
if
(
dbCache
->
cfgCache
.
cfgInfo
)
{
SDbCfgInfo
*
pInfo
=
ctgCloneDbCfgInfo
(
dbCache
->
cfgCache
.
cfgInfo
);
if
(
NULL
==
pInfo
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
pDbCfg
,
pInfo
,
sizeof
(
*
pInfo
));
taosMemoryFree
(
pInfo
);
CTG_CACHE_HIT_INC
(
CTG_CI_DB_CFG
,
1
);
}
else
{
pDbCfg
->
cfgVersion
=
-
1
;
CTG_CACHE_NHIT_INC
(
CTG_CI_DB_CFG
,
1
);
}
_return:
if
(
dbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
cfgCache
.
cfgLock
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
return
code
;
}
int32_t
ctgGetCachedStbNameFromSuid
(
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
char
**
stbName
)
{
int32_t
ctgGetCachedStbNameFromSuid
(
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
char
**
stbName
)
{
*
stbName
=
NULL
;
*
stbName
=
NULL
;
...
@@ -726,6 +769,7 @@ int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid
...
@@ -726,6 +769,7 @@ int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
SUserAuthInfo
*
pReq
,
bool
*
inCache
,
SCtgAuthRsp
*
pRes
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
if
(
IS_SYS_DBNAME
(
pReq
->
tbName
.
dbname
))
{
...
@@ -1006,6 +1050,44 @@ _return:
...
@@ -1006,6 +1050,44 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgUpdateDbCfgEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDbCfgInfo
*
cfgInfo
,
bool
syncOp
)
{
int32_t
code
=
0
;
SCtgCacheOperation
*
op
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgCacheOperation
));
op
->
opId
=
CTG_OP_UPDATE_DB_CFG
;
op
->
syncOp
=
syncOp
;
SCtgUpdateDbCfgMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateDbCfgMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateDbCfgMsg
));
taosMemoryFree
(
op
);
freeDbCfgInfo
(
cfgInfo
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
char
*
p
=
strchr
(
dbFName
,
'.'
);
if
(
p
&&
IS_SYS_DBNAME
(
p
+
1
))
{
dbFName
=
p
+
1
;
}
tstrncpy
(
msg
->
dbFName
,
dbFName
,
sizeof
(
msg
->
dbFName
));
msg
->
pCtg
=
pCtg
;
msg
->
dbId
=
dbId
;
msg
->
cfgInfo
=
cfgInfo
;
op
->
data
=
msg
;
CTG_ERR_JRET
(
ctgEnqueue
(
pCtg
,
op
));
return
TSDB_CODE_SUCCESS
;
_return:
freeDbCfgInfo
(
cfgInfo
);
CTG_RET
(
code
);
}
int32_t
ctgUpdateTbMetaEnqueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncOp
)
{
int32_t
ctgUpdateTbMetaEnqueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncOp
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgCacheOperation
*
op
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgCacheOperation
));
SCtgCacheOperation
*
op
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgCacheOperation
));
...
@@ -1419,15 +1501,15 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
...
@@ -1419,15 +1501,15 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
CTG_CACHE_NUM_INC
(
CTG_CI_DB
,
1
);
CTG_CACHE_NUM_INC
(
CTG_CI_DB
,
1
);
SDb
VgVersion
vgVersion
=
{.
dbId
=
newDBCache
.
dbId
,
.
vgVersion
=
-
1
,
.
stateTs
=
0
};
SDb
CacheInfo
dbCacheInfo
=
{.
dbId
=
newDBCache
.
dbId
,
.
vgVersion
=
-
1
,
.
stateTs
=
0
,
.
cfgVersion
=
-
1
};
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
tstrncpy
(
dbCacheInfo
.
dbFName
,
dbFName
,
sizeof
(
dbCacheInfo
.
dbFName
));
ctgDebug
(
"db added to cache, dbFName:%s, dbId:0x%"
PRIx64
,
dbFName
,
dbId
);
ctgDebug
(
"db added to cache, dbFName:%s, dbId:0x%"
PRIx64
,
dbFName
,
dbId
);
if
(
!
IS_SYS_DBNAME
(
dbFName
))
{
if
(
!
IS_SYS_DBNAME
(
dbFName
))
{
CTG_ERR_RET
(
ctgMetaRentAdd
(
&
pCtg
->
dbRent
,
&
vgVersion
,
dbId
,
sizeof
(
SDbVgVersion
)));
CTG_ERR_RET
(
ctgMetaRentAdd
(
&
pCtg
->
dbRent
,
&
dbCacheInfo
,
dbId
,
sizeof
(
SDbCacheInfo
)));
ctgDebug
(
"db added to rent, dbFName:%s, vgVersion:%d, dbId:0x%"
PRIx64
,
dbFName
,
vgVersion
.
vgVersion
,
dbId
);
ctgDebug
(
"db added to rent, dbFName:%s, vgVersion:%d, dbId:0x%"
PRIx64
,
dbFName
,
dbCacheInfo
.
vgVersion
,
dbId
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1471,7 +1553,7 @@ int32_t ctgRemoveDBFromCache(SCatalog *pCtg, SCtgDBCache *dbCache, const char *d
...
@@ -1471,7 +1553,7 @@ int32_t ctgRemoveDBFromCache(SCatalog *pCtg, SCtgDBCache *dbCache, const char *d
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
dbLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
dbLock
);
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCtg
->
dbRent
,
dbId
,
ctgDb
VgVersionSortCompare
,
ctgDbVgVersion
SearchCompare
));
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCtg
->
dbRent
,
dbId
,
ctgDb
CacheInfoSortCompare
,
ctgDbCacheInfo
SearchCompare
));
ctgDebug
(
"db removed from rent, dbFName:%s, dbId:0x%"
PRIx64
,
dbFName
,
dbId
);
ctgDebug
(
"db removed from rent, dbFName:%s, dbId:0x%"
PRIx64
,
dbFName
,
dbId
);
if
(
taosHashRemove
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
)))
{
if
(
taosHashRemove
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
)))
{
...
@@ -1766,8 +1848,8 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
...
@@ -1766,8 +1848,8 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
}
}
bool
newAdded
=
false
;
bool
newAdded
=
false
;
SDb
VgVersion
vgVersion
=
{
SDb
CacheInfo
dbCacheInfo
=
{
.
dbId
=
msg
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
,
.
numOfTable
=
dbInfo
->
numOfTable
,
.
stateTs
=
dbInfo
->
stateTs
};
.
dbId
=
msg
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
,
.
cfgVersion
=
-
1
,
.
numOfTable
=
dbInfo
->
numOfTable
,
.
stateTs
=
dbInfo
->
stateTs
};
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_JRET
(
ctgGetAddDBCache
(
msg
->
pCtg
,
dbFName
,
msg
->
dbId
,
&
dbCache
));
CTG_ERR_JRET
(
ctgGetAddDBCache
(
msg
->
pCtg
,
dbFName
,
msg
->
dbId
,
&
dbCache
));
...
@@ -1803,21 +1885,25 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
...
@@ -1803,21 +1885,25 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
CTG_DB_NUM_RESET
(
CTG_CI_DB_VGROUP
);
CTG_DB_NUM_RESET
(
CTG_CI_DB_VGROUP
);
}
}
if
(
dbCache
->
cfgCache
.
cfgInfo
)
{
dbCacheInfo
.
cfgVersion
=
dbCache
->
cfgCache
.
cfgInfo
->
cfgVersion
;
}
vgCache
->
vgInfo
=
dbInfo
;
vgCache
->
vgInfo
=
dbInfo
;
msg
->
dbInfo
=
NULL
;
msg
->
dbInfo
=
NULL
;
CTG_DB_NUM_SET
(
CTG_CI_DB_VGROUP
);
CTG_DB_NUM_SET
(
CTG_CI_DB_VGROUP
);
ctgDebug
(
"db vgInfo updated, dbFName:%s, vgVer:%d, stateTs:%"
PRId64
", dbId:0x%"
PRIx64
,
dbFName
,
ctgDebug
(
"db vgInfo updated, dbFName:%s, vgVer:%d, stateTs:%"
PRId64
", dbId:0x%"
PRIx64
,
dbFName
,
vgVersion
.
vgVersion
,
vgVersion
.
stateTs
,
vgVersion
.
dbId
);
dbCacheInfo
.
vgVersion
,
dbCacheInfo
.
stateTs
,
dbCacheInfo
.
dbId
);
ctgWUnlockVgInfo
(
dbCache
);
ctgWUnlockVgInfo
(
dbCache
);
dbCache
=
NULL
;
dbCache
=
NULL
;
// if (!IS_SYS_DBNAME(dbFName)) {
// if (!IS_SYS_DBNAME(dbFName)) {
tstrncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
tstrncpy
(
dbCacheInfo
.
dbFName
,
dbFName
,
sizeof
(
dbCacheInfo
.
dbFName
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
dbCacheInfo
,
dbCacheInfo
.
dbId
,
sizeof
(
SDbCacheInfo
),
ctgDb
VgVersionSortCompare
,
ctgDbVgVersion
SearchCompare
));
ctgDb
CacheInfoSortCompare
,
ctgDbCacheInfo
SearchCompare
));
//}
//}
_return:
_return:
...
@@ -1828,6 +1914,67 @@ _return:
...
@@ -1828,6 +1914,67 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgOpUpdateDbCfg
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgUpdateDbCfgMsg
*
msg
=
operation
->
data
;
SDbCfgInfo
*
cfgInfo
=
msg
->
cfgInfo
;
char
*
dbFName
=
msg
->
dbFName
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
if
(
pCtg
->
stopUpdate
||
NULL
==
cfgInfo
)
{
goto
_return
;
}
if
(
cfgInfo
->
cfgVersion
<
0
)
{
ctgDebug
(
"invalid db cfgInfo, dbFName:%s, cfgVersion:%d"
,
dbFName
,
cfgInfo
->
cfgVersion
);
CTG_ERR_JRET
(
TSDB_CODE_APP_ERROR
);
}
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_JRET
(
ctgGetAddDBCache
(
msg
->
pCtg
,
dbFName
,
msg
->
dbId
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"conflict db update, ignore this update, dbFName:%s, dbId:0x%"
PRIx64
,
dbFName
,
msg
->
dbId
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
SDbCacheInfo
cacheInfo
=
{
0
};
cacheInfo
.
dbId
=
dbCache
->
dbId
;
tstrncpy
(
cacheInfo
.
dbFName
,
dbFName
,
sizeof
(
cacheInfo
.
dbFName
));
cacheInfo
.
cfgVersion
=
cfgInfo
->
cfgVersion
;
SCtgVgCache
*
vgCache
=
&
dbCache
->
vgCache
;
if
(
vgCache
->
vgInfo
)
{
cacheInfo
.
vgVersion
=
vgCache
->
vgInfo
->
vgVersion
;
cacheInfo
.
numOfTable
=
vgCache
->
vgInfo
->
numOfTable
;
cacheInfo
.
stateTs
=
vgCache
->
vgInfo
->
stateTs
;
}
else
{
cacheInfo
.
vgVersion
=
-
1
;
}
ctgWLockDbCfgInfo
(
dbCache
);
freeDbCfgInfo
(
dbCache
->
cfgCache
.
cfgInfo
);
dbCache
->
cfgCache
.
cfgInfo
=
cfgInfo
;
cfgInfo
=
NULL
;
ctgWUnlockDbCfgInfo
(
dbCache
);
ctgDebug
(
"db cfgInfo updated, dbFName:%s, cfgVer:%d"
,
dbFName
,
dbCache
->
cfgCache
.
cfgInfo
->
cfgVersion
);
// if (!IS_SYS_DBNAME(dbFName)) {
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
cacheInfo
,
cacheInfo
.
dbId
,
sizeof
(
SDbCacheInfo
),
ctgDbCacheInfoSortCompare
,
ctgDbCacheInfoSearchCompare
));
//}
_return:
freeDbCfgInfo
(
cfgInfo
);
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgOpDropDbCache
(
SCtgCacheOperation
*
operation
)
{
int32_t
ctgOpDropDbCache
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgDropDBMsg
*
msg
=
operation
->
data
;
SCtgDropDBMsg
*
msg
=
operation
->
data
;
...
@@ -2080,27 +2227,19 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
...
@@ -2080,27 +2227,19 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
CTG_LOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
CTG_LOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
taosHashCleanup
(
pUser
->
userAuth
.
createdDbs
);
taosHashCleanup
(
pUser
->
userAuth
.
createdDbs
);
pUser
->
userAuth
.
createdDbs
=
msg
->
userAuth
.
createdDbs
;
msg
->
userAuth
.
createdDbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
readDbs
);
taosHashCleanup
(
pUser
->
userAuth
.
readDbs
);
pUser
->
userAuth
.
readDbs
=
msg
->
userAuth
.
readDbs
;
msg
->
userAuth
.
readDbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
writeDbs
);
taosHashCleanup
(
pUser
->
userAuth
.
writeDbs
);
pUser
->
userAuth
.
writeDbs
=
msg
->
userAuth
.
writeDbs
;
msg
->
userAuth
.
writeDbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
readTbs
);
taosHashCleanup
(
pUser
->
userAuth
.
readTbs
);
pUser
->
userAuth
.
readTbs
=
msg
->
userAuth
.
readTbs
;
msg
->
userAuth
.
readTbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
writeTbs
);
taosHashCleanup
(
pUser
->
userAuth
.
writeTbs
);
pUser
->
userAuth
.
writeTbs
=
msg
->
userAuth
.
writeTbs
;
msg
->
userAuth
.
writeTbs
=
NULL
;
taosHashCleanup
(
pUser
->
userAuth
.
useDbs
);
taosHashCleanup
(
pUser
->
userAuth
.
useDbs
);
pUser
->
userAuth
.
useDbs
=
msg
->
userAuth
.
useDbs
;
memcpy
(
&
pUser
->
userAuth
,
&
msg
->
userAuth
,
sizeof
(
msg
->
userAuth
));
msg
->
userAuth
.
createdDbs
=
NULL
;
msg
->
userAuth
.
readDbs
=
NULL
;
msg
->
userAuth
.
writeDbs
=
NULL
;
msg
->
userAuth
.
readTbs
=
NULL
;
msg
->
userAuth
.
writeTbs
=
NULL
;
msg
->
userAuth
.
useDbs
=
NULL
;
msg
->
userAuth
.
useDbs
=
NULL
;
CTG_UNLOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
pUser
->
lock
);
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
fb7a06e0
...
@@ -501,6 +501,25 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
...
@@ -501,6 +501,25 @@ void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) {
}
}
}
}
if
(
dbCache
->
cfgCache
.
cfgInfo
)
{
SDbCfgInfo
*
pCfg
=
dbCache
->
cfgCache
.
cfgInfo
;
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: cfgVersion:%d, numOfVgroups:%d, numOfStables:%d, buffer:%d, cacheSize:%d, pageSize:%d, pages:%d"
", daysPerFile:%d, daysToKeep0:%d, daysToKeep1:%d, daysToKeep2:%d, minRows:%d, maxRows:%d, walFsyncPeriod:%d"
", hashPrefix:%d, hashSuffix:%d, walLevel:%d, precision:%d, compression:%d, replications:%d, strict:%d"
", cacheLast:%d, tsdbPageSize:%d, walRetentionPeriod:%d, walRollPeriod:%d, walRetentionSize:%"
PRId64
""
", walSegmentSize:%"
PRId64
", numOfRetensions:%d, schemaless:%d, sstTrigger:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
pCfg
->
cfgVersion
,
pCfg
->
numOfVgroups
,
pCfg
->
numOfStables
,
pCfg
->
buffer
,
pCfg
->
cacheSize
,
pCfg
->
pageSize
,
pCfg
->
pages
,
pCfg
->
daysPerFile
,
pCfg
->
daysToKeep0
,
pCfg
->
daysToKeep1
,
pCfg
->
daysToKeep2
,
pCfg
->
minRows
,
pCfg
->
maxRows
,
pCfg
->
walFsyncPeriod
,
pCfg
->
hashPrefix
,
pCfg
->
hashSuffix
,
pCfg
->
walLevel
,
pCfg
->
precision
,
pCfg
->
compression
,
pCfg
->
replications
,
pCfg
->
strict
,
pCfg
->
cacheLast
,
pCfg
->
tsdbPageSize
,
pCfg
->
walRetentionPeriod
,
pCfg
->
walRollPeriod
,
pCfg
->
walRetentionSize
,
pCfg
->
walSegmentSize
,
pCfg
->
numOfRetensions
,
pCfg
->
schemaless
,
pCfg
->
sstTrigger
);
}
++
i
;
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
}
}
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
fb7a06e0
...
@@ -236,6 +236,7 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) {
...
@@ -236,6 +236,7 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) {
}
}
void
ctgFreeVgInfoCache
(
SCtgDBCache
*
dbCache
)
{
freeVgInfo
(
dbCache
->
vgCache
.
vgInfo
);
}
void
ctgFreeVgInfoCache
(
SCtgDBCache
*
dbCache
)
{
freeVgInfo
(
dbCache
->
vgCache
.
vgInfo
);
}
void
ctgFreeCfgInfoCache
(
SCtgDBCache
*
dbCache
)
{
freeDbCfgInfo
(
dbCache
->
cfgCache
.
cfgInfo
);
}
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
)
{
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
)
{
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
...
@@ -243,6 +244,7 @@ void ctgFreeDbCache(SCtgDBCache* dbCache) {
...
@@ -243,6 +244,7 @@ void ctgFreeDbCache(SCtgDBCache* dbCache) {
}
}
ctgFreeVgInfoCache
(
dbCache
);
ctgFreeVgInfoCache
(
dbCache
);
ctgFreeCfgInfoCache
(
dbCache
);
ctgFreeStbMetaCache
(
dbCache
);
ctgFreeStbMetaCache
(
dbCache
);
ctgFreeTbCache
(
dbCache
);
ctgFreeTbCache
(
dbCache
);
}
}
...
@@ -1073,10 +1075,10 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
...
@@ -1073,10 +1075,10 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) {
}
}
}
}
int32_t
ctgDb
VgVersion
SearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
int32_t
ctgDb
CacheInfo
SearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
int64_t
*
)
key1
<
((
SDb
VgVersion
*
)
key2
)
->
dbId
)
{
if
(
*
(
int64_t
*
)
key1
<
((
SDb
CacheInfo
*
)
key2
)
->
dbId
)
{
return
-
1
;
return
-
1
;
}
else
if
(
*
(
int64_t
*
)
key1
>
((
SDb
VgVersion
*
)
key2
)
->
dbId
)
{
}
else
if
(
*
(
int64_t
*
)
key1
>
((
SDb
CacheInfo
*
)
key2
)
->
dbId
)
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
...
@@ -1093,10 +1095,10 @@ int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) {
...
@@ -1093,10 +1095,10 @@ int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) {
}
}
}
}
int32_t
ctgDb
VgVersion
SortCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
int32_t
ctgDb
CacheInfo
SortCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
SDb
VgVersion
*
)
key1
)
->
dbId
<
((
SDbVgVersion
*
)
key2
)
->
dbId
)
{
if
(((
SDb
CacheInfo
*
)
key1
)
->
dbId
<
((
SDbCacheInfo
*
)
key2
)
->
dbId
)
{
return
-
1
;
return
-
1
;
}
else
if
(((
SDb
VgVersion
*
)
key1
)
->
dbId
>
((
SDbVgVersion
*
)
key2
)
->
dbId
)
{
}
else
if
(((
SDb
CacheInfo
*
)
key1
)
->
dbId
>
((
SDbCacheInfo
*
)
key2
)
->
dbId
)
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
...
@@ -1267,16 +1269,20 @@ static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)p
...
@@ -1267,16 +1269,20 @@ static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)p
static
void
ctgFreeDbVgroup
(
void
*
p
)
{
taosArrayDestroy
((
SArray
*
)((
SMetaRes
*
)
p
)
->
pRes
);
}
static
void
ctgFreeDbVgroup
(
void
*
p
)
{
taosArrayDestroy
((
SArray
*
)((
SMetaRes
*
)
p
)
->
pRes
);
}
static
void
*
ctgCloneDbCfgInfo
(
void
*
pSrc
)
{
void
*
ctgCloneDbCfgInfo
(
void
*
pSrc
)
{
SDbCfgInfo
*
pDst
=
taosMemoryMalloc
(
sizeof
(
SDbCfgInfo
));
SDbCfgInfo
*
pDst
=
taosMemoryMalloc
(
sizeof
(
SDbCfgInfo
));
if
(
NULL
==
pDst
)
{
if
(
NULL
==
pDst
)
{
return
NULL
;
return
NULL
;
}
}
memcpy
(
pDst
,
pSrc
,
sizeof
(
SDbCfgInfo
));
memcpy
(
pDst
,
pSrc
,
sizeof
(
SDbCfgInfo
));
pDst
->
pRetensions
=
taosArrayDup
(((
SDbCfgInfo
*
)
pSrc
)
->
pRetensions
,
NULL
);
return
pDst
;
return
pDst
;
}
}
static
void
ctgFreeDbCfgInfo
(
void
*
p
)
{
taosMemoryFree
(((
SMetaRes
*
)
p
)
->
pRes
);
}
static
void
ctgFreeDbCfgInfo
(
void
*
p
)
{
SDbCfgInfo
*
pDst
=
(
SDbCfgInfo
*
)((
SMetaRes
*
)
p
)
->
pRes
;
freeDbCfgInfo
(
pDst
);
}
static
void
*
ctgCloneDbInfo
(
void
*
pSrc
)
{
static
void
*
ctgCloneDbInfo
(
void
*
pSrc
)
{
SDbInfo
*
pDst
=
taosMemoryMalloc
(
sizeof
(
SDbInfo
));
SDbInfo
*
pDst
=
taosMemoryMalloc
(
sizeof
(
SDbInfo
));
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
fb7a06e0
...
@@ -1331,7 +1331,7 @@ TEST(tableMeta, normalTable) {
...
@@ -1331,7 +1331,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
SDb
VgVersion
*
dbs
=
NULL
;
SDb
CacheInfo
*
dbs
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
int32_t
i
=
0
;
int32_t
i
=
0
;
...
@@ -1443,7 +1443,7 @@ TEST(tableMeta, childTableCase) {
...
@@ -1443,7 +1443,7 @@ TEST(tableMeta, childTableCase) {
taosMemoryFree
(
tableMeta
);
taosMemoryFree
(
tableMeta
);
SDb
VgVersion
*
dbs
=
NULL
;
SDb
CacheInfo
*
dbs
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
int32_t
i
=
0
;
int32_t
i
=
0
;
...
@@ -1584,7 +1584,7 @@ TEST(tableMeta, superTableCase) {
...
@@ -1584,7 +1584,7 @@ TEST(tableMeta, superTableCase) {
taosMemoryFree
(
tableMeta
);
taosMemoryFree
(
tableMeta
);
SDb
VgVersion
*
dbs
=
NULL
;
SDb
CacheInfo
*
dbs
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
SSTableVersion
*
stb
=
NULL
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
uint32_t
dbNum
=
0
,
stbNum
=
0
,
allDbNum
=
0
,
allStbNum
=
0
;
int32_t
i
=
0
;
int32_t
i
=
0
;
...
@@ -2680,7 +2680,7 @@ TEST(rentTest, allRent) {
...
@@ -2680,7 +2680,7 @@ TEST(rentTest, allRent) {
SDBVgInfo
dbVgroup
=
{
0
};
SDBVgInfo
dbVgroup
=
{
0
};
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
ctgTestStop
=
false
;
ctgTestStop
=
false
;
SDb
VgVersion
*
dbs
=
NULL
;
SDb
CacheInfo
*
dbs
=
NULL
;
SSTableVersion
*
stable
=
NULL
;
SSTableVersion
*
stable
=
NULL
;
uint32_t
num
=
0
;
uint32_t
num
=
0
;
...
...
source/libs/executor/inc/executil.h
浏览文件 @
fb7a06e0
...
@@ -87,7 +87,25 @@ typedef struct SColMatchInfo {
...
@@ -87,7 +87,25 @@ typedef struct SColMatchInfo {
}
SColMatchInfo
;
}
SColMatchInfo
;
typedef
struct
SExecTaskInfo
SExecTaskInfo
;
typedef
struct
SExecTaskInfo
SExecTaskInfo
;
typedef
struct
STableListInfo
STableListInfo
;
typedef
struct
STableListIdInfo
{
uint64_t
suid
;
uint64_t
uid
;
int32_t
tableType
;
}
STableListIdInfo
;
// If the numOfOutputGroups is 1, the data blocks that belongs to different groups will be provided randomly
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
typedef
struct
STableListInfo
{
bool
oneTableForEachGroup
;
int32_t
numOfOuputGroups
;
// the data block will be generated one by one
int32_t
*
groupOffset
;
// keep the offset value for each group in the tableList
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
STableListIdInfo
idInfo
;
// this maybe the super table or ordinary table
}
STableListInfo
;
struct
SqlFunctionCtx
;
struct
SqlFunctionCtx
;
int32_t
createScanTableListInfo
(
SScanPhysiNode
*
pScanNode
,
SNodeList
*
pGroupTags
,
bool
groupSort
,
SReadHandle
*
pHandle
,
int32_t
createScanTableListInfo
(
SScanPhysiNode
*
pScanNode
,
SNodeList
*
pGroupTags
,
bool
groupSort
,
SReadHandle
*
pHandle
,
...
...
source/libs/executor/inc/executorInt.h
浏览文件 @
fb7a06e0
...
@@ -213,6 +213,7 @@ typedef struct STableScanInfo {
...
@@ -213,6 +213,7 @@ typedef struct STableScanInfo {
SScanInfo
scanInfo
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
int32_t
scanTimes
;
SSDataBlock
*
pResBlock
;
SSDataBlock
*
pResBlock
;
SHashObj
*
pIgnoreTables
;
SSampleExecInfo
sample
;
// sample execution info
SSampleExecInfo
sample
;
// sample execution info
int32_t
currentGroupId
;
int32_t
currentGroupId
;
int32_t
currentTable
;
int32_t
currentTable
;
...
...
source/libs/executor/src/cachescanoperator.c
浏览文件 @
fb7a06e0
...
@@ -226,6 +226,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
...
@@ -226,6 +226,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
if
(
NULL
==
pInfo
->
pLastrowReader
)
{
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pList
,
num
,
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pList
,
num
,
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
),
suid
,
&
pInfo
->
pLastrowReader
,
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
),
suid
,
&
pInfo
->
pLastrowReader
,
pTaskInfo
->
id
.
str
);
pTaskInfo
->
id
.
str
);
...
@@ -234,6 +235,9 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
...
@@ -234,6 +235,9 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
taosArrayClear
(
pInfo
->
pUidList
);
taosArrayClear
(
pInfo
->
pUidList
);
continue
;
continue
;
}
}
}
else
{
tsdbReuseCacherowsReader
(
pInfo
->
pLastrowReader
,
pList
,
num
);
}
taosArrayClear
(
pInfo
->
pUidList
);
taosArrayClear
(
pInfo
->
pUidList
);
...
@@ -265,13 +269,14 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
...
@@ -265,13 +269,14 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
}
}
}
}
pInfo
->
pLastrowReader
=
tsdbCacherowsReaderClose
(
pInfo
->
pLastrowReader
);
//
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
else
{
}
else
{
pInfo
->
pLastrowReader
=
tsdbCacherowsReaderClose
(
pInfo
->
pLastrowReader
);
//
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
}
}
}
}
pInfo
->
pLastrowReader
=
tsdbCacherowsReaderClose
(
pInfo
->
pLastrowReader
);
setOperatorCompleted
(
pOperator
);
setOperatorCompleted
(
pOperator
);
return
NULL
;
return
NULL
;
}
}
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
fb7a06e0
...
@@ -194,9 +194,6 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
...
@@ -194,9 +194,6 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
compressed
=
pEntry
->
compressed
;
pOutput
->
compressed
=
pEntry
->
compressed
;
// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
fb7a06e0
...
@@ -28,23 +28,6 @@
...
@@ -28,23 +28,6 @@
#include "querytask.h"
#include "querytask.h"
#include "tcompression.h"
#include "tcompression.h"
typedef
struct
STableListIdInfo
{
uint64_t
suid
;
uint64_t
uid
;
int32_t
tableType
;
}
STableListIdInfo
;
// If the numOfOutputGroups is 1, the data blocks that belongs to different groups will be provided randomly
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
struct
STableListInfo
{
bool
oneTableForEachGroup
;
int32_t
numOfOuputGroups
;
// the data block will be generated one by one
int32_t
*
groupOffset
;
// keep the offset value for each group in the tableList
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
STableListIdInfo
idInfo
;
// this maybe the super table or ordinary table
};
typedef
struct
tagFilterAssist
{
typedef
struct
tagFilterAssist
{
SHashObj
*
colHash
;
SHashObj
*
colHash
;
int32_t
index
;
int32_t
index
;
...
@@ -62,7 +45,7 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArra
...
@@ -62,7 +45,7 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArra
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
SArray
*
list
,
SNode
*
pTagCond
);
static
int32_t
optimizeTbnameInCondImpl
(
void
*
metaHandle
,
SArray
*
list
,
SNode
*
pTagCond
);
static
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
static
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
,
const
char
*
idstr
);
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
,
uint8_t
*
digest
,
const
char
*
idstr
);
static
SSDataBlock
*
createTagValBlockForFilter
(
SArray
*
pColList
,
int32_t
numOfTables
,
SArray
*
pUidTagList
,
static
SSDataBlock
*
createTagValBlockForFilter
(
SArray
*
pColList
,
int32_t
numOfTables
,
SArray
*
pUidTagList
,
void
*
metaHandle
);
void
*
metaHandle
);
...
@@ -436,12 +419,49 @@ void freeItem(void* p) {
...
@@ -436,12 +419,49 @@ void freeItem(void* p) {
}
}
}
}
int32_t
getColInfoResultForGroupby
(
void
*
metaHandle
,
SNodeList
*
group
,
STableListInfo
*
pTableListInfo
)
{
static
void
genTagFilterDigest
(
const
SNode
*
pTagCond
,
T_MD5_CTX
*
pContext
)
{
if
(
pTagCond
==
NULL
)
{
return
;
}
char
*
payload
=
NULL
;
int32_t
len
=
0
;
nodesNodeToMsg
(
pTagCond
,
&
payload
,
&
len
);
tMD5Init
(
pContext
);
tMD5Update
(
pContext
,
(
uint8_t
*
)
payload
,
(
uint32_t
)
len
);
tMD5Final
(
pContext
);
taosMemoryFree
(
payload
);
}
static
void
genTbGroupDigest
(
const
SNode
*
pGroup
,
uint8_t
*
filterDigest
,
T_MD5_CTX
*
pContext
)
{
char
*
payload
=
NULL
;
int32_t
len
=
0
;
nodesNodeToMsg
(
pGroup
,
&
payload
,
&
len
);
if
(
filterDigest
[
0
])
{
payload
=
taosMemoryRealloc
(
payload
,
len
+
tListLen
(
pContext
->
digest
));
memcpy
(
payload
+
len
,
filterDigest
+
1
,
tListLen
(
pContext
->
digest
));
len
+=
tListLen
(
pContext
->
digest
);
}
tMD5Init
(
pContext
);
tMD5Update
(
pContext
,
(
uint8_t
*
)
payload
,
(
uint32_t
)
len
);
tMD5Final
(
pContext
);
taosMemoryFree
(
payload
);
}
int32_t
getColInfoResultForGroupby
(
void
*
metaHandle
,
SNodeList
*
group
,
STableListInfo
*
pTableListInfo
,
uint8_t
*
digest
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
pBlockList
=
NULL
;
SArray
*
pBlockList
=
NULL
;
SSDataBlock
*
pResBlock
=
NULL
;
SSDataBlock
*
pResBlock
=
NULL
;
void
*
keyBuf
=
NULL
;
void
*
keyBuf
=
NULL
;
SArray
*
groupData
=
NULL
;
SArray
*
groupData
=
NULL
;
SArray
*
pUidTagList
=
NULL
;
SArray
*
tableList
=
NULL
;
int32_t
rows
=
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
int32_t
rows
=
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
if
(
rows
==
0
)
{
if
(
rows
==
0
)
{
...
@@ -468,7 +488,23 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
...
@@ -468,7 +488,23 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
REPLACE_NODE
(
pNode
);
REPLACE_NODE
(
pNode
);
}
}
SArray
*
pUidTagList
=
taosArrayInit
(
8
,
sizeof
(
STUidTagInfo
));
T_MD5_CTX
context
=
{
0
};
if
(
tsTagFilterCache
)
{
SNodeListNode
*
listNode
=
(
SNodeListNode
*
)
nodesMakeNode
(
QUERY_NODE_NODE_LIST
);
listNode
->
pNodeList
=
group
;
genTbGroupDigest
((
SNode
*
)
listNode
,
digest
,
&
context
);
nodesFree
(
listNode
);
metaGetCachedTbGroup
(
metaHandle
,
pTableListInfo
->
idInfo
.
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
&
tableList
);
if
(
tableList
)
{
taosArrayDestroy
(
pTableListInfo
->
pTableList
);
pTableListInfo
->
pTableList
=
tableList
;
qDebug
(
"retrieve tb group list from cache, numOfTables:%d"
,
(
int32_t
)
taosArrayGetSize
(
pTableListInfo
->
pTableList
));
goto
end
;
}
}
pUidTagList
=
taosArrayInit
(
8
,
sizeof
(
STUidTagInfo
));
for
(
int32_t
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rows
;
++
i
)
{
STableKeyInfo
*
pkeyInfo
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
STableKeyInfo
*
pkeyInfo
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
STUidTagInfo
info
=
{.
uid
=
pkeyInfo
->
uid
};
STUidTagInfo
info
=
{.
uid
=
pkeyInfo
->
uid
};
...
@@ -594,6 +630,11 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
...
@@ -594,6 +630,11 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
info
->
groupId
=
calcGroupId
(
keyBuf
,
len
);
info
->
groupId
=
calcGroupId
(
keyBuf
,
len
);
}
}
if
(
tsTagFilterCache
)
{
tableList
=
taosArrayDup
(
pTableListInfo
->
pTableList
,
NULL
);
metaPutTbGroupToCache
(
metaHandle
,
pTableListInfo
->
idInfo
.
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
tableList
,
taosArrayGetSize
(
tableList
)
*
sizeof
(
STableKeyInfo
));
}
// int64_t st2 = taosGetTimestampUs();
// int64_t st2 = taosGetTimestampUs();
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
// qDebug("calculate tag block rows:%d, cost:%ld us", rows, st2-st1);
...
@@ -798,21 +839,6 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* pExistedUidLis
...
@@ -798,21 +839,6 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, SArray* pExistedUidLis
return
-
1
;
return
-
1
;
}
}
static
void
genTagFilterDigest
(
const
SNode
*
pTagCond
,
T_MD5_CTX
*
pContext
)
{
if
(
pTagCond
==
NULL
)
{
return
;
}
char
*
payload
=
NULL
;
int32_t
len
=
0
;
nodesNodeToMsg
(
pTagCond
,
&
payload
,
&
len
);
tMD5Init
(
pContext
);
tMD5Update
(
pContext
,
(
uint8_t
*
)
payload
,
(
uint32_t
)
len
);
tMD5Final
(
pContext
);
taosMemoryFree
(
payload
);
}
static
SSDataBlock
*
createTagValBlockForFilter
(
SArray
*
pColList
,
int32_t
numOfTables
,
SArray
*
pUidTagList
,
static
SSDataBlock
*
createTagValBlockForFilter
(
SArray
*
pColList
,
int32_t
numOfTables
,
SArray
*
pUidTagList
,
void
*
metaHandle
)
{
void
*
metaHandle
)
{
...
@@ -1027,7 +1053,7 @@ end:
...
@@ -1027,7 +1053,7 @@ end:
}
}
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
,
const
char
*
idstr
)
{
STableListInfo
*
pListInfo
,
uint8_t
*
digest
,
const
char
*
idstr
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
size_t
numOfTables
=
0
;
size_t
numOfTables
=
0
;
...
@@ -1057,6 +1083,8 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
...
@@ -1057,6 +1083,8 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
metaGetCachedTableUidList
(
metaHandle
,
pScanNode
->
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
pUidList
,
metaGetCachedTableUidList
(
metaHandle
,
pScanNode
->
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
pUidList
,
&
acquired
);
&
acquired
);
if
(
acquired
)
{
if
(
acquired
)
{
digest
[
0
]
=
1
;
memcpy
(
digest
+
1
,
context
.
digest
,
tListLen
(
context
.
digest
));
qDebug
(
"retrieve table uid list from cache, numOfTables:%d"
,
(
int32_t
)
taosArrayGetSize
(
pUidList
));
qDebug
(
"retrieve table uid list from cache, numOfTables:%d"
,
(
int32_t
)
taosArrayGetSize
(
pUidList
));
goto
_end
;
goto
_end
;
}
}
...
@@ -1100,6 +1128,8 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
...
@@ -1100,6 +1128,8 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
}
}
metaUidFilterCachePut
(
metaHandle
,
pScanNode
->
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
pPayload
,
size
,
1
);
metaUidFilterCachePut
(
metaHandle
,
pScanNode
->
suid
,
context
.
digest
,
tListLen
(
context
.
digest
),
pPayload
,
size
,
1
);
digest
[
0
]
=
1
;
memcpy
(
digest
+
1
,
context
.
digest
,
tListLen
(
context
.
digest
));
}
}
}
}
...
@@ -2003,8 +2033,8 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
...
@@ -2003,8 +2033,8 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
return
TDB_CODE_SUCCESS
;
return
TDB_CODE_SUCCESS
;
}
}
int32_t
buildGroupIdMapForAllTables
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
int32_t
buildGroupIdMapForAllTables
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
S
ScanPhysiNode
*
pScanNode
,
S
NodeList
*
group
,
bool
groupSort
)
{
bool
groupSort
,
uint8_t
*
digest
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
groupByTbname
=
groupbyTbname
(
group
);
bool
groupByTbname
=
groupbyTbname
(
group
);
...
@@ -2024,7 +2054,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
...
@@ -2024,7 +2054,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
pTableListInfo
->
numOfOuputGroups
=
1
;
pTableListInfo
->
numOfOuputGroups
=
1
;
}
}
}
else
{
}
else
{
code
=
getColInfoResultForGroupby
(
pHandle
->
meta
,
group
,
pTableListInfo
);
code
=
getColInfoResultForGroupby
(
pHandle
->
meta
,
group
,
pTableListInfo
,
digest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -2055,7 +2085,8 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
...
@@ -2055,7 +2085,8 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
return
TSDB_CODE_INVALID_PARA
;
return
TSDB_CODE_INVALID_PARA
;
}
}
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pHandle
->
vnode
,
pScanNode
,
pTagCond
,
pTagIndexCond
,
pTableListInfo
,
idStr
);
uint8_t
digest
[
17
]
=
{
0
};
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pHandle
->
vnode
,
pScanNode
,
pTagCond
,
pTagIndexCond
,
pTableListInfo
,
digest
,
idStr
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to getTableList, code: %s"
,
tstrerror
(
code
));
qError
(
"failed to getTableList, code: %s"
,
tstrerror
(
code
));
return
code
;
return
code
;
...
@@ -2073,7 +2104,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
...
@@ -2073,7 +2104,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
code
=
buildGroupIdMapForAllTables
(
pTableListInfo
,
pHandle
,
p
GroupTags
,
groupSor
t
);
code
=
buildGroupIdMapForAllTables
(
pTableListInfo
,
pHandle
,
p
ScanNode
,
pGroupTags
,
groupSort
,
diges
t
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
...
source/libs/executor/src/executor.c
浏览文件 @
fb7a06e0
...
@@ -1153,7 +1153,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
...
@@ -1153,7 +1153,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
if
(
pScanBaseInfo
->
dataReader
==
NULL
)
{
if
(
pScanBaseInfo
->
dataReader
==
NULL
)
{
int32_t
code
=
tsdbReaderOpen
(
pScanBaseInfo
->
readHandle
.
vnode
,
&
pScanBaseInfo
->
cond
,
&
keyInfo
,
1
,
int32_t
code
=
tsdbReaderOpen
(
pScanBaseInfo
->
readHandle
.
vnode
,
&
pScanBaseInfo
->
cond
,
&
keyInfo
,
1
,
pScanInfo
->
pResBlock
,
&
pScanBaseInfo
->
dataReader
,
id
,
false
);
pScanInfo
->
pResBlock
,
&
pScanBaseInfo
->
dataReader
,
id
,
false
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"prepare read tsdb snapshot failed, uid:%"
PRId64
", code:%s %s"
,
pOffset
->
uid
,
tstrerror
(
code
),
id
);
qError
(
"prepare read tsdb snapshot failed, uid:%"
PRId64
", code:%s %s"
,
pOffset
->
uid
,
tstrerror
(
code
),
id
);
terrno
=
code
;
terrno
=
code
;
...
@@ -1212,7 +1212,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
...
@@ -1212,7 +1212,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
int32_t
size
=
tableListGetSize
(
pTableListInfo
);
int32_t
size
=
tableListGetSize
(
pTableListInfo
);
tsdbReaderOpen
(
pInfo
->
vnode
,
&
pTaskInfo
->
streamInfo
.
tableCond
,
pList
,
size
,
NULL
,
&
pInfo
->
dataReader
,
NULL
,
tsdbReaderOpen
(
pInfo
->
vnode
,
&
pTaskInfo
->
streamInfo
.
tableCond
,
pList
,
size
,
NULL
,
&
pInfo
->
dataReader
,
NULL
,
false
);
false
,
NULL
);
cleanupQueryTableDataCond
(
&
pTaskInfo
->
streamInfo
.
tableCond
);
cleanupQueryTableDataCond
(
&
pTaskInfo
->
streamInfo
.
tableCond
);
strcpy
(
pTaskInfo
->
streamInfo
.
tbName
,
mtInfo
.
tbName
);
strcpy
(
pTaskInfo
->
streamInfo
.
tbName
,
mtInfo
.
tbName
);
...
...
source/libs/executor/src/executorInt.c
浏览文件 @
fb7a06e0
...
@@ -82,7 +82,7 @@ static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SC
...
@@ -82,7 +82,7 @@ static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SC
static
int32_t
doSetInputDataBlock
(
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
int32_t
order
,
int32_t
scanFlag
,
static
int32_t
doSetInputDataBlock
(
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
int32_t
order
,
int32_t
scanFlag
,
bool
createDummyCol
);
bool
createDummyCol
);
static
int32_t
doCopyToSDataBlock
(
SExecTaskInfo
*
pTaskInfo
,
SSDataBlock
*
pBlock
,
SExprSupp
*
pSup
,
SDiskbasedBuf
*
pBuf
,
static
int32_t
doCopyToSDataBlock
(
SExecTaskInfo
*
pTaskInfo
,
SSDataBlock
*
pBlock
,
SExprSupp
*
pSup
,
SDiskbasedBuf
*
pBuf
,
SGroupResInfo
*
pGroupResInfo
,
int32_t
threshold
);
SGroupResInfo
*
pGroupResInfo
,
int32_t
threshold
,
bool
ignoreGroup
);
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
*
currentPageId
,
int32_t
interBufSize
)
{
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int32_t
*
currentPageId
,
int32_t
interBufSize
)
{
SFilePage
*
pData
=
NULL
;
SFilePage
*
pData
=
NULL
;
...
@@ -776,7 +776,7 @@ int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPos
...
@@ -776,7 +776,7 @@ int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPos
}
}
int32_t
doCopyToSDataBlock
(
SExecTaskInfo
*
pTaskInfo
,
SSDataBlock
*
pBlock
,
SExprSupp
*
pSup
,
SDiskbasedBuf
*
pBuf
,
int32_t
doCopyToSDataBlock
(
SExecTaskInfo
*
pTaskInfo
,
SSDataBlock
*
pBlock
,
SExprSupp
*
pSup
,
SDiskbasedBuf
*
pBuf
,
SGroupResInfo
*
pGroupResInfo
,
int32_t
threshold
)
{
SGroupResInfo
*
pGroupResInfo
,
int32_t
threshold
,
bool
ignoreGroup
)
{
SExprInfo
*
pExprInfo
=
pSup
->
pExprInfo
;
SExprInfo
*
pExprInfo
=
pSup
->
pExprInfo
;
int32_t
numOfExprs
=
pSup
->
numOfExprs
;
int32_t
numOfExprs
=
pSup
->
numOfExprs
;
int32_t
*
rowEntryOffset
=
pSup
->
rowEntryInfoOffset
;
int32_t
*
rowEntryOffset
=
pSup
->
rowEntryInfoOffset
;
...
@@ -803,6 +803,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
...
@@ -803,6 +803,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
continue
;
continue
;
}
}
if
(
!
ignoreGroup
)
{
if
(
pBlock
->
info
.
id
.
groupId
==
0
)
{
if
(
pBlock
->
info
.
id
.
groupId
==
0
)
{
pBlock
->
info
.
id
.
groupId
=
pPos
->
groupId
;
pBlock
->
info
.
id
.
groupId
=
pPos
->
groupId
;
}
else
{
}
else
{
...
@@ -812,11 +813,13 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
...
@@ -812,11 +813,13 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS
break
;
break
;
}
}
}
}
}
if
(
pBlock
->
info
.
rows
+
pRow
->
numOfRows
>
pBlock
->
info
.
capacity
)
{
if
(
pBlock
->
info
.
rows
+
pRow
->
numOfRows
>
pBlock
->
info
.
capacity
)
{
blockDataEnsureCapacity
(
pBlock
,
pBlock
->
info
.
rows
+
pRow
->
numOfRows
);
uint32_t
newSize
=
pBlock
->
info
.
rows
+
pRow
->
numOfRows
+
(
numOfRows
-
i
)
>
1
?
1
:
0
;
qDebug
(
"datablock capacity not sufficient, expand to required:%"
PRId64
", current capacity:%d, %s"
,
blockDataEnsureCapacity
(
pBlock
,
newSize
);
(
pRow
->
numOfRows
+
pBlock
->
info
.
rows
),
pBlock
->
info
.
capacity
,
GET_TASKID
(
pTaskInfo
));
qDebug
(
"datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s"
,
newSize
,
pBlock
->
info
.
capacity
,
GET_TASKID
(
pTaskInfo
));
// todo set the pOperator->resultInfo size
// todo set the pOperator->resultInfo size
}
}
...
@@ -853,7 +856,7 @@ void doBuildStreamResBlock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGr
...
@@ -853,7 +856,7 @@ void doBuildStreamResBlock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGr
// clear the existed group id
// clear the existed group id
pBlock
->
info
.
id
.
groupId
=
0
;
pBlock
->
info
.
id
.
groupId
=
0
;
ASSERT
(
!
pbInfo
->
mergeResultBlock
);
ASSERT
(
!
pbInfo
->
mergeResultBlock
);
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
);
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
,
false
);
void
*
tbname
=
NULL
;
void
*
tbname
=
NULL
;
if
(
streamStateGetParName
(
pTaskInfo
->
streamInfo
.
pState
,
pBlock
->
info
.
id
.
groupId
,
&
tbname
)
<
0
)
{
if
(
streamStateGetParName
(
pTaskInfo
->
streamInfo
.
pState
,
pBlock
->
info
.
id
.
groupId
,
&
tbname
)
<
0
)
{
...
@@ -880,10 +883,10 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
...
@@ -880,10 +883,10 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
// clear the existed group id
// clear the existed group id
pBlock
->
info
.
id
.
groupId
=
0
;
pBlock
->
info
.
id
.
groupId
=
0
;
if
(
!
pbInfo
->
mergeResultBlock
)
{
if
(
!
pbInfo
->
mergeResultBlock
)
{
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
);
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
,
false
);
}
else
{
}
else
{
while
(
hasRemainResults
(
pGroupResInfo
))
{
while
(
hasRemainResults
(
pGroupResInfo
))
{
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
);
doCopyToSDataBlock
(
pTaskInfo
,
pBlock
,
&
pOperator
->
exprSupp
,
pBuf
,
pGroupResInfo
,
pOperator
->
resultInfo
.
threshold
,
true
);
if
(
pBlock
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
{
if
(
pBlock
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
{
break
;
break
;
}
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
fb7a06e0
...
@@ -194,8 +194,23 @@ static SResultRow* getTableGroupOutputBuf(SOperatorInfo* pOperator, uint64_t gro
...
@@ -194,8 +194,23 @@ static SResultRow* getTableGroupOutputBuf(SOperatorInfo* pOperator, uint64_t gro
return
(
SResultRow
*
)((
char
*
)(
*
pPage
)
+
p1
->
offset
);
return
(
SResultRow
*
)((
char
*
)(
*
pPage
)
+
p1
->
offset
);
}
}
static
int32_t
insertTableToScanIgnoreList
(
STableScanInfo
*
pTableScanInfo
,
uint64_t
uid
)
{
if
(
NULL
==
pTableScanInfo
->
pIgnoreTables
)
{
int32_t
tableNum
=
taosArrayGetSize
(
pTableScanInfo
->
base
.
pTableListInfo
->
pTableList
);
pTableScanInfo
->
pIgnoreTables
=
taosHashInit
(
tableNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
NULL
==
pTableScanInfo
->
pIgnoreTables
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
taosHashPut
(
pTableScanInfo
->
pIgnoreTables
,
&
uid
,
sizeof
(
uid
),
&
pTableScanInfo
->
scanTimes
,
sizeof
(
pTableScanInfo
->
scanTimes
));
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
doDynamicPruneDataBlock
(
SOperatorInfo
*
pOperator
,
SDataBlockInfo
*
pBlockInfo
,
uint32_t
*
status
)
{
static
int32_t
doDynamicPruneDataBlock
(
SOperatorInfo
*
pOperator
,
SDataBlockInfo
*
pBlockInfo
,
uint32_t
*
status
)
{
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pTableScanInfo
->
base
.
pdInfo
.
pExprSup
==
NULL
)
{
if
(
pTableScanInfo
->
base
.
pdInfo
.
pExprSup
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -228,9 +243,10 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
...
@@ -228,9 +243,10 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
if
(
notLoadBlock
)
{
if
(
notLoadBlock
)
{
*
status
=
FUNC_DATA_REQUIRED_NOT_LOAD
;
*
status
=
FUNC_DATA_REQUIRED_NOT_LOAD
;
code
=
insertTableToScanIgnoreList
(
pTableScanInfo
,
pBlockInfo
->
id
.
uid
);
}
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
}
static
bool
doFilterByBlockSMA
(
SFilterInfo
*
pFilterInfo
,
SColumnDataAgg
**
pColsAgg
,
int32_t
numOfCols
,
static
bool
doFilterByBlockSMA
(
SFilterInfo
*
pFilterInfo
,
SColumnDataAgg
**
pColsAgg
,
int32_t
numOfCols
,
...
@@ -382,7 +398,13 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
...
@@ -382,7 +398,13 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
GET_TASKID
(
pTaskInfo
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
);
GET_TASKID
(
pTaskInfo
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
);
pCost
->
skipBlocks
+=
1
;
pCost
->
skipBlocks
+=
1
;
tsdbReleaseDataBlock
(
pTableScanInfo
->
dataReader
);
tsdbReleaseDataBlock
(
pTableScanInfo
->
dataReader
);
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
if
(
taosHashGetSize
(
pTableScanInfo
->
pIgnoreTables
)
==
taosArrayGetSize
(
pTableScanInfo
->
base
.
pTableListInfo
->
pTableList
))
{
*
status
=
FUNC_DATA_REQUIRED_ALL_FILTEROUT
;
}
else
{
*
status
=
FUNC_DATA_REQUIRED_FILTEROUT
;
*
status
=
FUNC_DATA_REQUIRED_FILTEROUT
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -697,6 +719,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
...
@@ -697,6 +719,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
if
(
status
==
FUNC_DATA_REQUIRED_ALL_FILTEROUT
)
{
break
;
}
// current block is filter out according to filter condition, continue load the next block
// current block is filter out according to filter condition, continue load the next block
if
(
status
==
FUNC_DATA_REQUIRED_FILTEROUT
||
pBlock
->
info
.
rows
==
0
)
{
if
(
status
==
FUNC_DATA_REQUIRED_FILTEROUT
||
pBlock
->
info
.
rows
==
0
)
{
continue
;
continue
;
...
@@ -736,6 +762,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
...
@@ -736,6 +762,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
}
}
pTableScanInfo
->
scanTimes
+=
1
;
pTableScanInfo
->
scanTimes
+=
1
;
taosHashClear
(
pTableScanInfo
->
pIgnoreTables
);
if
(
pTableScanInfo
->
scanTimes
<
pTableScanInfo
->
scanInfo
.
numOfAsc
)
{
if
(
pTableScanInfo
->
scanTimes
<
pTableScanInfo
->
scanInfo
.
numOfAsc
)
{
setTaskStatus
(
pTaskInfo
,
TASK_NOT_COMPLETED
);
setTaskStatus
(
pTaskInfo
,
TASK_NOT_COMPLETED
);
...
@@ -763,6 +790,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
...
@@ -763,6 +790,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator) {
}
}
pTableScanInfo
->
scanTimes
+=
1
;
pTableScanInfo
->
scanTimes
+=
1
;
taosHashClear
(
pTableScanInfo
->
pIgnoreTables
);
if
(
pTableScanInfo
->
scanTimes
<
total
)
{
if
(
pTableScanInfo
->
scanTimes
<
total
)
{
setTaskStatus
(
pTaskInfo
,
TASK_NOT_COMPLETED
);
setTaskStatus
(
pTaskInfo
,
TASK_NOT_COMPLETED
);
...
@@ -827,7 +855,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
...
@@ -827,7 +855,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
ASSERT
(
pInfo
->
base
.
dataReader
==
NULL
);
ASSERT
(
pInfo
->
base
.
dataReader
==
NULL
);
int32_t
code
=
tsdbReaderOpen
(
pInfo
->
base
.
readHandle
.
vnode
,
&
pInfo
->
base
.
cond
,
pList
,
num
,
pInfo
->
pResBlock
,
int32_t
code
=
tsdbReaderOpen
(
pInfo
->
base
.
readHandle
.
vnode
,
&
pInfo
->
base
.
cond
,
pList
,
num
,
pInfo
->
pResBlock
,
(
STsdbReader
**
)
&
pInfo
->
base
.
dataReader
,
GET_TASKID
(
pTaskInfo
),
pInfo
->
countOnly
);
(
STsdbReader
**
)
&
pInfo
->
base
.
dataReader
,
GET_TASKID
(
pTaskInfo
),
pInfo
->
countOnly
,
&
pInfo
->
pIgnoreTables
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
...
@@ -896,6 +924,7 @@ static void destroyTableScanBase(STableScanBase* pBase) {
...
@@ -896,6 +924,7 @@ static void destroyTableScanBase(STableScanBase* pBase) {
static
void
destroyTableScanOperatorInfo
(
void
*
param
)
{
static
void
destroyTableScanOperatorInfo
(
void
*
param
)
{
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
blockDataDestroy
(
pTableScanInfo
->
pResBlock
);
blockDataDestroy
(
pTableScanInfo
->
pResBlock
);
taosHashCleanup
(
pTableScanInfo
->
pIgnoreTables
);
destroyTableScanBase
(
&
pTableScanInfo
->
base
);
destroyTableScanBase
(
&
pTableScanInfo
->
base
);
taosMemoryFreeClear
(
param
);
taosMemoryFreeClear
(
param
);
}
}
...
@@ -1061,7 +1090,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
...
@@ -1061,7 +1090,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
STsdbReader
*
pReader
=
NULL
;
STsdbReader
*
pReader
=
NULL
;
int32_t
code
=
tsdbReaderOpen
(
pTableScanInfo
->
base
.
readHandle
.
vnode
,
&
cond
,
&
tblInfo
,
1
,
pBlock
,
int32_t
code
=
tsdbReaderOpen
(
pTableScanInfo
->
base
.
readHandle
.
vnode
,
&
cond
,
&
tblInfo
,
1
,
pBlock
,
(
STsdbReader
**
)
&
pReader
,
GET_TASKID
(
pTaskInfo
),
false
);
(
STsdbReader
**
)
&
pReader
,
GET_TASKID
(
pTaskInfo
),
false
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
terrno
=
code
;
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
...
@@ -2660,7 +2689,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
...
@@ -2660,7 +2689,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
SReadHandle
*
pHandle
=
&
pInfo
->
base
.
readHandle
;
SReadHandle
*
pHandle
=
&
pInfo
->
base
.
readHandle
;
if
(
NULL
==
source
->
dataReader
||
!
source
->
multiReader
)
{
if
(
NULL
==
source
->
dataReader
||
!
source
->
multiReader
)
{
code
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
p
,
1
,
pBlock
,
&
source
->
dataReader
,
GET_TASKID
(
pTaskInfo
),
false
);
code
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
p
,
1
,
pBlock
,
&
source
->
dataReader
,
GET_TASKID
(
pTaskInfo
),
false
,
NULL
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
...
@@ -2708,6 +2737,10 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
...
@@ -2708,6 +2737,10 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
}
}
if
(
status
==
FUNC_DATA_REQUIRED_ALL_FILTEROUT
)
{
break
;
}
// current block is filter out according to filter condition, continue load the next block
// current block is filter out according to filter condition, continue load the next block
if
(
status
==
FUNC_DATA_REQUIRED_FILTEROUT
||
pBlock
->
info
.
rows
==
0
)
{
if
(
status
==
FUNC_DATA_REQUIRED_FILTEROUT
||
pBlock
->
info
.
rows
==
0
)
{
continue
;
continue
;
...
...
source/libs/executor/src/sysscanoperator.c
浏览文件 @
fb7a06e0
...
@@ -2268,7 +2268,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi
...
@@ -2268,7 +2268,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi
size_t
num
=
tableListGetSize
(
pTableListInfo
);
size_t
num
=
tableListGetSize
(
pTableListInfo
);
void
*
pList
=
tableListGetInfo
(
pTableListInfo
,
0
);
void
*
pList
=
tableListGetInfo
(
pTableListInfo
,
0
);
code
=
tsdbReaderOpen
(
readHandle
->
vnode
,
&
cond
,
pList
,
num
,
pInfo
->
pResBlock
,
&
pInfo
->
pHandle
,
pTaskInfo
->
id
.
str
,
false
);
code
=
tsdbReaderOpen
(
readHandle
->
vnode
,
&
cond
,
pList
,
num
,
pInfo
->
pResBlock
,
&
pInfo
->
pHandle
,
pTaskInfo
->
id
.
str
,
false
,
NULL
);
cleanupQueryTableDataCond
(
&
cond
);
cleanupQueryTableDataCond
(
&
cond
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
goto
_error
;
goto
_error
;
...
...
source/libs/function/src/udfd.c
浏览文件 @
fb7a06e0
...
@@ -54,16 +54,15 @@ int32_t udfdCPluginOpen(SScriptUdfEnvItem *items, int numItems) { return 0; }
...
@@ -54,16 +54,15 @@ int32_t udfdCPluginOpen(SScriptUdfEnvItem *items, int numItems) { return 0; }
int32_t
udfdCPluginClose
()
{
return
0
;
}
int32_t
udfdCPluginClose
()
{
return
0
;
}
const
char
*
udfdCPluginUdfInitLoadInitDestoryFuncs
(
SUdfCPluginCtx
*
udfCtx
,
const
char
*
udfName
)
{
const
char
*
udfdCPluginUdfInitLoadInitDestoryFuncs
(
SUdfCPluginCtx
*
udfCtx
,
const
char
*
udfName
)
{
char
initFuncName
[
TSDB_FUNC_NAME_LEN
+
5
]
=
{
0
};
char
initFuncName
[
TSDB_FUNC_NAME_LEN
+
6
]
=
{
0
};
char
*
initSuffix
=
"_init"
;
char
*
initSuffix
=
"_init"
;
strcpy
(
initFuncName
,
udfName
);
snprintf
(
initFuncName
,
sizeof
(
initFuncName
),
"%s%s"
,
udfName
,
initSuffix
);
strncat
(
initFuncName
,
initSuffix
,
strlen
(
initSuffix
));
uv_dlsym
(
&
udfCtx
->
lib
,
initFuncName
,
(
void
**
)(
&
udfCtx
->
initFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
initFuncName
,
(
void
**
)(
&
udfCtx
->
initFunc
));
char
destroyFuncName
[
TSDB_FUNC_NAME_LEN
+
5
]
=
{
0
};
char
destroyFuncName
[
TSDB_FUNC_NAME_LEN
+
9
]
=
{
0
};
char
*
destroySuffix
=
"_destroy"
;
char
*
destroySuffix
=
"_destroy"
;
strcpy
(
destroyFuncName
,
udfName
);
strcpy
(
destroyFuncName
,
udfName
);
s
trncat
(
destroyFuncName
,
destroySuffix
,
strlen
(
destroySuffix
)
);
s
nprintf
(
destroyFuncName
,
sizeof
(
destroyFuncName
),
"%s%s"
,
udfName
,
destroySuffix
);
uv_dlsym
(
&
udfCtx
->
lib
,
destroyFuncName
,
(
void
**
)(
&
udfCtx
->
destroyFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
destroyFuncName
,
(
void
**
)(
&
udfCtx
->
destroyFunc
));
return
udfName
;
return
udfName
;
}
}
...
@@ -73,22 +72,19 @@ void udfdCPluginUdfInitLoadAggFuncs(SUdfCPluginCtx *udfCtx, const char *udfName)
...
@@ -73,22 +72,19 @@ void udfdCPluginUdfInitLoadAggFuncs(SUdfCPluginCtx *udfCtx, const char *udfName)
strcpy
(
processFuncName
,
udfName
);
strcpy
(
processFuncName
,
udfName
);
uv_dlsym
(
&
udfCtx
->
lib
,
processFuncName
,
(
void
**
)(
&
udfCtx
->
aggProcFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
processFuncName
,
(
void
**
)(
&
udfCtx
->
aggProcFunc
));
char
startFuncName
[
TSDB_FUNC_NAME_LEN
+
6
]
=
{
0
};
char
startFuncName
[
TSDB_FUNC_NAME_LEN
+
7
]
=
{
0
};
char
*
startSuffix
=
"_start"
;
char
*
startSuffix
=
"_start"
;
strncpy
(
startFuncName
,
processFuncName
,
sizeof
(
startFuncName
));
snprintf
(
startFuncName
,
sizeof
(
startFuncName
),
"%s%s"
,
processFuncName
,
startSuffix
);
strncat
(
startFuncName
,
startSuffix
,
strlen
(
startSuffix
));
uv_dlsym
(
&
udfCtx
->
lib
,
startFuncName
,
(
void
**
)(
&
udfCtx
->
aggStartFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
startFuncName
,
(
void
**
)(
&
udfCtx
->
aggStartFunc
));
char
finishFuncName
[
TSDB_FUNC_NAME_LEN
+
7
]
=
{
0
};
char
finishFuncName
[
TSDB_FUNC_NAME_LEN
+
8
]
=
{
0
};
char
*
finishSuffix
=
"_finish"
;
char
*
finishSuffix
=
"_finish"
;
strncpy
(
finishFuncName
,
processFuncName
,
sizeof
(
finishFuncName
));
snprintf
(
finishFuncName
,
sizeof
(
finishFuncName
),
"%s%s"
,
processFuncName
,
finishSuffix
);
strncat
(
finishFuncName
,
finishSuffix
,
strlen
(
finishSuffix
));
uv_dlsym
(
&
udfCtx
->
lib
,
finishFuncName
,
(
void
**
)(
&
udfCtx
->
aggFinishFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
finishFuncName
,
(
void
**
)(
&
udfCtx
->
aggFinishFunc
));
char
mergeFuncName
[
TSDB_FUNC_NAME_LEN
+
6
]
=
{
0
};
char
mergeFuncName
[
TSDB_FUNC_NAME_LEN
+
7
]
=
{
0
};
char
*
mergeSuffix
=
"_merge"
;
char
*
mergeSuffix
=
"_merge"
;
strncpy
(
mergeFuncName
,
processFuncName
,
sizeof
(
mergeFuncName
));
snprintf
(
mergeFuncName
,
sizeof
(
mergeFuncName
),
"%s%s"
,
processFuncName
,
mergeSuffix
);
strncat
(
mergeFuncName
,
mergeSuffix
,
strlen
(
mergeSuffix
));
uv_dlsym
(
&
udfCtx
->
lib
,
mergeFuncName
,
(
void
**
)(
&
udfCtx
->
aggMergeFunc
));
uv_dlsym
(
&
udfCtx
->
lib
,
mergeFuncName
,
(
void
**
)(
&
udfCtx
->
aggMergeFunc
));
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
fb7a06e0
...
@@ -87,7 +87,7 @@ static void* nodesCalloc(int32_t num, int32_t size) {
...
@@ -87,7 +87,7 @@ static void* nodesCalloc(int32_t num, int32_t size) {
return
(
char
*
)
p
+
1
;
return
(
char
*
)
p
+
1
;
}
}
static
void
nodesFree
(
void
*
p
)
{
void
nodesFree
(
void
*
p
)
{
char
*
ptr
=
(
char
*
)
p
-
1
;
char
*
ptr
=
(
char
*
)
p
-
1
;
if
(
0
==
*
ptr
)
{
if
(
0
==
*
ptr
)
{
taosMemoryFree
(
ptr
);
taosMemoryFree
(
ptr
);
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
fb7a06e0
...
@@ -548,3 +548,11 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
...
@@ -548,3 +548,11 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
freeDbCfgInfo
(
SDbCfgInfo
*
pInfo
)
{
if
(
pInfo
)
{
taosArrayDestroy
(
pInfo
->
pRetensions
);
}
taosMemoryFree
(
pInfo
);
}
source/libs/qworker/inc/qwInt.h
浏览文件 @
fb7a06e0
...
@@ -120,7 +120,8 @@ typedef struct SQWTaskCtx {
...
@@ -120,7 +120,8 @@ typedef struct SQWTaskCtx {
int8_t
explain
;
int8_t
explain
;
int8_t
needFetch
;
int8_t
needFetch
;
int8_t
localExec
;
int8_t
localExec
;
int32_t
msgType
;
int32_t
queryMsgType
;
int32_t
fetchMsgType
;
int32_t
level
;
int32_t
level
;
uint64_t
sId
;
uint64_t
sId
;
...
...
source/libs/qworker/src/qwDbg.c
浏览文件 @
fb7a06e0
...
@@ -126,10 +126,10 @@ void qwDbgDumpTasksInfo(SQWorker *mgmt) {
...
@@ -126,10 +126,10 @@ void qwDbgDumpTasksInfo(SQWorker *mgmt) {
void
*
key
=
taosHashGetKey
(
pIter
,
NULL
);
void
*
key
=
taosHashGetKey
(
pIter
,
NULL
);
QW_GET_QTID
(
key
,
qId
,
tId
,
eId
);
QW_GET_QTID
(
key
,
qId
,
tId
,
eId
);
QW_TASK_DLOG
(
"%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d,
m
sgType:%d, "
QW_TASK_DLOG
(
"%p lock:%x, phase:%d, type:%d, explain:%d, needFetch:%d, localExec:%d,
queryM
sgType:%d, "
"sId:%"
PRId64
", level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, "
"sId:%"
PRId64
", level:%d, queryGotData:%d, queryRsped:%d, queryEnd:%d, queryContinue:%d, queryInQueue:%d, "
"rspCode:%x, affectedRows:%"
PRId64
", taskHandle:%p, sinkHandle:%p, tbFName:%s, sver:%d, tver:%d, events:%d,%d,%d,%d,%d"
,
"rspCode:%x, affectedRows:%"
PRId64
", taskHandle:%p, sinkHandle:%p, tbFName:%s, sver:%d, tver:%d, events:%d,%d,%d,%d,%d"
,
ctx
,
ctx
->
lock
,
ctx
->
phase
,
ctx
->
taskType
,
ctx
->
explain
,
ctx
->
needFetch
,
ctx
->
localExec
,
ctx
->
m
sgType
,
ctx
,
ctx
->
lock
,
ctx
->
phase
,
ctx
->
taskType
,
ctx
->
explain
,
ctx
->
needFetch
,
ctx
->
localExec
,
ctx
->
queryM
sgType
,
ctx
->
sId
,
ctx
->
level
,
ctx
->
queryGotData
,
ctx
->
queryRsped
,
ctx
->
queryEnd
,
ctx
->
queryContinue
,
ctx
->
sId
,
ctx
->
level
,
ctx
->
queryGotData
,
ctx
->
queryRsped
,
ctx
->
queryEnd
,
ctx
->
queryContinue
,
ctx
->
queryInQueue
,
ctx
->
rspCode
,
ctx
->
affectedRows
,
ctx
->
taskHandle
,
ctx
->
sinkHandle
,
ctx
->
tbInfo
.
tbFName
,
ctx
->
queryInQueue
,
ctx
->
rspCode
,
ctx
->
affectedRows
,
ctx
->
taskHandle
,
ctx
->
sinkHandle
,
ctx
->
tbInfo
.
tbFName
,
ctx
->
tbInfo
.
sversion
,
ctx
->
tbInfo
.
tversion
,
ctx
->
events
[
QW_EVENT_CANCEL
],
ctx
->
events
[
QW_EVENT_READY
],
ctx
->
tbInfo
.
sversion
,
ctx
->
tbInfo
.
tversion
,
ctx
->
events
[
QW_EVENT_CANCEL
],
ctx
->
events
[
QW_EVENT_READY
],
...
@@ -259,9 +259,9 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) {
...
@@ -259,9 +259,9 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) {
static
int32_t
ignoreTime
=
0
;
static
int32_t
ignoreTime
=
0
;
if
(
++
ignoreTime
>
10
&&
0
==
taosRand
()
%
9
)
{
if
(
++
ignoreTime
>
10
&&
0
==
taosRand
()
%
9
)
{
if
(
ctx
->
m
sgType
==
TDMT_SCH_FETCH
)
{
if
(
ctx
->
fetchM
sgType
==
TDMT_SCH_FETCH
)
{
qwBuildAndSendErrorRsp
(
TDMT_SCH_LINK_BROKEN
,
&
ctx
->
ctrlConnInfo
,
TSDB_CODE_RPC_BROKEN_LINK
);
qwBuildAndSendErrorRsp
(
TDMT_SCH_LINK_BROKEN
,
&
ctx
->
ctrlConnInfo
,
TSDB_CODE_RPC_BROKEN_LINK
);
qwBuildAndSendErrorRsp
(
ctx
->
m
sgType
+
1
,
&
ctx
->
dataConnInfo
,
TSDB_CODE_QRY_TASK_CTX_NOT_EXIST
);
qwBuildAndSendErrorRsp
(
ctx
->
fetchM
sgType
+
1
,
&
ctx
->
dataConnInfo
,
TSDB_CODE_QRY_TASK_CTX_NOT_EXIST
);
*
rsped
=
true
;
*
rsped
=
true
;
taosSsleep
(
3
);
taosSsleep
(
3
);
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
fb7a06e0
...
@@ -254,6 +254,7 @@ bool qwTaskNotInExec(SQWTaskCtx *ctx) {
...
@@ -254,6 +254,7 @@ bool qwTaskNotInExec(SQWTaskCtx *ctx) {
return
false
;
return
false
;
}
}
int32_t
qwGenerateSchHbRsp
(
SQWorker
*
mgmt
,
SQWSchStatus
*
sch
,
SQWHbInfo
*
hbInfo
)
{
int32_t
qwGenerateSchHbRsp
(
SQWorker
*
mgmt
,
SQWSchStatus
*
sch
,
SQWHbInfo
*
hbInfo
)
{
int32_t
taskNum
=
0
;
int32_t
taskNum
=
0
;
...
@@ -436,6 +437,40 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
...
@@ -436,6 +437,40 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qwQuickRspFetchReq
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
,
SQWMsg
*
qwMsg
,
int32_t
code
)
{
if
(
QUERY_RSP_POLICY_QUICK
==
tsQueryRspPolicy
&&
ctx
!=
NULL
)
{
if
(
QW_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
void
*
rsp
=
NULL
;
int32_t
dataLen
=
0
;
SOutputData
sOutput
=
{
0
};
if
(
qwGetQueryResFromSink
(
QW_FPARAMS
(),
ctx
,
&
dataLen
,
&
rsp
,
&
sOutput
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
rsp
)
{
bool
qComplete
=
(
DS_BUF_EMPTY
==
sOutput
.
bufStatus
&&
sOutput
.
queryEnd
);
qwBuildFetchRsp
(
rsp
,
&
sOutput
,
dataLen
,
qComplete
);
if
(
qComplete
)
{
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryEnd
,
true
);
}
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_FETCH
);
qwBuildAndSendFetchRsp
(
ctx
->
fetchMsgType
+
1
,
&
qwMsg
->
connInfo
,
rsp
,
dataLen
,
code
);
rsp
=
NULL
;
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
tstrerror
(
code
),
dataLen
);
}
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
qwHandlePrePhaseEvents
(
QW_FPARAMS_DEF
,
int8_t
phase
,
SQWPhaseInput
*
input
,
SQWPhaseOutput
*
output
)
{
int32_t
qwHandlePrePhaseEvents
(
QW_FPARAMS_DEF
,
int8_t
phase
,
SQWPhaseInput
*
input
,
SQWPhaseOutput
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SQWTaskCtx
*
ctx
=
NULL
;
SQWTaskCtx
*
ctx
=
NULL
;
...
@@ -584,7 +619,7 @@ _return:
...
@@ -584,7 +619,7 @@ _return:
if
(
QW_PHASE_POST_QUERY
==
phase
&&
ctx
&&
!
ctx
->
queryRsped
)
{
if
(
QW_PHASE_POST_QUERY
==
phase
&&
ctx
&&
!
ctx
->
queryRsped
)
{
bool
rsped
=
false
;
bool
rsped
=
false
;
SQWMsg
qwMsg
=
{.
msgType
=
ctx
->
m
sgType
,
.
connInfo
=
ctx
->
ctrlConnInfo
};
SQWMsg
qwMsg
=
{.
msgType
=
ctx
->
queryM
sgType
,
.
connInfo
=
ctx
->
ctrlConnInfo
};
qwDbgSimulateRedirect
(
&
qwMsg
,
ctx
,
&
rsped
);
qwDbgSimulateRedirect
(
&
qwMsg
,
ctx
,
&
rsped
);
qwDbgSimulateDead
(
QW_FPARAMS
(),
ctx
,
&
rsped
);
qwDbgSimulateDead
(
QW_FPARAMS
(),
ctx
,
&
rsped
);
if
(
!
rsped
)
{
if
(
!
rsped
)
{
...
@@ -634,6 +669,8 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
...
@@ -634,6 +669,8 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
QW_ERR_JRET
(
qwAddTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_INIT
));
QW_ERR_JRET
(
qwAddTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_INIT
));
qwSendQueryRsp
(
QW_FPARAMS
(),
qwMsg
->
msgType
+
1
,
ctx
,
code
,
true
);
_return:
_return:
if
(
ctx
)
{
if
(
ctx
)
{
...
@@ -660,7 +697,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
...
@@ -660,7 +697,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
ctx
->
taskType
=
qwMsg
->
msgInfo
.
taskType
;
ctx
->
taskType
=
qwMsg
->
msgInfo
.
taskType
;
ctx
->
explain
=
qwMsg
->
msgInfo
.
explain
;
ctx
->
explain
=
qwMsg
->
msgInfo
.
explain
;
ctx
->
needFetch
=
qwMsg
->
msgInfo
.
needFetch
;
ctx
->
needFetch
=
qwMsg
->
msgInfo
.
needFetch
;
ctx
->
m
sgType
=
qwMsg
->
msgType
;
ctx
->
queryM
sgType
=
qwMsg
->
msgType
;
ctx
->
localExec
=
false
;
ctx
->
localExec
=
false
;
// QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
// QW_TASK_DLOGL("subplan json string, len:%d, %s", qwMsg->msgLen, qwMsg->msg);
...
@@ -684,7 +721,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
...
@@ -684,7 +721,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
QW_ERR_JRET
(
TSDB_CODE_APP_ERROR
);
QW_ERR_JRET
(
TSDB_CODE_APP_ERROR
);
}
}
qwSendQueryRsp
(
QW_FPARAMS
(),
qwMsg
->
msgType
+
1
,
ctx
,
code
,
true
);
//
qwSendQueryRsp(QW_FPARAMS(), qwMsg->msgType + 1, ctx, code, true);
ctx
->
level
=
plan
->
level
;
ctx
->
level
=
plan
->
level
;
atomic_store_ptr
(
&
ctx
->
taskHandle
,
pTaskInfo
);
atomic_store_ptr
(
&
ctx
->
taskHandle
,
pTaskInfo
);
...
@@ -701,32 +738,7 @@ _return:
...
@@ -701,32 +738,7 @@ _return:
input
.
msgType
=
qwMsg
->
msgType
;
input
.
msgType
=
qwMsg
->
msgType
;
code
=
qwHandlePostPhaseEvents
(
QW_FPARAMS
(),
QW_PHASE_POST_QUERY
,
&
input
,
NULL
);
code
=
qwHandlePostPhaseEvents
(
QW_FPARAMS
(),
QW_PHASE_POST_QUERY
,
&
input
,
NULL
);
if
(
QUERY_RSP_POLICY_QUICK
==
tsQueryRspPolicy
&&
ctx
!=
NULL
&&
QW_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
qwQuickRspFetchReq
(
QW_FPARAMS
(),
ctx
,
qwMsg
,
code
);
void
*
rsp
=
NULL
;
int32_t
dataLen
=
0
;
SOutputData
sOutput
=
{
0
};
if
(
qwGetQueryResFromSink
(
QW_FPARAMS
(),
ctx
,
&
dataLen
,
&
rsp
,
&
sOutput
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
rsp
)
{
bool
qComplete
=
(
DS_BUF_EMPTY
==
sOutput
.
bufStatus
&&
sOutput
.
queryEnd
);
qwBuildFetchRsp
(
rsp
,
&
sOutput
,
dataLen
,
qComplete
);
if
(
qComplete
)
{
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryEnd
,
true
);
}
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_FETCH
);
qwBuildAndSendFetchRsp
(
ctx
->
msgType
+
1
,
&
qwMsg
->
connInfo
,
rsp
,
dataLen
,
code
);
rsp
=
NULL
;
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
tstrerror
(
code
),
dataLen
);
}
}
QW_RET
(
TSDB_CODE_SUCCESS
);
QW_RET
(
TSDB_CODE_SUCCESS
);
}
}
...
@@ -750,7 +762,9 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
...
@@ -750,7 +762,9 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryInQueue
,
0
);
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryInQueue
,
0
);
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryContinue
,
0
);
atomic_store_8
((
int8_t
*
)
&
ctx
->
queryContinue
,
0
);
if
(
!
queryStop
)
{
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
ctx
,
&
queryStop
));
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
ctx
,
&
queryStop
));
}
if
(
QW_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
if
(
QW_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
SOutputData
sOutput
=
{
0
};
SOutputData
sOutput
=
{
0
};
...
@@ -774,7 +788,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
...
@@ -774,7 +788,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_FETCH
);
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_FETCH
);
qwBuildAndSendFetchRsp
(
ctx
->
m
sgType
+
1
,
&
qwMsg
->
connInfo
,
rsp
,
dataLen
,
code
);
qwBuildAndSendFetchRsp
(
ctx
->
fetchM
sgType
+
1
,
&
qwMsg
->
connInfo
,
rsp
,
dataLen
,
code
);
rsp
=
NULL
;
rsp
=
NULL
;
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
...
@@ -796,7 +810,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
...
@@ -796,7 +810,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
rsp
=
NULL
;
rsp
=
NULL
;
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
qwMsg
->
connInfo
=
ctx
->
dataConnInfo
;
qwBuildAndSendFetchRsp
(
ctx
->
m
sgType
+
1
,
&
qwMsg
->
connInfo
,
NULL
,
0
,
code
);
qwBuildAndSendFetchRsp
(
ctx
->
fetchM
sgType
+
1
,
&
qwMsg
->
connInfo
,
NULL
,
0
,
code
);
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
tstrerror
(
code
),
QW_TASK_DLOG
(
"fetch rsp send, handle:%p, code:%x - %s, dataLen:%d"
,
qwMsg
->
connInfo
.
handle
,
code
,
tstrerror
(
code
),
0
);
0
);
}
}
...
@@ -830,7 +844,7 @@ int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
...
@@ -830,7 +844,7 @@ int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
ctx
->
m
sgType
=
qwMsg
->
msgType
;
ctx
->
fetchM
sgType
=
qwMsg
->
msgType
;
ctx
->
dataConnInfo
=
qwMsg
->
connInfo
;
ctx
->
dataConnInfo
=
qwMsg
->
connInfo
;
SOutputData
sOutput
=
{
0
};
SOutputData
sOutput
=
{
0
};
...
@@ -896,6 +910,8 @@ _return:
...
@@ -896,6 +910,8 @@ _return:
qwFreeFetchRsp
(
rsp
);
qwFreeFetchRsp
(
rsp
);
rsp
=
NULL
;
rsp
=
NULL
;
}
}
}
else
{
//qwQuickRspFetchReq(QW_FPARAMS(), ctx, qwMsg, code);
}
}
QW_RET
(
TSDB_CODE_SUCCESS
);
QW_RET
(
TSDB_CODE_SUCCESS
);
...
@@ -1307,7 +1323,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64
...
@@ -1307,7 +1323,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64
ctx
->
taskType
=
qwMsg
->
msgInfo
.
taskType
;
ctx
->
taskType
=
qwMsg
->
msgInfo
.
taskType
;
ctx
->
explain
=
qwMsg
->
msgInfo
.
explain
;
ctx
->
explain
=
qwMsg
->
msgInfo
.
explain
;
ctx
->
needFetch
=
qwMsg
->
msgInfo
.
needFetch
;
ctx
->
needFetch
=
qwMsg
->
msgInfo
.
needFetch
;
ctx
->
m
sgType
=
qwMsg
->
msgType
;
ctx
->
queryM
sgType
=
qwMsg
->
msgType
;
ctx
->
localExec
=
true
;
ctx
->
localExec
=
true
;
ctx
->
explainRes
=
explainRes
;
ctx
->
explainRes
=
explainRes
;
...
@@ -1362,7 +1378,7 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64
...
@@ -1362,7 +1378,7 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
ctx
->
m
sgType
=
TDMT_SCH_MERGE_FETCH
;
ctx
->
fetchM
sgType
=
TDMT_SCH_MERGE_FETCH
;
ctx
->
explainRes
=
explainRes
;
ctx
->
explainRes
=
explainRes
;
SOutputData
sOutput
=
{
0
};
SOutputData
sOutput
=
{
0
};
...
...
source/libs/transport/src/transCli.c
浏览文件 @
fb7a06e0
...
@@ -966,7 +966,7 @@ static void cliSendCb(uv_write_t* req, int status) {
...
@@ -966,7 +966,7 @@ static void cliSendCb(uv_write_t* req, int status) {
}
}
if
(
status
==
0
)
{
if
(
status
==
0
)
{
t
Trace
(
"%s conn %p data already was written out"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
t
Debug
(
"%s conn %p data already was written out"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
}
else
{
}
else
{
if
(
!
uv_is_closing
((
uv_handle_t
*
)
&
pConn
->
stream
))
{
if
(
!
uv_is_closing
((
uv_handle_t
*
)
&
pConn
->
stream
))
{
tError
(
"%s conn %p failed to write:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_err_name
(
status
));
tError
(
"%s conn %p failed to write:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_err_name
(
status
));
...
...
source/libs/transport/src/transSvr.c
浏览文件 @
fb7a06e0
...
@@ -236,7 +236,7 @@ static bool uvHandleReq(SSvrConn* pConn) {
...
@@ -236,7 +236,7 @@ static bool uvHandleReq(SSvrConn* pConn) {
if
(
pConn
->
status
==
ConnNormal
&&
pHead
->
noResp
==
0
)
{
if
(
pConn
->
status
==
ConnNormal
&&
pHead
->
noResp
==
0
)
{
transRefSrvHandle
(
pConn
);
transRefSrvHandle
(
pConn
);
if
(
cost
>=
EXCEPTION_LIMIT_US
)
{
if
(
cost
>=
EXCEPTION_LIMIT_US
)
{
tG
Warn
(
"%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus, recv exception"
,
transLabel
(
pTransInst
),
tG
Debug
(
"%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus, recv exception"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
pConn
->
dst
,
pConn
->
src
,
msgLen
,
(
int
)
cost
);
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
pConn
->
dst
,
pConn
->
src
,
msgLen
,
(
int
)
cost
);
}
else
{
}
else
{
tGDebug
(
"%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus"
,
transLabel
(
pTransInst
),
pConn
,
tGDebug
(
"%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus"
,
transLabel
(
pTransInst
),
pConn
,
...
@@ -244,7 +244,7 @@ static bool uvHandleReq(SSvrConn* pConn) {
...
@@ -244,7 +244,7 @@ static bool uvHandleReq(SSvrConn* pConn) {
}
}
}
else
{
}
else
{
if
(
cost
>=
EXCEPTION_LIMIT_US
)
{
if
(
cost
>=
EXCEPTION_LIMIT_US
)
{
tG
Warn
(
"%s conn %p %s received from %s, local info:%s, len:%d, noResp:%d, code:%d, cost:%dus, recv exception"
,
tG
Debug
(
"%s conn %p %s received from %s, local info:%s, len:%d, noResp:%d, code:%d, cost:%dus, recv exception"
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
pConn
->
dst
,
pConn
->
src
,
msgLen
,
pHead
->
noResp
,
transLabel
(
pTransInst
),
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
pConn
->
dst
,
pConn
->
src
,
msgLen
,
pHead
->
noResp
,
transMsg
.
code
,
(
int
)(
cost
));
transMsg
.
code
,
(
int
)(
cost
));
}
else
{
}
else
{
...
...
source/util/src/tarray.c
浏览文件 @
fb7a06e0
...
@@ -316,6 +316,10 @@ SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize) {
...
@@ -316,6 +316,10 @@ SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize) {
}
}
SArray
*
taosArrayDup
(
const
SArray
*
pSrc
,
__array_item_dup_fn_t
fn
)
{
SArray
*
taosArrayDup
(
const
SArray
*
pSrc
,
__array_item_dup_fn_t
fn
)
{
if
(
NULL
==
pSrc
)
{
return
NULL
;
}
if
(
pSrc
->
size
==
0
)
{
// empty array list
if
(
pSrc
->
size
==
0
)
{
// empty array list
return
taosArrayInit
(
8
,
pSrc
->
elemSize
);
return
taosArrayInit
(
8
,
pSrc
->
elemSize
);
}
}
...
...
source/util/src/tcompression.c
浏览文件 @
fb7a06e0
...
@@ -912,11 +912,11 @@ int32_t tsCompressDoubleImp(const char *const input, const int32_t nelements, ch
...
@@ -912,11 +912,11 @@ int32_t tsCompressDoubleImp(const char *const input, const int32_t nelements, ch
return
opos
;
return
opos
;
}
}
uint64_t
decodeDoubleValue
(
const
char
*
const
input
,
int32_t
*
const
ipos
,
uint8_t
flag
)
{
FORCE_INLINE
uint64_t
decodeDoubleValue
(
const
char
*
const
input
,
int32_t
*
const
ipos
,
uint8_t
flag
)
{
uint64_t
diff
=
0ul
;
uint64_t
diff
=
0ul
;
int32_t
nbytes
=
(
flag
&
INT8MASK
(
3
)
)
+
1
;
int32_t
nbytes
=
(
flag
&
0x7
)
+
1
;
for
(
int32_t
i
=
0
;
i
<
nbytes
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
nbytes
;
i
++
)
{
diff
=
diff
|
((
INT64MASK
(
8
)
&
input
[(
*
ipos
)
++
])
<<
BITS_PER_BYTE
*
i
);
diff
|=
(((
uint64_t
)
0xff
&
input
[(
*
ipos
)
++
])
<<
BITS_PER_BYTE
*
i
);
}
}
int32_t
shift_width
=
(
LONG_BYTES
*
BITS_PER_BYTE
-
nbytes
*
BITS_PER_BYTE
)
*
(
flag
>>
3
);
int32_t
shift_width
=
(
LONG_BYTES
*
BITS_PER_BYTE
-
nbytes
*
BITS_PER_BYTE
)
*
(
flag
>>
3
);
diff
<<=
shift_width
;
diff
<<=
shift_width
;
...
@@ -936,25 +936,22 @@ int32_t tsDecompressDoubleImp(const char *const input, const int32_t nelements,
...
@@ -936,25 +936,22 @@ int32_t tsDecompressDoubleImp(const char *const input, const int32_t nelements,
uint8_t
flags
=
0
;
uint8_t
flags
=
0
;
int32_t
ipos
=
1
;
int32_t
ipos
=
1
;
int32_t
opos
=
0
;
int32_t
opos
=
0
;
uint64_t
prev_value
=
0
;
uint64_t
diff
=
0
;
union
{
uint64_t
bits
;
double
real
;
}
curr
;
curr
.
bits
=
0
;
for
(
int32_t
i
=
0
;
i
<
nelements
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
nelements
;
i
++
)
{
if
((
i
&
0x01
)
==
0
)
{
if
((
i
&
0x01
)
==
0
)
{
flags
=
input
[
ipos
++
];
flags
=
input
[
ipos
++
];
}
}
uint8_t
flag
=
flags
&
INT8MASK
(
4
);
diff
=
decodeDoubleValue
(
input
,
&
ipos
,
flags
&
0x0f
);
flags
>>=
4
;
flags
>>=
4
;
curr
.
bits
^=
diff
;
uint64_t
diff
=
decodeDoubleValue
(
input
,
&
ipos
,
flag
);
union
{
uint64_t
bits
;
double
real
;
}
curr
;
uint64_t
predicted
=
prev_value
;
curr
.
bits
=
predicted
^
diff
;
prev_value
=
curr
.
bits
;
ostream
[
opos
++
]
=
curr
.
real
;
ostream
[
opos
++
]
=
curr
.
real
;
}
}
...
...
source/util/src/tlog.c
浏览文件 @
fb7a06e0
...
@@ -596,7 +596,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg
...
@@ -596,7 +596,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg
int32_t
end
=
0
;
int32_t
end
=
0
;
int32_t
remainSize
=
0
;
int32_t
remainSize
=
0
;
static
int64_t
lostLine
=
0
;
static
int64_t
lostLine
=
0
;
char
tmpBuf
[
128
]
=
{
0
}
;
char
tmpBuf
[
128
];
int32_t
tmpBufLen
=
0
;
int32_t
tmpBufLen
=
0
;
if
(
pLogBuf
==
NULL
||
pLogBuf
->
stop
)
return
-
1
;
if
(
pLogBuf
==
NULL
||
pLogBuf
->
stop
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录