Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b13c31c9
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b13c31c9
编写于
6月 14, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into enh/avg_stddev_split
上级
a17c6e3c
157e708f
变更
77
隐藏空白更改
内联
并排
Showing
77 changed file
with
2421 addition
and
976 deletion
+2421
-976
docs/en/12-taos-sql/08-delete-data.mdx
docs/en/12-taos-sql/08-delete-data.mdx
+0
-0
docs/en/12-taos-sql/10-function.md
docs/en/12-taos-sql/10-function.md
+0
-0
docs/en/12-taos-sql/12-interval.md
docs/en/12-taos-sql/12-interval.md
+0
-0
docs/en/12-taos-sql/14-limit.md
docs/en/12-taos-sql/14-limit.md
+0
-0
docs/en/12-taos-sql/16-json.md
docs/en/12-taos-sql/16-json.md
+0
-0
docs/en/12-taos-sql/18-escape.md
docs/en/12-taos-sql/18-escape.md
+0
-0
docs/en/12-taos-sql/20-keywords.md
docs/en/12-taos-sql/20-keywords.md
+0
-0
docs/zh/12-taos-sql/08-delete-data.mdx
docs/zh/12-taos-sql/08-delete-data.mdx
+0
-0
docs/zh/12-taos-sql/10-function.md
docs/zh/12-taos-sql/10-function.md
+0
-0
docs/zh/12-taos-sql/12-interval.md
docs/zh/12-taos-sql/12-interval.md
+0
-0
docs/zh/12-taos-sql/14-limit.md
docs/zh/12-taos-sql/14-limit.md
+0
-0
docs/zh/12-taos-sql/16-json.md
docs/zh/12-taos-sql/16-json.md
+0
-0
docs/zh/12-taos-sql/18-escape.md
docs/zh/12-taos-sql/18-escape.md
+0
-0
docs/zh/12-taos-sql/20-keywords.md
docs/zh/12-taos-sql/20-keywords.md
+0
-0
include/common/tmsg.h
include/common/tmsg.h
+12
-6
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+2
-3
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+7
-4
include/libs/sync/sync.h
include/libs/sync/sync.h
+7
-7
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+1
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+21
-10
source/client/src/clientSml.c
source/client/src/clientSml.c
+12
-44
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+25
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+93
-18
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+8
-16
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
+32
-54
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+115
-115
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+14
-47
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+70
-49
source/dnode/mgmt/node_mgmt/src/dmEnv.c
source/dnode/mgmt/node_mgmt/src/dmEnv.c
+5
-3
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+6
-8
source/dnode/mnode/impl/inc/mndSma.h
source/dnode/mnode/impl/inc/mndSma.h
+1
-0
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+14
-11
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+2
-2
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+7
-9
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+1
-1
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+1
-1
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+18
-4
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+54
-14
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+14
-11
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+11
-0
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+178
-0
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-0
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+5
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+3
-3
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+3
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+51
-21
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+83
-17
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+34
-19
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+626
-341
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+10
-10
source/libs/catalog/src/ctgRemote.c
source/libs/catalog/src/ctgRemote.c
+3
-2
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+73
-31
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+6
-6
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+10
-0
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+25
-4
source/libs/parser/src/parInsertData.c
source/libs/parser/src/parInsertData.c
+4
-0
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+2
-4
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+0
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+5
-0
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+4
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+1
-1
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+223
-52
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+9
-5
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncRaftIdCheck.cpp
source/libs/sync/test/syncRaftIdCheck.cpp
+32
-0
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+31
-9
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+3
-0
source/os/src/osLz4.c
source/os/src/osLz4.c
+4
-4
source/util/src/talgo.c
source/util/src/talgo.c
+11
-1
source/util/src/tarray.c
source/util/src/tarray.c
+3
-0
source/util/test/taosbsearchTest.cpp
source/util/test/taosbsearchTest.cpp
+328
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/tsim/stable/tag_filter.sim
tests/script/tsim/stable/tag_filter.sim
+75
-0
tests/system-test/7-tmq/subscribeDb1.py
tests/system-test/7-tmq/subscribeDb1.py
+3
-3
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
docs/en/
07-develop/05
-delete-data.mdx
→
docs/en/
12-taos-sql/08
-delete-data.mdx
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/
07
-function.md
→
docs/en/12-taos-sql/
10
-function.md
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/
08
-interval.md
→
docs/en/12-taos-sql/
12
-interval.md
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/
09
-limit.md
→
docs/en/12-taos-sql/
14
-limit.md
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/1
0
-json.md
→
docs/en/12-taos-sql/1
6
-json.md
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/1
1
-escape.md
→
docs/en/12-taos-sql/1
8
-escape.md
浏览文件 @
b13c31c9
文件已移动
docs/en/12-taos-sql/
12
-keywords.md
→
docs/en/12-taos-sql/
20
-keywords.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/
07-develop/05
-delete-data.mdx
→
docs/zh/
12-taos-sql/08
-delete-data.mdx
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/
07
-function.md
→
docs/zh/12-taos-sql/
10
-function.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/
08
-interval.md
→
docs/zh/12-taos-sql/
12
-interval.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/
09
-limit.md
→
docs/zh/12-taos-sql/
14
-limit.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/1
0
-json.md
→
docs/zh/12-taos-sql/1
6
-json.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/1
1
-escape.md
→
docs/zh/12-taos-sql/1
8
-escape.md
浏览文件 @
b13c31c9
文件已移动
docs/zh/12-taos-sql/
12
-keywords.md
→
docs/zh/12-taos-sql/
20
-keywords.md
浏览文件 @
b13c31c9
文件已移动
include/common/tmsg.h
浏览文件 @
b13c31c9
...
@@ -1134,14 +1134,16 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
...
@@ -1134,14 +1134,16 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp* pRsp);
int32_t
tSerializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tSerializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tDeserializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
int32_t
tDeserializeSTableMetaRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaRsp
*
pRsp
);
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
);
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
);
void
tFreeSTableIndexRsp
(
void
*
info
);
typedef
struct
{
typedef
struct
{
SArray
*
pArray
;
// Array of STableMetaRsp
SArray
*
pMetaRsp
;
// Array of STableMetaRsp
}
STableMetaBatchRsp
;
SArray
*
pIndexRsp
;
// Array of STableIndexRsp;
}
SSTbHbRsp
;
int32_t
tSerializeS
TableMetaBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaBatch
Rsp
*
pRsp
);
int32_t
tSerializeS
STbHbRsp
(
void
*
buf
,
int32_t
bufLen
,
SSTbHb
Rsp
*
pRsp
);
int32_t
tDeserializeS
TableMetaBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaBatch
Rsp
*
pRsp
);
int32_t
tDeserializeS
STbHbRsp
(
void
*
buf
,
int32_t
bufLen
,
SSTbHb
Rsp
*
pRsp
);
void
tFreeS
TableMetaBatchRsp
(
STableMetaBatch
Rsp
*
pRsp
);
void
tFreeS
STbHbRsp
(
SSTbHb
Rsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int32_t
numOfTables
;
int32_t
numOfTables
;
...
@@ -2502,7 +2504,11 @@ typedef struct {
...
@@ -2502,7 +2504,11 @@ typedef struct {
}
STableIndexInfo
;
}
STableIndexInfo
;
typedef
struct
{
typedef
struct
{
SArray
*
pIndex
;
char
tbName
[
TSDB_TABLE_NAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
uint64_t
suid
;
int32_t
version
;
SArray
*
pIndex
;
}
STableIndexRsp
;
}
STableIndexRsp
;
int32_t
tSerializeSTableIndexRsp
(
void
*
buf
,
int32_t
bufLen
,
const
STableIndexRsp
*
pRsp
);
int32_t
tSerializeSTableIndexRsp
(
void
*
buf
,
int32_t
bufLen
,
const
STableIndexRsp
*
pRsp
);
...
...
include/dnode/mnode/mnode.h
浏览文件 @
b13c31c9
...
@@ -32,9 +32,7 @@ typedef struct {
...
@@ -32,9 +32,7 @@ typedef struct {
int32_t
dnodeId
;
int32_t
dnodeId
;
bool
standby
;
bool
standby
;
bool
deploy
;
bool
deploy
;
int8_t
replica
;
SReplica
replica
;
int8_t
selfIndex
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SMsgCb
msgCb
;
SMsgCb
msgCb
;
}
SMnodeOpt
;
}
SMnodeOpt
;
...
@@ -83,6 +81,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
...
@@ -83,6 +81,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
*/
*/
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndPreprocessQueryMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
/**
/**
* @brief Generate machine code
* @brief Generate machine code
...
...
include/libs/catalog/catalog.h
浏览文件 @
b13c31c9
...
@@ -98,14 +98,15 @@ typedef struct SCatalogCfg {
...
@@ -98,14 +98,15 @@ typedef struct SCatalogCfg {
uint32_t
stbRentSec
;
uint32_t
stbRentSec
;
}
SCatalogCfg
;
}
SCatalogCfg
;
typedef
struct
SSTable
Meta
Version
{
typedef
struct
SSTableVersion
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
stbName
[
TSDB_TABLE_NAME_LEN
];
char
stbName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
dbId
;
uint64_t
dbId
;
uint64_t
suid
;
uint64_t
suid
;
int16_t
sversion
;
int16_t
sversion
;
int16_t
tversion
;
int16_t
tversion
;
}
SSTableMetaVersion
;
int32_t
smaVer
;
}
SSTableVersion
;
typedef
struct
SDbVgVersion
{
typedef
struct
SDbVgVersion
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
@@ -267,7 +268,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t
...
@@ -267,7 +268,7 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t
int32_t
catalogGetQnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
);
int32_t
catalogGetQnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
);
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTable
MetaVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTable
Version
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
);
...
@@ -279,6 +280,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
...
@@ -279,6 +280,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
);
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
);
int32_t
catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
pass
);
...
...
include/libs/sync/sync.h
浏览文件 @
b13c31c9
...
@@ -47,8 +47,9 @@ typedef enum {
...
@@ -47,8 +47,9 @@ typedef enum {
typedef
enum
{
typedef
enum
{
TAOS_SYNC_PROPOSE_SUCCESS
=
0
,
TAOS_SYNC_PROPOSE_SUCCESS
=
0
,
TAOS_SYNC_PROPOSE_NOT_LEADER
=
1
,
TAOS_SYNC_PROPOSE_NOT_LEADER
=
1
,
TAOS_SYNC_PROPOSE_OTHER_ERROR
=
2
,
TAOS_SYNC_ONLY_ONE_REPLICA
=
2
,
TAOS_SYNC_ONLY_ONE_REPLICA
=
3
,
TAOS_SYNC_NOT_IN_NEW_CONFIG
=
3
,
TAOS_SYNC_OTHER_ERROR
=
100
,
}
ESyncProposeCode
;
}
ESyncProposeCode
;
typedef
enum
{
typedef
enum
{
...
@@ -110,6 +111,7 @@ typedef struct SSyncFSM {
...
@@ -110,6 +111,7 @@ typedef struct SSyncFSM {
void
(
*
FpRestoreFinishCb
)(
struct
SSyncFSM
*
pFsm
);
void
(
*
FpRestoreFinishCb
)(
struct
SSyncFSM
*
pFsm
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpLeaderTransferCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
...
@@ -199,15 +201,13 @@ bool syncIsRestoreFinish(int64_t rid);
...
@@ -199,15 +201,13 @@ bool syncIsRestoreFinish(int64_t rid);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
);
int32_t
syncReconfigRaw
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
,
SRpcMsg
*
pRpcMsg
);
// build SRpcMsg, need to call syncPropose with SRpcMsg
int32_t
syncReconfigBuild
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
,
SRpcMsg
*
pRpcMsg
);
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
);
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
);
// to be moved to static
void
syncStartNormal
(
int64_t
rid
);
void
syncStartStandBy
(
int64_t
rid
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/sync/syncTools.h
浏览文件 @
b13c31c9
...
@@ -467,6 +467,7 @@ typedef struct SyncLeaderTransfer {
...
@@ -467,6 +467,7 @@ typedef struct SyncLeaderTransfer {
SRaftId srcId;
SRaftId srcId;
SRaftId destId;
SRaftId destId;
*/
*/
SNodeInfo
newNodeInfo
;
SRaftId
newLeaderId
;
SRaftId
newLeaderId
;
}
SyncLeaderTransfer
;
}
SyncLeaderTransfer
;
...
...
source/client/src/clientHb.c
浏览文件 @
b13c31c9
...
@@ -99,15 +99,15 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -99,15 +99,15 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
static
int32_t
hbProcessStbInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
static
int32_t
hbProcessStbInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
S
TableMetaBatchRsp
batchMeta
Rsp
=
{
0
};
S
STbHbRsp
hb
Rsp
=
{
0
};
if
(
tDeserializeS
TableMetaBatchRsp
(
value
,
valueLen
,
&
batchMeta
Rsp
)
!=
0
)
{
if
(
tDeserializeS
STbHbRsp
(
value
,
valueLen
,
&
hb
Rsp
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
return
-
1
;
}
}
int32_t
numOf
Batchs
=
taosArrayGetSize
(
batchMetaRsp
.
pArray
);
int32_t
numOf
Meta
=
taosArrayGetSize
(
hbRsp
.
pMetaRsp
);
for
(
int32_t
i
=
0
;
i
<
numOf
Batchs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOf
Meta
;
++
i
)
{
STableMetaRsp
*
rsp
=
taosArrayGet
(
batchMetaRsp
.
pArray
,
i
);
STableMetaRsp
*
rsp
=
taosArrayGet
(
hbRsp
.
pMetaRsp
,
i
);
if
(
rsp
->
numOfColumns
<
0
)
{
if
(
rsp
->
numOfColumns
<
0
)
{
tscDebug
(
"hb remove stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
tscDebug
(
"hb remove stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
...
@@ -116,7 +116,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -116,7 +116,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
tscDebug
(
"hb update stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
tscDebug
(
"hb update stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
if
(
rsp
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
rsp
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
tscError
(
"invalid colId[%"
PRIi16
"] for the first column in table meta rsp msg"
,
rsp
->
pSchemas
[
0
].
colId
);
tscError
(
"invalid colId[%"
PRIi16
"] for the first column in table meta rsp msg"
,
rsp
->
pSchemas
[
0
].
colId
);
tFreeS
TableMetaBatchRsp
(
&
batchMeta
Rsp
);
tFreeS
STbHbRsp
(
&
hb
Rsp
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
}
...
@@ -124,7 +124,17 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -124,7 +124,17 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
}
}
}
}
tFreeSTableMetaBatchRsp
(
&
batchMetaRsp
);
int32_t
numOfIndex
=
taosArrayGetSize
(
hbRsp
.
pIndexRsp
);
for
(
int32_t
i
=
0
;
i
<
numOfIndex
;
++
i
)
{
STableIndexRsp
*
rsp
=
taosArrayGet
(
hbRsp
.
pIndexRsp
,
i
);
catalogUpdateTableIndex
(
pCatalog
,
rsp
);
}
taosArrayDestroy
(
hbRsp
.
pIndexRsp
);
hbRsp
.
pIndexRsp
=
NULL
;
tFreeSSTbHbRsp
(
&
hbRsp
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -455,7 +465,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
...
@@ -455,7 +465,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
}
}
int32_t
hbGetExpiredStbInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
int32_t
hbGetExpiredStbInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
SSTable
Meta
Version
*
stbs
=
NULL
;
SSTableVersion
*
stbs
=
NULL
;
uint32_t
stbNum
=
0
;
uint32_t
stbNum
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -469,15 +479,16 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
...
@@ -469,15 +479,16 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
}
}
for
(
int32_t
i
=
0
;
i
<
stbNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
stbNum
;
++
i
)
{
SSTable
Meta
Version
*
stb
=
&
stbs
[
i
];
SSTableVersion
*
stb
=
&
stbs
[
i
];
stb
->
suid
=
htobe64
(
stb
->
suid
);
stb
->
suid
=
htobe64
(
stb
->
suid
);
stb
->
sversion
=
htons
(
stb
->
sversion
);
stb
->
sversion
=
htons
(
stb
->
sversion
);
stb
->
tversion
=
htons
(
stb
->
tversion
);
stb
->
tversion
=
htons
(
stb
->
tversion
);
stb
->
smaVer
=
htonl
(
stb
->
smaVer
);
}
}
SKv
kv
=
{
SKv
kv
=
{
.
key
=
HEARTBEAT_KEY_STBINFO
,
.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
sizeof
(
SSTable
Meta
Version
)
*
stbNum
,
.
valueLen
=
sizeof
(
SSTableVersion
)
*
stbNum
,
.
value
=
stbs
,
.
value
=
stbs
,
};
};
...
...
source/client/src/clientSml.c
浏览文件 @
b13c31c9
...
@@ -1327,8 +1327,8 @@ static int32_t smlKvTimeArrayCompare(const void *key1, const void *key2) {
...
@@ -1327,8 +1327,8 @@ static int32_t smlKvTimeArrayCompare(const void *key1, const void *key2) {
static
int32_t
smlKvTimeHashCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
static
int32_t
smlKvTimeHashCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
SHashObj
*
s1
=
*
(
SHashObj
**
)
key1
;
SHashObj
*
s1
=
*
(
SHashObj
**
)
key1
;
SHashObj
*
s2
=
*
(
SHashObj
**
)
key2
;
SHashObj
*
s2
=
*
(
SHashObj
**
)
key2
;
SSmlKv
*
kv1
=
(
SSmlKv
*
)
taosHashGet
(
s1
,
TS
,
TS_LEN
);
SSmlKv
*
kv1
=
*
(
SSmlKv
*
*
)
taosHashGet
(
s1
,
TS
,
TS_LEN
);
SSmlKv
*
kv2
=
(
SSmlKv
*
)
taosHashGet
(
s2
,
TS
,
TS_LEN
);
SSmlKv
*
kv2
=
*
(
SSmlKv
*
*
)
taosHashGet
(
s2
,
TS
,
TS_LEN
);
ASSERT
(
kv1
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
kv1
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
kv2
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
kv2
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
if
(
kv1
->
i
<
kv2
->
i
)
{
if
(
kv1
->
i
<
kv2
->
i
)
{
...
@@ -1340,29 +1340,13 @@ static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
...
@@ -1340,29 +1340,13 @@ static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
}
}
}
}
static
int32_t
smlDealCols
(
SSmlTableInfo
*
oneTable
,
bool
dataFormat
,
SArray
*
cols
)
{
static
int32_t
smlDealCols
(
SSmlTableInfo
*
oneTable
,
bool
dataFormat
,
SArray
*
cols
)
{
if
(
dataFormat
)
{
if
(
dataFormat
)
{
void
*
p
=
taosArraySearch
(
oneTable
->
cols
,
&
cols
,
smlKvTimeArrayCompare
,
TD_G
E
);
void
*
p
=
taosArraySearch
(
oneTable
->
cols
,
&
cols
,
smlKvTimeArrayCompare
,
TD_G
T
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
taosArrayPush
(
oneTable
->
cols
,
&
cols
);
taosArrayPush
(
oneTable
->
cols
,
&
cols
);
}
else
{
// to make the sort stable for update data
}
else
{
SArray
*
sa
=
(
SArray
*
)
p
;
taosArrayInsert
(
oneTable
->
cols
,
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
),
&
cols
);
SSmlKv
*
cur
=
(
SSmlKv
*
)
taosArrayGet
(
sa
,
0
);
SSmlKv
*
dCur
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
0
);
if
(
cur
->
i
>
dCur
->
i
)
{
taosArrayInsert
(
oneTable
->
cols
,
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
),
&
cols
);
}
else
{
ASSERT
(
cur
->
i
==
dCur
->
i
);
int32_t
index
=
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
)
+
1
;
for
(;
index
<
taosArrayGetSize
(
oneTable
->
cols
);
index
++
)
{
SArray
*
tmp
=
(
SArray
*
)
taosArrayGet
(
oneTable
->
cols
,
index
);
SSmlKv
*
curTs
=
(
SSmlKv
*
)
taosArrayGet
(
tmp
,
0
);
if
(
curTs
->
i
>
dCur
->
i
)
{
break
;
}
}
taosArrayInsert
(
oneTable
->
cols
,
index
,
&
cols
);
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1377,27 +1361,11 @@ static int32_t smlDealCols(SSmlTableInfo *oneTable, bool dataFormat, SArray *col
...
@@ -1377,27 +1361,11 @@ static int32_t smlDealCols(SSmlTableInfo *oneTable, bool dataFormat, SArray *col
taosHashPut
(
kvHash
,
kv
->
key
,
kv
->
keyLen
,
&
kv
,
POINTER_BYTES
);
taosHashPut
(
kvHash
,
kv
->
key
,
kv
->
keyLen
,
&
kv
,
POINTER_BYTES
);
}
}
void
*
p
=
taosArraySearch
(
oneTable
->
cols
,
&
kvHash
,
smlKvTimeHashCompare
,
TD_G
E
);
void
*
p
=
taosArraySearch
(
oneTable
->
cols
,
&
kvHash
,
smlKvTimeHashCompare
,
TD_G
T
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
taosArrayPush
(
oneTable
->
cols
,
&
kvHash
);
taosArrayPush
(
oneTable
->
cols
,
&
kvHash
);
}
else
{
// to make the sort stable for update data
}
else
{
SHashObj
*
sa
=
(
SHashObj
*
)
p
;
taosArrayInsert
(
oneTable
->
cols
,
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
),
&
kvHash
);
SSmlKv
*
cur
=
(
SSmlKv
*
)
taosHashGet
(
sa
,
TS
,
TS_LEN
);
SSmlKv
*
dCur
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
0
);
if
(
cur
->
i
>
dCur
->
i
)
{
taosArrayInsert
(
oneTable
->
cols
,
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
),
&
cols
);
}
else
{
ASSERT
(
cur
->
i
==
dCur
->
i
);
int32_t
index
=
TARRAY_ELEM_IDX
(
oneTable
->
cols
,
p
)
+
1
;
for
(;
index
<
taosArrayGetSize
(
oneTable
->
cols
);
index
++
)
{
SHashObj
*
tmp
=
(
SHashObj
*
)
taosArrayGet
(
oneTable
->
cols
,
index
);
SSmlKv
*
curTs
=
(
SSmlKv
*
)
taosHashGet
(
tmp
,
TS
,
TS_LEN
);
if
(
curTs
->
i
>
dCur
->
i
)
{
break
;
}
}
taosArrayInsert
(
oneTable
->
cols
,
index
,
&
cols
);
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/client/test/smlTest.cpp
浏览文件 @
b13c31c9
...
@@ -1260,4 +1260,28 @@ TEST(testCase, sml_16368_Test) {
...
@@ -1260,4 +1260,28 @@ TEST(testCase, sml_16368_Test) {
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS);
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MICRO_SECONDS);
ASSERT_EQ(taos_errno(pRes), 0);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
taos_free_result(pRes);
}*/
}
TEST(testCase, sml_dup_time_Test) {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(taos, nullptr);
TAOS_RES* pRes = taos_query(taos, "create database if not exists dup_time schemaless 1");
taos_free_result(pRes);
const char *sql[] = {
//"test_ms,t0=t c0=f 1626006833641",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000"
};
pRes = taos_query(taos, "use dup_time");
taos_free_result(pRes);
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
}
*/
source/common/src/tmsg.c
浏览文件 @
b13c31c9
...
@@ -2438,6 +2438,10 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
...
@@ -2438,6 +2438,10 @@ int32_t tSerializeSTableIndexRsp(void *buf, int32_t bufLen, const STableIndexRsp
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
tbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
dbFName
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pRsp
->
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
version
)
<
0
)
return
-
1
;
int32_t
num
=
taosArrayGetSize
(
pRsp
->
pIndex
);
int32_t
num
=
taosArrayGetSize
(
pRsp
->
pIndex
);
if
(
tEncodeI32
(
&
encoder
,
num
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
num
)
<
0
)
return
-
1
;
if
(
num
>
0
)
{
if
(
num
>
0
)
{
...
@@ -2472,6 +2476,10 @@ int32_t tDeserializeSTableIndexRsp(void *buf, int32_t bufLen, STableIndexRsp *pR
...
@@ -2472,6 +2476,10 @@ int32_t tDeserializeSTableIndexRsp(void *buf, int32_t bufLen, STableIndexRsp *pR
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pRsp
->
tbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pRsp
->
dbFName
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pRsp
->
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
version
)
<
0
)
return
-
1
;
int32_t
num
=
0
;
int32_t
num
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
num
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
num
)
<
0
)
return
-
1
;
if
(
num
>
0
)
{
if
(
num
>
0
)
{
...
@@ -2631,18 +2639,35 @@ int32_t tSerializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp)
...
@@ -2631,18 +2639,35 @@ int32_t tSerializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp)
return
tlen
;
return
tlen
;
}
}
int32_t
tSerializeS
TableMetaBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaBatch
Rsp
*
pRsp
)
{
int32_t
tSerializeS
STbHbRsp
(
void
*
buf
,
int32_t
bufLen
,
SSTbHb
Rsp
*
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
;
int32_t
numOf
Batch
=
taosArrayGetSize
(
pRsp
->
pArray
);
int32_t
numOf
Meta
=
taosArrayGetSize
(
pRsp
->
pMetaRsp
);
if
(
tEncodeI32
(
&
encoder
,
numOf
Batch
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
numOf
Meta
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOf
Batch
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOf
Meta
;
++
i
)
{
STableMetaRsp
*
pMetaRsp
=
taosArrayGet
(
pRsp
->
p
Array
,
i
);
STableMetaRsp
*
pMetaRsp
=
taosArrayGet
(
pRsp
->
p
MetaRsp
,
i
);
if
(
tEncodeSTableMetaRsp
(
&
encoder
,
pMetaRsp
)
<
0
)
return
-
1
;
if
(
tEncodeSTableMetaRsp
(
&
encoder
,
pMetaRsp
)
<
0
)
return
-
1
;
}
}
int32_t
numOfIndex
=
taosArrayGetSize
(
pRsp
->
pIndexRsp
);
if
(
tEncodeI32
(
&
encoder
,
numOfIndex
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfIndex
;
++
i
)
{
STableIndexRsp
*
pIndexRsp
=
taosArrayGet
(
pRsp
->
pIndexRsp
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pIndexRsp
->
tbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pIndexRsp
->
dbFName
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pIndexRsp
->
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pIndexRsp
->
version
)
<
0
)
return
-
1
;
int32_t
num
=
taosArrayGetSize
(
pIndexRsp
->
pIndex
);
if
(
tEncodeI32
(
&
encoder
,
num
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
STableIndexInfo
*
pInfo
=
(
STableIndexInfo
*
)
taosArrayGet
(
pIndexRsp
->
pIndex
,
i
);
if
(
tSerializeSTableIndexInfo
(
&
encoder
,
pInfo
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -2662,26 +2687,58 @@ int32_t tDeserializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp
...
@@ -2662,26 +2687,58 @@ int32_t tDeserializeSTableMetaRsp(void *buf, int32_t bufLen, STableMetaRsp *pRsp
return
0
;
return
0
;
}
}
int32_t
tDeserializeS
TableMetaBatchRsp
(
void
*
buf
,
int32_t
bufLen
,
STableMetaBatch
Rsp
*
pRsp
)
{
int32_t
tDeserializeS
STbHbRsp
(
void
*
buf
,
int32_t
bufLen
,
SSTbHb
Rsp
*
pRsp
)
{
SDecoder
decoder
=
{
0
};
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
int32_t
numOfMeta
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfBatch
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfMeta
)
<
0
)
return
-
1
;
pRsp
->
pMetaRsp
=
taosArrayInit
(
numOfMeta
,
sizeof
(
STableMetaRsp
));
pRsp
->
pArray
=
taosArrayInit
(
numOfBatch
,
sizeof
(
STableMetaRsp
));
if
(
pRsp
->
pMetaRsp
==
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
<
numOf
Batch
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOf
Meta
;
++
i
)
{
STableMetaRsp
tableMetaRsp
=
{
0
};
STableMetaRsp
tableMetaRsp
=
{
0
};
if
(
tDecodeSTableMetaRsp
(
&
decoder
,
&
tableMetaRsp
)
<
0
)
return
-
1
;
if
(
tDecodeSTableMetaRsp
(
&
decoder
,
&
tableMetaRsp
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
p
Array
,
&
tableMetaRsp
);
taosArrayPush
(
pRsp
->
p
MetaRsp
,
&
tableMetaRsp
);
}
}
int32_t
numOfIndex
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfIndex
)
<
0
)
return
-
1
;
pRsp
->
pIndexRsp
=
taosArrayInit
(
numOfIndex
,
sizeof
(
STableIndexRsp
));
if
(
pRsp
->
pIndexRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfIndex
;
++
i
)
{
STableIndexRsp
tableIndexRsp
=
{
0
};
if
(
tDecodeCStrTo
(
&
decoder
,
tableIndexRsp
.
tbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
tableIndexRsp
.
dbFName
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
tableIndexRsp
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
tableIndexRsp
.
version
)
<
0
)
return
-
1
;
int32_t
num
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
num
)
<
0
)
return
-
1
;
if
(
num
>
0
)
{
tableIndexRsp
.
pIndex
=
taosArrayInit
(
num
,
sizeof
(
STableIndexInfo
));
if
(
NULL
==
tableIndexRsp
.
pIndex
)
return
-
1
;
STableIndexInfo
info
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
if
(
tDeserializeSTableIndexInfo
(
&
decoder
,
&
info
)
<
0
)
return
-
1
;
if
(
NULL
==
taosArrayPush
(
tableIndexRsp
.
pIndex
,
&
info
))
{
taosMemoryFree
(
info
.
expr
);
return
-
1
;
}
}
}
taosArrayPush
(
pRsp
->
pIndexRsp
,
&
tableIndexRsp
);
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
@@ -2690,14 +2747,32 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc
...
@@ -2690,14 +2747,32 @@ int32_t tDeserializeSTableMetaBatchRsp(void *buf, int32_t bufLen, STableMetaBatc
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
)
{
taosMemoryFreeClear
(
pRsp
->
pSchemas
);
}
void
tFreeSTableMetaRsp
(
STableMetaRsp
*
pRsp
)
{
taosMemoryFreeClear
(
pRsp
->
pSchemas
);
}
void
tFreeSTableMetaBatchRsp
(
STableMetaBatchRsp
*
pRsp
)
{
void
tFreeSTableIndexRsp
(
void
*
info
)
{
int32_t
numOfBatch
=
taosArrayGetSize
(
pRsp
->
pArray
);
if
(
NULL
==
info
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatch
;
++
i
)
{
return
;
STableMetaRsp
*
pMetaRsp
=
taosArrayGet
(
pRsp
->
pArray
,
i
);
}
STableIndexRsp
*
pInfo
=
(
STableIndexRsp
*
)
info
;
taosArrayDestroyEx
(
pInfo
->
pIndex
,
tFreeSTableIndexInfo
);
}
void
tFreeSSTbHbRsp
(
SSTbHbRsp
*
pRsp
)
{
int32_t
numOfMeta
=
taosArrayGetSize
(
pRsp
->
pMetaRsp
);
for
(
int32_t
i
=
0
;
i
<
numOfMeta
;
++
i
)
{
STableMetaRsp
*
pMetaRsp
=
taosArrayGet
(
pRsp
->
pMetaRsp
,
i
);
tFreeSTableMetaRsp
(
pMetaRsp
);
tFreeSTableMetaRsp
(
pMetaRsp
);
}
}
taosArrayDestroy
(
pRsp
->
pArray
);
taosArrayDestroy
(
pRsp
->
pMetaRsp
);
int32_t
numOfIndex
=
taosArrayGetSize
(
pRsp
->
pIndexRsp
);
for
(
int32_t
i
=
0
;
i
<
numOfIndex
;
++
i
)
{
STableIndexRsp
*
pIndexRsp
=
taosArrayGet
(
pRsp
->
pIndexRsp
,
i
);
tFreeSTableIndexRsp
(
pIndexRsp
);
}
taosArrayDestroy
(
pRsp
->
pIndexRsp
);
}
}
int32_t
tSerializeSShowRsp
(
void
*
buf
,
int32_t
bufLen
,
SShowRsp
*
pRsp
)
{
int32_t
tSerializeSShowRsp
(
void
*
buf
,
int32_t
bufLen
,
SShowRsp
*
pRsp
)
{
...
...
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
b13c31c9
...
@@ -34,39 +34,31 @@ typedef struct SMnodeMgmt {
...
@@ -34,39 +34,31 @@ typedef struct SMnodeMgmt {
SSingleWorker
writeWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
monitorWorker
;
SSingleWorker
monitorWorker
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
int8_t
replica
;
bool
stopped
;
bool
stopped
;
int32_t
refCount
;
int32_t
refCount
;
TdThreadRwlock
lock
;
TdThreadRwlock
lock
;
}
SMnodeMgmt
;
}
SMnodeMgmt
;
// mmFile.c
// mmFile.c
int32_t
mmReadFile
(
SMnodeMgmt
*
pMgmt
,
bool
*
pDeployed
);
int32_t
mmReadFile
(
SMnodeMgmt
*
pMgmt
,
SReplica
*
pReplica
,
bool
*
pDeployed
);
int32_t
mmWriteFile
(
SMnodeMgmt
*
pMgmt
,
SDCreateMnodeReq
*
pMsg
,
bool
deployed
);
int32_t
mmWriteFile
(
SMnodeMgmt
*
pMgmt
,
const
SReplica
*
pReplica
,
bool
deployed
);
// mmInt.c
int32_t
mmAcquire
(
SMnodeMgmt
*
pMgmt
);
void
mmRelease
(
SMnodeMgmt
*
pMgmt
);
// mmHandle.c
// mmHandle.c
SArray
*
mmGetMsgHandles
();
SArray
*
mmGetMsgHandles
();
int32_t
mmProcessCreateReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessCreateReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessDropReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessDropReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessAlterReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessGetLoadsReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmProcessGetLoadsReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mndPreprocessQueryMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
);
// mmWorker.c
// mmWorker.c
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
);
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
int32_t
mmPut
Node
MsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPut
Node
MsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPut
Node
MsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPut
Node
MsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPut
Node
MsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPut
Rpc
MsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
int32_t
mmPutMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
浏览文件 @
b13c31c9
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mmInt.h"
#include "mmInt.h"
int32_t
mmReadFile
(
SMnodeMgmt
*
pMgmt
,
bool
*
pDeployed
)
{
int32_t
mmReadFile
(
SMnodeMgmt
*
pMgmt
,
SReplica
*
pReplica
,
bool
*
pDeployed
)
{
int32_t
code
=
TSDB_CODE_INVALID_JSON_FORMAT
;
int32_t
code
=
TSDB_CODE_INVALID_JSON_FORMAT
;
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
4096
;
...
@@ -52,61 +52,54 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
...
@@ -52,61 +52,54 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
}
}
*
pDeployed
=
deployed
->
valueint
;
*
pDeployed
=
deployed
->
valueint
;
cJSON
*
mnodes
=
cJSON_GetObjectItem
(
root
,
"mnodes
"
);
cJSON
*
id
=
cJSON_GetObjectItem
(
root
,
"id
"
);
if
(
mnodes
!=
NULL
)
{
if
(
id
)
{
if
(
!
mnodes
||
mnodes
->
type
!=
cJSON_Array
)
{
if
(
id
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since
nodes
not found"
,
file
);
dError
(
"failed to read %s since
id
not found"
,
file
);
goto
_OVER
;
goto
_OVER
;
}
}
if
(
pReplica
)
{
pReplica
->
id
=
id
->
valueint
;
}
}
pMgmt
->
replica
=
cJSON_GetArraySize
(
mnodes
);
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
root
,
"fqdn"
);
if
(
pMgmt
->
replica
<=
0
||
pMgmt
->
replica
>
TSDB_MAX_REPLICA
)
{
if
(
fqdn
)
{
dError
(
"failed to read %s since mnodes size %d invalid"
,
file
,
pMgmt
->
replica
);
if
(
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s since fqdn not found"
,
file
);
goto
_OVER
;
goto
_OVER
;
}
}
if
(
pReplica
)
{
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
cJSON
*
node
=
cJSON_GetArrayItem
(
mnodes
,
i
);
if
(
node
==
NULL
)
break
;
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
cJSON
*
id
=
cJSON_GetObjectItem
(
node
,
"id"
);
if
(
!
id
||
id
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since id not found"
,
file
);
goto
_OVER
;
}
pReplica
->
id
=
id
->
valueint
;
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
node
,
"fqdn"
);
if
(
!
fqdn
||
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s since fqdn not found"
,
file
);
goto
_OVER
;
}
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
}
}
cJSON
*
port
=
cJSON_GetObjectItem
(
node
,
"port"
);
cJSON
*
port
=
cJSON_GetObjectItem
(
root
,
"port"
);
if
(
!
port
||
port
->
type
!=
cJSON_Number
)
{
if
(
port
)
{
dError
(
"failed to read %s since port not found"
,
file
);
if
(
port
->
type
!=
cJSON_Number
)
{
goto
_OVER
;
dError
(
"failed to read %s since port not found"
,
file
);
}
goto
_OVER
;
pReplica
->
port
=
port
->
valueint
;
}
if
(
pReplica
)
{
pReplica
->
port
=
(
uint16_t
)
port
->
valueint
;
}
}
}
}
code
=
0
;
code
=
0
;
dDebug
(
"succcessed to read file %s, deployed:%d"
,
file
,
*
pDeployed
);
_OVER:
_OVER:
if
(
content
!=
NULL
)
taosMemoryFree
(
content
);
if
(
content
!=
NULL
)
taosMemoryFree
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
if
(
code
==
0
)
{
dDebug
(
"succcessed to read file %s, deployed:%d"
,
file
,
*
pDeployed
);
}
terrno
=
code
;
terrno
=
code
;
return
code
;
return
code
;
}
}
int32_t
mmWriteFile
(
SMnodeMgmt
*
pMgmt
,
SDCreateMnodeReq
*
pMsg
,
bool
deployed
)
{
int32_t
mmWriteFile
(
SMnodeMgmt
*
pMgmt
,
const
SReplica
*
pReplica
,
bool
deployed
)
{
char
file
[
PATH_MAX
]
=
{
0
};
char
file
[
PATH_MAX
]
=
{
0
};
char
realfile
[
PATH_MAX
]
=
{
0
};
char
realfile
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%smnode.json.bak"
,
pMgmt
->
path
,
TD_DIRSEP
);
snprintf
(
file
,
sizeof
(
file
),
"%s%smnode.json.bak"
,
pMgmt
->
path
,
TD_DIRSEP
);
...
@@ -124,26 +117,11 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
...
@@ -124,26 +117,11 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
if
(
pReplica
!=
NULL
&&
pReplica
->
id
>
0
)
{
int8_t
replica
=
(
pMsg
!=
NULL
?
pMsg
->
replica
:
pMgmt
->
replica
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pReplica
->
id
);
if
(
replica
>
0
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pReplica
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u
\n
,"
,
pReplica
->
port
);
for
(
int32_t
i
=
0
;
i
<
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
if
(
pMsg
!=
NULL
)
{
pReplica
=
&
pMsg
->
replicas
[
i
];
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pReplica
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pReplica
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u
\n
"
,
pReplica
->
port
);
if
(
i
<
replica
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }],
\n
"
);
}
}
}
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d
\n
"
,
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d
\n
"
,
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"}
\n
"
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
b13c31c9
...
@@ -20,11 +20,6 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
...
@@ -20,11 +20,6 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
grant
);
mndGetMonitorInfo
(
pMgmt
->
pMnode
,
&
pInfo
->
cluster
,
&
pInfo
->
vgroup
,
&
pInfo
->
grant
);
}
}
void
mmGetMnodeLoads
(
SMnodeMgmt
*
pMgmt
,
SMonMloadInfo
*
pInfo
)
{
pInfo
->
isMnode
=
1
;
mndGetLoad
(
pMgmt
->
pMnode
,
&
pInfo
->
load
);
}
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmProcessGetMonitorInfoReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SMonMmInfo
mmInfo
=
{
0
};
SMonMmInfo
mmInfo
=
{
0
};
mmGetMonitorInfo
(
pMgmt
,
&
mmInfo
);
mmGetMonitorInfo
(
pMgmt
,
&
mmInfo
);
...
@@ -50,6 +45,11 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -50,6 +45,11 @@ int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
0
;
return
0
;
}
}
void
mmGetMnodeLoads
(
SMnodeMgmt
*
pMgmt
,
SMonMloadInfo
*
pInfo
)
{
pInfo
->
isMnode
=
1
;
mndGetLoad
(
pMgmt
->
pMnode
,
&
pInfo
->
load
);
}
int32_t
mmProcessGetLoadsReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmProcessGetLoadsReq
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SMonMloadInfo
mloads
=
{
0
};
SMonMloadInfo
mloads
=
{
0
};
mmGetMnodeLoads
(
pMgmt
,
&
mloads
);
mmGetMnodeLoads
(
pMgmt
,
&
mloads
);
...
@@ -90,7 +90,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
...
@@ -90,7 +90,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
SMnodeMgmt
mgmt
=
{
0
};
SMnodeMgmt
mgmt
=
{
0
};
mgmt
.
path
=
pInput
->
path
;
mgmt
.
path
=
pInput
->
path
;
mgmt
.
name
=
pInput
->
name
;
mgmt
.
name
=
pInput
->
name
;
if
(
mmWriteFile
(
&
mgmt
,
&
createReq
,
deployed
)
!=
0
)
{
if
(
mmWriteFile
(
&
mgmt
,
&
createReq
.
replicas
[
0
]
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
dError
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -126,117 +126,117 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
...
@@ -126,117 +126,117 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
SArray
*
mmGetMsgHandles
()
{
SArray
*
mmGetMsgHandles
()
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SArray
*
pArray
=
taosArrayInit
(
64
,
sizeof
(
SMgmtHandle
));
SArray
*
pArray
=
taosArrayInit
(
128
,
sizeof
(
SMgmtHandle
));
if
(
pArray
==
NULL
)
goto
_OVER
;
if
(
pArray
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_MNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_MNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_MNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_MNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_QNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_QNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_QNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_QNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_SNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_SNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_SNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_SNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_BNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_BNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_BNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_BNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CONFIG_DNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CONFIG_DNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CONNECT
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CONNECT
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_ACCT
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_ACCT
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_ACCT
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_ACCT
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_ACCT
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_ACCT
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_USER
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_USER
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_USER
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_USER
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_USER
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_USER
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_USER_AUTH
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_USER_AUTH
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_DNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_DNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CONFIG_DNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CONFIG_DNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_DNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_DNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_MNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_MNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_QNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_QNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_QNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_QNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_QNODE_LIST
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_QNODE_LIST
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_BNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_BNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_BNODE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_BNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_DB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_DB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_DB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_DB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_USE_DB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_USE_DB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_DB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_DB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_COMPACT_DB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_COMPACT_DB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_DB_CFG
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_DB_CFG
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_VGROUP_LIST
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_VGROUP_LIST
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MERGE_VGROUP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MERGE_VGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_BALANCE_VGROUP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_BALANCE_VGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_FUNC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_FUNC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_RETRIEVE_FUNC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_RETRIEVE_FUNC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_FUNC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_FUNC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_STB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_STB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_STB
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_STB
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TABLE_META
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TABLE_META
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SMA
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SMA
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STREAM
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_INDEX
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_TABLE_INDEX
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_TABLE_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_TOPIC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_TOPIC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_TOPIC
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SUBSCRIBE
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SUBSCRIBE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_ASK_EP
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_ASK_EP
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_TRANS
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_TRANS
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_QUERY
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_QUERY
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_CONN
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_CONN
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_HEARTBEAT
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_HEARTBEAT
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_STATUS
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_STATUS
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SYSTABLE_RETRIEVE
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GRANT
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GRANT
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_AUTH
,
mmPut
Node
MsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_AUTH
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
mmPut
Node
MsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
mmPut
Node
MsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_HEARTBEAT
,
mmPut
Node
MsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_HEARTBEAT
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH
,
mmPut
Node
MsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_STB_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_STB_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_STB_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_STB_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_STB_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_STB_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_SMA_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_SMA_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_SMA_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_SMA_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_CHANGE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_CHANGE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
mmPut
Node
MsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT_RSP
,
mmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_MM_INFO
,
mmPut
Node
MsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_MM_INFO
,
mmPutMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_MM_LOAD
,
mmPut
Node
MsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_MM_LOAD
,
mmPutMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PING
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PING
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PING_REPLY
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PING_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_REQUEST_VOTE
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_REQUEST_VOTE
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_REQUEST_VOTE_REPLY
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_REQUEST_VOTE_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPut
Node
MsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY
,
mmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY
,
mmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
b13c31c9
...
@@ -27,7 +27,7 @@ static bool mmDeployRequired(const SMgmtInputOpt *pInput) {
...
@@ -27,7 +27,7 @@ static bool mmDeployRequired(const SMgmtInputOpt *pInput) {
static
int32_t
mmRequire
(
const
SMgmtInputOpt
*
pInput
,
bool
*
required
)
{
static
int32_t
mmRequire
(
const
SMgmtInputOpt
*
pInput
,
bool
*
required
)
{
SMnodeMgmt
mgmt
=
{
0
};
SMnodeMgmt
mgmt
=
{
0
};
mgmt
.
path
=
pInput
->
path
;
mgmt
.
path
=
pInput
->
path
;
if
(
mmReadFile
(
&
mgmt
,
required
)
!=
0
)
{
if
(
mmReadFile
(
&
mgmt
,
NULL
,
required
)
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -43,33 +43,19 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu
...
@@ -43,33 +43,19 @@ static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, const SMgmtInputOpt *pInpu
pOption
->
deploy
=
true
;
pOption
->
deploy
=
true
;
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
dnodeId
=
pMgmt
->
pData
->
dnodeId
;
pOption
->
dnodeId
=
pMgmt
->
pData
->
dnodeId
;
pOption
->
replica
.
id
=
1
;
pOption
->
replica
=
1
;
pOption
->
replica
.
port
=
tsServerPort
;
pOption
->
selfIndex
=
0
;
tstrncpy
(
pOption
->
replica
.
fqdn
,
tsLocalFqdn
,
TSDB_FQDN_LEN
);
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
pReplica
->
id
=
1
;
pReplica
->
port
=
tsServerPort
;
tstrncpy
(
pReplica
->
fqdn
,
tsLocalFqdn
,
TSDB_FQDN_LEN
);
}
}
static
void
mmBuildOptionForOpen
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
)
{
static
void
mmBuildOptionForOpen
(
SMnodeMgmt
*
pMgmt
,
const
SReplica
*
pReplica
,
SMnodeOpt
*
pOption
)
{
pOption
->
deploy
=
false
;
pOption
->
standby
=
false
;
pOption
->
standby
=
false
;
pOption
->
deploy
=
false
;
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
dnodeId
=
pMgmt
->
pData
->
dnodeId
;
pOption
->
dnodeId
=
pMgmt
->
pData
->
dnodeId
;
if
(
pReplica
->
id
>
0
)
{
if
(
pMgmt
->
replica
>
0
)
{
pOption
->
standby
=
true
;
pOption
->
standby
=
true
;
pOption
->
replica
=
1
;
pOption
->
replica
=
*
pReplica
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
if
(
pMgmt
->
replicas
[
i
].
id
!=
pMgmt
->
pData
->
dnodeId
)
continue
;
pReplica
->
id
=
pMgmt
->
replicas
[
i
].
id
;
pReplica
->
port
=
pMgmt
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
pMgmt
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
}
}
}
}
}
...
@@ -105,12 +91,13 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
...
@@ -105,12 +91,13 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
mmPut
Rpc
MsgToQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
mmPutMsgToQueue
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
bool
deployed
=
false
;
bool
deployed
=
false
;
if
(
mmReadFile
(
pMgmt
,
&
deployed
)
!=
0
)
{
SReplica
replica
=
{
0
};
if
(
mmReadFile
(
pMgmt
,
&
replica
,
&
deployed
)
!=
0
)
{
dError
(
"failed to read file since %s"
,
terrstr
());
dError
(
"failed to read file since %s"
,
terrstr
());
mmClose
(
pMgmt
);
mmClose
(
pMgmt
);
return
-
1
;
return
-
1
;
...
@@ -123,7 +110,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
...
@@ -123,7 +110,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
mmBuildOptionForDeploy
(
pMgmt
,
pInput
,
&
option
);
mmBuildOptionForDeploy
(
pMgmt
,
pInput
,
&
option
);
}
else
{
}
else
{
dInfo
(
"mnode start to open"
);
dInfo
(
"mnode start to open"
);
mmBuildOptionForOpen
(
pMgmt
,
&
option
);
mmBuildOptionForOpen
(
pMgmt
,
&
replica
,
&
option
);
}
}
pMgmt
->
pMnode
=
mndOpen
(
pMgmt
->
path
,
&
option
);
pMgmt
->
pMnode
=
mndOpen
(
pMgmt
->
path
,
&
option
);
...
@@ -141,8 +128,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
...
@@ -141,8 +128,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
}
}
tmsgReportStartup
(
"mnode-worker"
,
"initialized"
);
tmsgReportStartup
(
"mnode-worker"
,
"initialized"
);
if
(
!
deployed
||
pMgmt
->
replica
>
0
)
{
if
(
!
deployed
||
replica
.
id
>
0
)
{
pMgmt
->
replica
=
0
;
deployed
=
true
;
deployed
=
true
;
if
(
mmWriteFile
(
pMgmt
,
NULL
,
deployed
)
!=
0
)
{
if
(
mmWriteFile
(
pMgmt
,
NULL
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
dError
(
"failed to write mnode file since %s"
,
terrstr
());
...
@@ -178,22 +164,3 @@ SMgmtFunc mmGetMgmtFunc() {
...
@@ -178,22 +164,3 @@ SMgmtFunc mmGetMgmtFunc() {
return
mgmtFunc
;
return
mgmtFunc
;
}
}
int32_t
mmAcquire
(
SMnodeMgmt
*
pMgmt
)
{
int32_t
code
=
0
;
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
if
(
pMgmt
->
stopped
)
{
code
=
-
1
;
}
else
{
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
}
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
return
code
;
}
void
mmRelease
(
SMnodeMgmt
*
pMgmt
)
{
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
atomic_sub_fetch_32
(
&
pMgmt
->
refCount
,
1
);
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
}
\ No newline at end of file
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
b13c31c9
...
@@ -16,6 +16,25 @@
...
@@ -16,6 +16,25 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mmInt.h"
#include "mmInt.h"
static
inline
int32_t
mmAcquire
(
SMnodeMgmt
*
pMgmt
)
{
int32_t
code
=
0
;
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
if
(
pMgmt
->
stopped
)
{
code
=
-
1
;
}
else
{
atomic_add_fetch_32
(
&
pMgmt
->
refCount
,
1
);
}
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
return
code
;
}
static
inline
void
mmRelease
(
SMnodeMgmt
*
pMgmt
)
{
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
atomic_sub_fetch_32
(
&
pMgmt
->
refCount
,
1
);
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
}
static
inline
void
mmSendRsp
(
SRpcMsg
*
pMsg
,
int32_t
code
)
{
static
inline
void
mmSendRsp
(
SRpcMsg
*
pMsg
,
int32_t
code
)
{
SRpcMsg
rsp
=
{
SRpcMsg
rsp
=
{
.
code
=
code
,
.
code
=
code
,
...
@@ -26,7 +45,7 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
...
@@ -26,7 +45,7 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
}
static
void
mmProcess
Queue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
static
void
mmProcess
RpcMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
dTrace
(
"msg:%p, get from mnode queue"
,
pMsg
);
dTrace
(
"msg:%p, get from mnode queue"
,
pMsg
);
...
@@ -53,11 +72,10 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -53,11 +72,10 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
static
void
mmProcessSync
Queue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
static
void
mmProcessSync
Msg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
dTrace
(
"msg:%p, get from mnode-sync queue"
,
pMsg
);
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
dTrace
(
"msg:%p, get from mnode-sync queue"
,
pMsg
);
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
pHead
->
contLen
=
ntohl
(
pHead
->
contLen
);
pHead
->
contLen
=
ntohl
(
pHead
->
contLen
);
...
@@ -70,66 +88,69 @@ static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -70,66 +88,69 @@ static void mmProcessSyncQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
static
int32_t
mmPutNodeMsgToWorker
(
SSingleWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
static
inline
int32_t
mmPutMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
SSingleWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into %s queue, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pMsg
->
msgType
));
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
dTrace
(
"msg:%p, put into %s queue, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pMsg
->
msgType
));
return
0
;
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
mmRelease
(
pMgmt
);
return
0
;
}
else
{
dTrace
(
"msg:%p, failed to put into %s queue since %s, type:%s"
,
pMsg
,
pWorker
->
name
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
-
1
;
}
}
}
int32_t
mmPut
Node
MsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPut
NodeMsgToWorker
(
&
pMgmt
->
writeWorker
,
pMsg
);
return
mmPut
MsgToWorker
(
pMgmt
,
&
pMgmt
->
writeWorker
,
pMsg
);
}
}
int32_t
mmPut
Node
MsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPut
NodeMsgToWorker
(
&
pMgmt
->
syncWorker
,
pMsg
);
return
mmPut
MsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
}
}
int32_t
mmPut
Node
MsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPut
NodeMsgToWorker
(
&
pMgmt
->
readWorker
,
pMsg
);
return
mmPut
MsgToWorker
(
pMgmt
,
&
pMgmt
->
readWorker
,
pMsg
);
}
}
int32_t
mmPutNodeMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
mndPreprocessQueryMsg
(
pMgmt
->
pMnode
,
pMsg
);
if
(
mndPreprocessQueryMsg
(
pMgmt
->
pMnode
,
pMsg
)
!=
0
)
{
dError
(
"msg:%p, failed to pre-process in mnode since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
mmPutNodeMsgToWorker
(
&
pMgmt
->
queryWorker
,
pMsg
);
return
-
1
;
}
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
queryWorker
,
pMsg
);
}
}
int32_t
mmPut
Node
MsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPut
NodeMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
return
mmPut
MsgToWorker
(
pMgmt
,
&
pMgmt
->
monitorWorker
,
pMsg
);
}
}
int32_t
mmPutRpcMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
int32_t
mmPutMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
SSingleWorker
*
pWorker
=
NULL
;
if
(
pMsg
==
NULL
)
return
-
1
;
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
switch
(
qtype
)
{
switch
(
qtype
)
{
case
WRITE_QUEUE
:
case
WRITE_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-write queue"
,
pMsg
);
pWorker
=
&
pMgmt
->
writeWorker
;
taosWriteQitem
(
pMgmt
->
writeWorker
.
queue
,
pMsg
);
break
;
return
0
;
case
QUERY_QUEUE
:
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-query queue"
,
pMsg
);
pWorker
=
&
pMgmt
->
queryWorker
;
taosWriteQitem
(
pMgmt
->
queryWorker
.
queue
,
pMsg
);
break
;
return
0
;
case
READ_QUEUE
:
case
READ_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-read queue"
,
pMsg
);
pWorker
=
&
pMgmt
->
readWorker
;
taosWriteQitem
(
pMgmt
->
readWorker
.
queue
,
pMsg
);
break
;
return
0
;
case
SYNC_QUEUE
:
case
SYNC_QUEUE
:
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
pWorker
=
&
pMgmt
->
syncWorker
;
dTrace
(
"msg:%p, is created and will put into vnode-sync queue"
,
pMsg
);
break
;
taosWriteQitem
(
pMgmt
->
syncWorker
.
queue
,
pMsg
);
mmRelease
(
pMgmt
);
return
0
;
}
else
{
return
-
1
;
}
default:
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
}
if
(
pWorker
==
NULL
)
return
-
1
;
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
dTrace
(
"msg:%p, is created and will put int %s queue"
,
pMsg
,
pWorker
->
name
);
return
mmPutMsgToWorker
(
pMgmt
,
pWorker
,
pMsg
);
}
}
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
)
{
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
)
{
...
@@ -137,7 +158,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -137,7 +158,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
.
min
=
tsNumOfMnodeQueryThreads
,
.
min
=
tsNumOfMnodeQueryThreads
,
.
max
=
tsNumOfMnodeQueryThreads
,
.
max
=
tsNumOfMnodeQueryThreads
,
.
name
=
"mnode-query"
,
.
name
=
"mnode-query"
,
.
fp
=
(
FItem
)
mmProcess
Queue
,
.
fp
=
(
FItem
)
mmProcess
RpcMsg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
queryWorker
,
&
qCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
queryWorker
,
&
qCfg
)
!=
0
)
{
...
@@ -149,7 +170,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -149,7 +170,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
.
min
=
tsNumOfMnodeReadThreads
,
.
min
=
tsNumOfMnodeReadThreads
,
.
max
=
tsNumOfMnodeReadThreads
,
.
max
=
tsNumOfMnodeReadThreads
,
.
name
=
"mnode-read"
,
.
name
=
"mnode-read"
,
.
fp
=
(
FItem
)
mmProcess
Queue
,
.
fp
=
(
FItem
)
mmProcess
RpcMsg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
readWorker
,
&
rCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
readWorker
,
&
rCfg
)
!=
0
)
{
...
@@ -161,7 +182,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -161,7 +182,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
.
min
=
1
,
.
min
=
1
,
.
max
=
1
,
.
max
=
1
,
.
name
=
"mnode-write"
,
.
name
=
"mnode-write"
,
.
fp
=
(
FItem
)
mmProcess
Queue
,
.
fp
=
(
FItem
)
mmProcess
RpcMsg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
writeWorker
,
&
wCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
writeWorker
,
&
wCfg
)
!=
0
)
{
...
@@ -173,7 +194,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -173,7 +194,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
.
min
=
1
,
.
min
=
1
,
.
max
=
1
,
.
max
=
1
,
.
name
=
"mnode-sync"
,
.
name
=
"mnode-sync"
,
.
fp
=
(
FItem
)
mmProcessSync
Queue
,
.
fp
=
(
FItem
)
mmProcessSync
Msg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
syncWorker
,
&
sCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
syncWorker
,
&
sCfg
)
!=
0
)
{
...
@@ -185,7 +206,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -185,7 +206,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
.
min
=
1
,
.
min
=
1
,
.
max
=
1
,
.
max
=
1
,
.
name
=
"mnode-monitor"
,
.
name
=
"mnode-monitor"
,
.
fp
=
(
FItem
)
mmProcess
Queue
,
.
fp
=
(
FItem
)
mmProcess
RpcMsg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
monitorWorker
,
&
mCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
monitorWorker
,
&
mCfg
)
!=
0
)
{
...
...
source/dnode/mgmt/node_mgmt/src/dmEnv.c
浏览文件 @
b13c31c9
...
@@ -123,10 +123,12 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
...
@@ -123,10 +123,12 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) {
dError
(
"node:%s, failed to create since %s"
,
pWrapper
->
name
,
terrstr
());
dError
(
"node:%s, failed to create since %s"
,
pWrapper
->
name
,
terrstr
());
}
else
{
}
else
{
dInfo
(
"node:%s, has been created"
,
pWrapper
->
name
);
dInfo
(
"node:%s, has been created"
,
pWrapper
->
name
);
(
void
)
dmOpenNode
(
pWrapper
);
code
=
dmOpenNode
(
pWrapper
);
(
void
)
dmStartNode
(
pWrapper
);
if
(
code
==
0
)
{
pWrapper
->
required
=
true
;
code
=
dmStartNode
(
pWrapper
);
}
pWrapper
->
deployed
=
true
;
pWrapper
->
deployed
=
true
;
pWrapper
->
required
=
true
;
pWrapper
->
proc
.
ptype
=
pDnode
->
ptype
;
pWrapper
->
proc
.
ptype
=
pDnode
->
ptype
;
}
}
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
b13c31c9
...
@@ -76,11 +76,12 @@ typedef struct {
...
@@ -76,11 +76,12 @@ typedef struct {
}
STelemMgmt
;
}
STelemMgmt
;
typedef
struct
{
typedef
struct
{
sem_t
syncSem
;
sem_t
syncSem
;
int64_t
sync
;
int64_t
sync
;
bool
standby
;
bool
standby
;
int32_t
errCode
;
SReplica
replica
;
int32_t
transId
;
int32_t
errCode
;
int32_t
transId
;
}
SSyncMgmt
;
}
SSyncMgmt
;
typedef
struct
{
typedef
struct
{
...
@@ -98,9 +99,6 @@ typedef struct SMnode {
...
@@ -98,9 +99,6 @@ typedef struct SMnode {
bool
stopped
;
bool
stopped
;
bool
restored
;
bool
restored
;
bool
deploy
;
bool
deploy
;
int8_t
replica
;
int8_t
selfIndex
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
char
*
path
;
char
*
path
;
int64_t
checkTime
;
int64_t
checkTime
;
SSdb
*
pSdb
;
SSdb
*
pSdb
;
...
...
source/dnode/mnode/impl/inc/mndSma.h
浏览文件 @
b13c31c9
...
@@ -26,6 +26,7 @@ int32_t mndInitSma(SMnode *pMnode);
...
@@ -26,6 +26,7 @@ int32_t mndInitSma(SMnode *pMnode);
void
mndCleanupSma
(
SMnode
*
pMnode
);
void
mndCleanupSma
(
SMnode
*
pMnode
);
SSmaObj
*
mndAcquireSma
(
SMnode
*
pMnode
,
char
*
smaName
);
SSmaObj
*
mndAcquireSma
(
SMnode
*
pMnode
,
char
*
smaName
);
void
mndReleaseSma
(
SMnode
*
pMnode
,
SSmaObj
*
pSma
);
void
mndReleaseSma
(
SMnode
*
pMnode
,
SSmaObj
*
pSma
);
int32_t
mndGetTableSma
(
SMnode
*
pMnode
,
char
*
tbFName
,
STableIndexRsp
*
rsp
,
bool
*
exist
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
b13c31c9
...
@@ -27,7 +27,7 @@ void mndCleanupStb(SMnode *pMnode);
...
@@ -27,7 +27,7 @@ void mndCleanupStb(SMnode *pMnode);
SStbObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
);
SStbObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
);
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStbObj
*
pStb
);
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStbObj
*
pStb
);
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
);
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
);
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTable
Meta
Version
*
pStbs
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableVersion
*
pStbs
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
int32_t
*
pRspLen
);
int32_t
mndGetNumOfStbs
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStbs
);
int32_t
mndGetNumOfStbs
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStbs
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
b13c31c9
...
@@ -1366,7 +1366,7 @@ char *buildRetension(SArray *pRetension) {
...
@@ -1366,7 +1366,7 @@ char *buildRetension(SArray *pRetension) {
}
}
static
void
dumpDbInfoData
(
SSDataBlock
*
pBlock
,
SDbObj
*
pDb
,
SShowObj
*
pShow
,
int32_t
rows
,
int64_t
numOfTables
,
static
void
dumpDbInfoData
(
SSDataBlock
*
pBlock
,
SDbObj
*
pDb
,
SShowObj
*
pShow
,
int32_t
rows
,
int64_t
numOfTables
,
bool
sysDb
)
{
bool
sysDb
,
ESdbStatus
objStatus
)
{
int32_t
cols
=
0
;
int32_t
cols
=
0
;
int32_t
bytes
=
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
;
int32_t
bytes
=
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
;
...
@@ -1379,6 +1379,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
...
@@ -1379,6 +1379,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
}
}
char
*
status
=
"ready"
;
char
*
status
=
"ready"
;
if
(
objStatus
==
SDB_STATUS_CREATING
)
status
=
"creating"
;
if
(
objStatus
==
SDB_STATUS_DROPPING
)
status
=
"dropping"
;
char
statusB
[
24
]
=
{
0
};
char
statusB
[
24
]
=
{
0
};
STR_WITH_SIZE_TO_VARSTR
(
statusB
,
status
,
strlen
(
status
));
STR_WITH_SIZE_TO_VARSTR
(
statusB
,
status
,
strlen
(
status
));
...
@@ -1503,8 +1505,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
...
@@ -1503,8 +1505,8 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
statusB
,
false
);
colDataAppend
(
pColInfo
,
rows
,
(
const
char
*
)
statusB
,
false
);
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false);
// colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.schemaless, false);
char
*
p
=
buildRetension
(
pDb
->
cfg
.
pRetensions
);
char
*
p
=
buildRetension
(
pDb
->
cfg
.
pRetensions
);
...
@@ -1548,29 +1550,30 @@ static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, v
...
@@ -1548,29 +1550,30 @@ static bool mndGetTablesOfDbFp(SMnode *pMnode, void *pObj, void *p1, void *p2, v
}
}
static
int32_t
mndRetrieveDbs
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rowsCapacity
)
{
static
int32_t
mndRetrieveDbs
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rowsCapacity
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
ESdbStatus
objStatus
=
0
;
// Append the information_schema database into the result.
// Append the information_schema database into the result.
if
(
!
pShow
->
sysDbRsp
)
{
if
(
!
pShow
->
sysDbRsp
)
{
SDbObj
infoschemaDb
=
{
0
};
SDbObj
infoschemaDb
=
{
0
};
setInformationSchemaDbCfg
(
&
infoschemaDb
);
setInformationSchemaDbCfg
(
&
infoschemaDb
);
dumpDbInfoData
(
pBlock
,
&
infoschemaDb
,
pShow
,
numOfRows
,
14
,
true
);
dumpDbInfoData
(
pBlock
,
&
infoschemaDb
,
pShow
,
numOfRows
,
14
,
true
,
0
);
numOfRows
+=
1
;
numOfRows
+=
1
;
SDbObj
perfschemaDb
=
{
0
};
SDbObj
perfschemaDb
=
{
0
};
setPerfSchemaDbCfg
(
&
perfschemaDb
);
setPerfSchemaDbCfg
(
&
perfschemaDb
);
dumpDbInfoData
(
pBlock
,
&
perfschemaDb
,
pShow
,
numOfRows
,
3
,
true
);
dumpDbInfoData
(
pBlock
,
&
perfschemaDb
,
pShow
,
numOfRows
,
3
,
true
,
0
);
numOfRows
+=
1
;
numOfRows
+=
1
;
pShow
->
sysDbRsp
=
true
;
pShow
->
sysDbRsp
=
true
;
}
}
while
(
numOfRows
<
rowsCapacity
)
{
while
(
numOfRows
<
rowsCapacity
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_DB
,
pShow
->
pIter
,
(
void
**
)
&
pDb
);
pShow
->
pIter
=
sdbFetch
All
(
pSdb
,
SDB_DB
,
pShow
->
pIter
,
(
void
**
)
&
pDb
,
&
objStatus
);
if
(
pShow
->
pIter
==
NULL
)
{
if
(
pShow
->
pIter
==
NULL
)
{
break
;
break
;
}
}
...
@@ -1578,7 +1581,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
...
@@ -1578,7 +1581,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
sdbTraverse
(
pSdb
,
SDB_VGROUP
,
mndGetTablesOfDbFp
,
&
numOfTables
,
NULL
,
NULL
);
sdbTraverse
(
pSdb
,
SDB_VGROUP
,
mndGetTablesOfDbFp
,
&
numOfTables
,
NULL
,
NULL
);
dumpDbInfoData
(
pBlock
,
pDb
,
pShow
,
numOfRows
,
numOfTables
,
false
);
dumpDbInfoData
(
pBlock
,
pDb
,
pShow
,
numOfRows
,
numOfTables
,
false
,
objStatus
);
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pDb
);
sdbRelease
(
pSdb
,
pDb
);
}
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
b13c31c9
...
@@ -95,8 +95,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
...
@@ -95,8 +95,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
dnodeObj
.
id
=
1
;
dnodeObj
.
id
=
1
;
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
dnodeObj
.
createdTime
=
taosGetTimestampMs
();
dnodeObj
.
updateTime
=
dnodeObj
.
createdTime
;
dnodeObj
.
updateTime
=
dnodeObj
.
createdTime
;
dnodeObj
.
port
=
pMnode
->
replicas
[
0
].
p
ort
;
dnodeObj
.
port
=
tsServerP
ort
;
memcpy
(
&
dnodeObj
.
fqdn
,
pMnode
->
replicas
[
0
].
f
qdn
,
TSDB_FQDN_LEN
);
memcpy
(
&
dnodeObj
.
fqdn
,
tsLocalF
qdn
,
TSDB_FQDN_LEN
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
snprintf
(
dnodeObj
.
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
dnodeObj
.
fqdn
,
dnodeObj
.
port
);
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_GLOBAL
,
NULL
);
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_GLOBAL
,
NULL
);
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
b13c31c9
...
@@ -289,11 +289,9 @@ static int32_t mndExecSteps(SMnode *pMnode) {
...
@@ -289,11 +289,9 @@ static int32_t mndExecSteps(SMnode *pMnode) {
}
}
static
void
mndSetOptions
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
static
void
mndSetOptions
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
pMnode
->
replica
=
pOption
->
replica
;
pMnode
->
selfIndex
=
pOption
->
selfIndex
;
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
msgCb
=
pOption
->
msgCb
;
pMnode
->
msgCb
=
pOption
->
msgCb
;
pMnode
->
selfDnodeId
=
pOption
->
dnodeId
;
pMnode
->
selfDnodeId
=
pOption
->
dnodeId
;
pMnode
->
syncMgmt
.
replica
=
pOption
->
replica
;
pMnode
->
syncMgmt
.
standby
=
pOption
->
standby
;
pMnode
->
syncMgmt
.
standby
=
pOption
->
standby
;
}
}
...
@@ -382,22 +380,22 @@ void mndStop(SMnode *pMnode) {
...
@@ -382,22 +380,22 @@ void mndStop(SMnode *pMnode) {
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
int32_t
code
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
int32_t
code
=
TAOS_SYNC_OTHER_ERROR
;
if
(
!
syncEnvIsStart
())
{
if
(
!
syncEnvIsStart
())
{
mError
(
"failed to process sync msg:%p type:%s since syncEnv stop"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"failed to process sync msg:%p type:%s since syncEnv stop"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
return
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pMgmt
->
sync
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pMgmt
->
sync
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
mError
(
"failed to process sync msg:%p type:%s since syncNode is null"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"failed to process sync msg:%p type:%s since syncNode is null"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
return
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
if
(
mndAcquireSyncRef
(
pMnode
)
!=
0
)
{
if
(
mndAcquireSyncRef
(
pMnode
)
!=
0
)
{
mError
(
"failed to process sync msg:%p type:%s since %s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrstr
());
mError
(
"failed to process sync msg:%p type:%s since %s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrstr
());
return
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
char
logBuf
[
512
]
=
{
0
};
char
logBuf
[
512
]
=
{
0
};
...
@@ -458,7 +456,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
...
@@ -458,7 +456,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
else
{
}
else
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
code
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
code
=
TAOS_SYNC_OTHER_ERROR
;
}
}
}
else
{
}
else
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
...
@@ -499,7 +497,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
...
@@ -499,7 +497,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
else
{
}
else
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
code
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
code
=
TAOS_SYNC_OTHER_ERROR
;
}
}
}
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
b13c31c9
...
@@ -659,7 +659,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
...
@@ -659,7 +659,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SMnodeObj
*
pObj
=
NULL
;
SMnodeObj
*
pObj
=
NULL
;
ESdbStatus
objStatus
;
ESdbStatus
objStatus
=
0
;
char
*
pWrite
;
char
*
pWrite
;
int64_t
curMs
=
taosGetTimestampMs
();
int64_t
curMs
=
taosGetTimestampMs
();
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
b13c31c9
...
@@ -433,7 +433,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -433,7 +433,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
case
HEARTBEAT_KEY_STBINFO
:
{
case
HEARTBEAT_KEY_STBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTable
Meta
Version
),
&
rspMsg
,
&
rspLen
);
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
SKv
kv1
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
SKv
kv1
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
taosArrayPush
(
hbRsp
.
info
,
&
kv1
);
taosArrayPush
(
hbRsp
.
info
,
&
kv1
);
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
b13c31c9
...
@@ -532,6 +532,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -532,6 +532,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
SStreamObj
streamObj
=
{
0
};
SStreamObj
streamObj
=
{
0
};
tstrncpy
(
streamObj
.
name
,
pCreate
->
name
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
name
,
pCreate
->
name
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
sourceDb
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
sourceDb
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
targetDb
,
streamObj
.
sourceDb
,
TSDB_DB_FNAME_LEN
);
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
...
@@ -899,18 +900,31 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
...
@@ -899,18 +900,31 @@ static int32_t mndGetSma(SMnode *pMnode, SUserIndexReq *indexReq, SUserIndexRsp
return
code
;
return
code
;
}
}
static
int32_t
mndGetTableSma
(
SMnode
*
pMnode
,
STableIndexReq
*
indexReq
,
STableIndexRsp
*
rsp
,
bool
*
exist
)
{
int32_t
mndGetTableSma
(
SMnode
*
pMnode
,
char
*
tbFName
,
STableIndexRsp
*
rsp
,
bool
*
exist
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SSmaObj
*
pSma
=
NULL
;
SSmaObj
*
pSma
=
NULL
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
STableIndexInfo
info
;
STableIndexInfo
info
;
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
NULL
==
pStb
)
{
*
exist
=
false
;
return
TSDB_CODE_SUCCESS
;
}
strcpy
(
rsp
->
dbFName
,
pStb
->
db
);
strcpy
(
rsp
->
tbName
,
pStb
->
name
+
strlen
(
pStb
->
db
)
+
1
);
rsp
->
suid
=
pStb
->
uid
;
rsp
->
version
=
pStb
->
smaVer
;
mndReleaseStb
(
pMnode
,
pStb
);
while
(
1
)
{
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_SMA
,
pIter
,
(
void
**
)
&
pSma
);
pIter
=
sdbFetch
(
pSdb
,
SDB_SMA
,
pIter
,
(
void
**
)
&
pSma
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pSma
->
stb
[
0
]
!=
indexReq
->
tbFName
[
0
]
||
strcmp
(
pSma
->
stb
,
indexReq
->
tbFName
))
{
if
(
pSma
->
stb
[
0
]
!=
tbFName
[
0
]
||
strcmp
(
pSma
->
stb
,
tbFName
))
{
continue
;
continue
;
}
}
...
@@ -1022,7 +1036,7 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
...
@@ -1022,7 +1036,7 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
code
=
mndGetTableSma
(
pMnode
,
&
indexReq
,
&
rsp
,
&
exist
);
code
=
mndGetTableSma
(
pMnode
,
indexReq
.
tbFName
,
&
rsp
,
&
exist
);
if
(
code
)
{
if
(
code
)
{
goto
_OVER
;
goto
_OVER
;
}
}
...
@@ -1114,4 +1128,4 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
...
@@ -1114,4 +1128,4 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
static
void
mndCancelGetNextSma
(
SMnode
*
pMnode
,
void
*
pIter
)
{
static
void
mndCancelGetNextSma
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
}
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
b13c31c9
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "mndSma.h"
#include "tname.h"
#include "tname.h"
#define STB_VER_NUMBER 1
#define STB_VER_NUMBER 1
...
@@ -1271,7 +1272,7 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
...
@@ -1271,7 +1272,7 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
return
0
;
return
0
;
}
}
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
)
{
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
,
int32_t
*
smaVer
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
dbFName
,
tbName
);
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
dbFName
,
tbName
);
...
@@ -1288,6 +1289,10 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
...
@@ -1288,6 +1289,10 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
return
-
1
;
return
-
1
;
}
}
if
(
smaVer
)
{
*
smaVer
=
pStb
->
smaVer
;
}
int32_t
code
=
mndBuildStbSchemaImp
(
pDb
,
pStb
,
tbName
,
pRsp
);
int32_t
code
=
mndBuildStbSchemaImp
(
pDb
,
pStb
,
tbName
,
pRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
...
@@ -1634,7 +1639,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
...
@@ -1634,7 +1639,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
}
}
}
else
{
}
else
{
mDebug
(
"stb:%s.%s, start to retrieve meta"
,
infoReq
.
dbFName
,
infoReq
.
tbName
);
mDebug
(
"stb:%s.%s, start to retrieve meta"
,
infoReq
.
dbFName
,
infoReq
.
tbName
);
if
(
mndBuildStbSchema
(
pMnode
,
infoReq
.
dbFName
,
infoReq
.
tbName
,
&
metaRsp
)
!=
0
)
{
if
(
mndBuildStbSchema
(
pMnode
,
infoReq
.
dbFName
,
infoReq
.
tbName
,
&
metaRsp
,
NULL
)
!=
0
)
{
goto
_OVER
;
goto
_OVER
;
}
}
}
}
...
@@ -1667,51 +1672,86 @@ _OVER:
...
@@ -1667,51 +1672,86 @@ _OVER:
return
code
;
return
code
;
}
}
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTable
Meta
Version
*
pStbVersions
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableVersion
*
pStbVersions
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
)
{
int32_t
*
pRspLen
)
{
S
TableMetaBatchRsp
batchMeta
Rsp
=
{
0
};
S
STbHbRsp
hb
Rsp
=
{
0
};
batchMetaRsp
.
pArray
=
taosArrayInit
(
numOfStbs
,
sizeof
(
STableMetaRsp
));
hbRsp
.
pMetaRsp
=
taosArrayInit
(
numOfStbs
,
sizeof
(
STableMetaRsp
));
if
(
batchMetaRsp
.
pArray
==
NULL
)
{
if
(
hbRsp
.
pMetaRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
hbRsp
.
pIndexRsp
=
taosArrayInit
(
numOfStbs
,
sizeof
(
STableIndexRsp
));
if
(
NULL
==
hbRsp
.
pIndexRsp
)
{
taosArrayDestroy
(
hbRsp
.
pMetaRsp
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfStbs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfStbs
;
++
i
)
{
SSTable
Meta
Version
*
pStbVersion
=
&
pStbVersions
[
i
];
SSTableVersion
*
pStbVersion
=
&
pStbVersions
[
i
];
pStbVersion
->
suid
=
be64toh
(
pStbVersion
->
suid
);
pStbVersion
->
suid
=
be64toh
(
pStbVersion
->
suid
);
pStbVersion
->
sversion
=
ntohs
(
pStbVersion
->
sversion
);
pStbVersion
->
sversion
=
ntohs
(
pStbVersion
->
sversion
);
pStbVersion
->
tversion
=
ntohs
(
pStbVersion
->
tversion
);
pStbVersion
->
tversion
=
ntohs
(
pStbVersion
->
tversion
);
pStbVersion
->
smaVer
=
ntohl
(
pStbVersion
->
smaVer
);
STableMetaRsp
metaRsp
=
{
0
};
STableMetaRsp
metaRsp
=
{
0
};
int32_t
smaVer
=
0
;
mDebug
(
"stb:%s.%s, start to retrieve meta"
,
pStbVersion
->
dbFName
,
pStbVersion
->
stbName
);
mDebug
(
"stb:%s.%s, start to retrieve meta"
,
pStbVersion
->
dbFName
,
pStbVersion
->
stbName
);
if
(
mndBuildStbSchema
(
pMnode
,
pStbVersion
->
dbFName
,
pStbVersion
->
stbName
,
&
metaRsp
)
!=
0
)
{
if
(
mndBuildStbSchema
(
pMnode
,
pStbVersion
->
dbFName
,
pStbVersion
->
stbName
,
&
metaRsp
,
&
smaVer
)
!=
0
)
{
metaRsp
.
numOfColumns
=
-
1
;
metaRsp
.
numOfColumns
=
-
1
;
metaRsp
.
suid
=
pStbVersion
->
suid
;
metaRsp
.
suid
=
pStbVersion
->
suid
;
taosArrayPush
(
hbRsp
.
pMetaRsp
,
&
metaRsp
);
continue
;
}
}
if
(
pStbVersion
->
sversion
!=
metaRsp
.
sversion
||
pStbVersion
->
tversion
!=
metaRsp
.
tversion
)
{
if
(
pStbVersion
->
sversion
!=
metaRsp
.
sversion
||
pStbVersion
->
tversion
!=
metaRsp
.
tversion
)
{
taosArrayPush
(
batchMetaRsp
.
pArray
,
&
metaRsp
);
taosArrayPush
(
hbRsp
.
pMetaRsp
,
&
metaRsp
);
}
else
{
}
else
{
tFreeSTableMetaRsp
(
&
metaRsp
);
tFreeSTableMetaRsp
(
&
metaRsp
);
}
}
if
(
pStbVersion
->
smaVer
&&
pStbVersion
->
smaVer
!=
smaVer
)
{
bool
exist
=
false
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
STableIndexRsp
indexRsp
=
{
0
};
indexRsp
.
pIndex
=
taosArrayInit
(
10
,
sizeof
(
STableIndexInfo
));
if
(
NULL
==
indexRsp
.
pIndex
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
sprintf
(
tbFName
,
"%s.%s"
,
pStbVersion
->
dbFName
,
pStbVersion
->
stbName
);
int32_t
code
=
mndGetTableSma
(
pMnode
,
tbFName
,
&
indexRsp
,
&
exist
);
if
(
code
||
!
exist
)
{
indexRsp
.
suid
=
pStbVersion
->
suid
;
indexRsp
.
version
=
-
1
;
indexRsp
.
pIndex
=
NULL
;
}
strcpy
(
indexRsp
.
dbFName
,
pStbVersion
->
dbFName
);
strcpy
(
indexRsp
.
tbName
,
pStbVersion
->
stbName
);
taosArrayPush
(
hbRsp
.
pIndexRsp
,
&
indexRsp
);
}
}
}
int32_t
rspLen
=
tSerializeS
TableMetaBatchRsp
(
NULL
,
0
,
&
batchMeta
Rsp
);
int32_t
rspLen
=
tSerializeS
STbHbRsp
(
NULL
,
0
,
&
hb
Rsp
);
if
(
rspLen
<
0
)
{
if
(
rspLen
<
0
)
{
tFreeS
TableMetaBatchRsp
(
&
batchMeta
Rsp
);
tFreeS
STbHbRsp
(
&
hb
Rsp
);
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
return
-
1
;
}
}
void
*
pRsp
=
taosMemoryMalloc
(
rspLen
);
void
*
pRsp
=
taosMemoryMalloc
(
rspLen
);
if
(
pRsp
==
NULL
)
{
if
(
pRsp
==
NULL
)
{
tFreeS
TableMetaBatchRsp
(
&
batchMeta
Rsp
);
tFreeS
STbHbRsp
(
&
hb
Rsp
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
tSerializeS
TableMetaBatchRsp
(
pRsp
,
rspLen
,
&
batchMeta
Rsp
);
tSerializeS
STbHbRsp
(
pRsp
,
rspLen
,
&
hb
Rsp
);
tFreeS
TableMetaBatchRsp
(
&
batchMeta
Rsp
);
tFreeS
STbHbRsp
(
&
hb
Rsp
);
*
ppRsp
=
pRsp
;
*
ppRsp
=
pRsp
;
*
pRspLen
=
rspLen
;
*
pRspLen
=
rspLen
;
return
0
;
return
0
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
b13c31c9
...
@@ -188,15 +188,15 @@ int32_t mndInitSync(SMnode *pMnode) {
...
@@ -188,15 +188,15 @@ int32_t mndInitSync(SMnode *pMnode) {
syncInfo
.
isStandBy
=
pMgmt
->
standby
;
syncInfo
.
isStandBy
=
pMgmt
->
standby
;
syncInfo
.
snapshotEnable
=
true
;
syncInfo
.
snapshotEnable
=
true
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
mInfo
(
"start to open mnode sync, standby:%d"
,
pMgmt
->
standby
)
;
pCfg
->
replicaNum
=
pMnode
->
replica
;
if
(
pMgmt
->
standby
||
pMgmt
->
replica
.
id
>
0
)
{
pCfg
->
myIndex
=
pMnode
->
selfIndex
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
mInfo
(
"start to open mnode sync, replica:%d myindex:%d standby:%d"
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
,
pMgmt
->
standby
)
;
pCfg
->
replicaNum
=
1
;
for
(
int32_t
i
=
0
;
i
<
pMnode
->
replica
;
++
i
)
{
pCfg
->
myIndex
=
0
;
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
0
];
tstrncpy
(
pNode
->
nodeFqdn
,
pM
node
->
replicas
[
i
]
.
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
tstrncpy
(
pNode
->
nodeFqdn
,
pM
gmt
->
replica
.
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
pNode
->
nodePort
=
pM
node
->
replicas
[
i
]
.
port
;
pNode
->
nodePort
=
pM
gmt
->
replica
.
port
;
mInfo
(
"
index:%d, fqdn:%s port:%d"
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
mInfo
(
"
fqdn:%s port:%u"
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
}
}
tsem_init
(
&
pMgmt
->
syncSem
,
0
,
0
);
tsem_init
(
&
pMgmt
->
syncSem
,
0
,
0
);
...
@@ -236,7 +236,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -236,7 +236,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
tsem_wait
(
&
pMgmt
->
syncSem
);
tsem_wait
(
&
pMgmt
->
syncSem
);
}
else
if
(
code
==
TAOS_SYNC_PROPOSE_NOT_LEADER
)
{
}
else
if
(
code
==
TAOS_SYNC_PROPOSE_NOT_LEADER
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
else
if
(
code
==
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
)
{
}
else
if
(
code
==
TAOS_SYNC_OTHER_ERROR
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
else
{
}
else
{
terrno
=
TSDB_CODE_APP_ERROR
;
terrno
=
TSDB_CODE_APP_ERROR
;
...
@@ -254,13 +254,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -254,13 +254,16 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
void
mndSyncStart
(
SMnode
*
pMnode
)
{
void
mndSyncStart
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
syncSetMsgCb
(
pMgmt
->
sync
,
&
pMnode
->
msgCb
);
syncSetMsgCb
(
pMgmt
->
sync
,
&
pMnode
->
msgCb
);
syncStart
(
pMgmt
->
sync
);
mDebug
(
"mnode sync started, id:%"
PRId64
" standby:%d"
,
pMgmt
->
sync
,
pMgmt
->
standby
);
/*
if (pMgmt->standby) {
if (pMgmt->standby) {
syncStartStandBy(pMgmt->sync);
syncStartStandBy(pMgmt->sync);
} else {
} else {
syncStart(pMgmt->sync);
syncStart(pMgmt->sync);
}
}
mDebug
(
"mnode sync started, id:%"
PRId64
" standby:%d"
,
pMgmt
->
sync
,
pMgmt
->
standby
);
*/
}
}
void
mndSyncStop
(
SMnode
*
pMnode
)
{}
void
mndSyncStop
(
SMnode
*
pMnode
)
{}
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
b13c31c9
...
@@ -663,12 +663,23 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
...
@@ -663,12 +663,23 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
void
*
entryKey
=
NULL
,
*
entryVal
=
NULL
;
void
*
entryKey
=
NULL
,
*
entryVal
=
NULL
;
int32_t
nEntryKey
,
nEntryVal
;
int32_t
nEntryKey
,
nEntryVal
;
bool
first
=
true
;
while
(
1
)
{
while
(
1
)
{
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
&
entryKey
,
&
nEntryKey
,
(
const
void
**
)
&
entryVal
,
&
nEntryVal
);
valid
=
tdbTbcGet
(
pCursor
->
pCur
,
(
const
void
**
)
&
entryKey
,
&
nEntryKey
,
(
const
void
**
)
&
entryVal
,
&
nEntryVal
);
if
(
valid
<
0
)
{
if
(
valid
<
0
)
{
break
;
break
;
}
}
STagIdxKey
*
p
=
entryKey
;
STagIdxKey
*
p
=
entryKey
;
if
(
p
->
type
!=
pCursor
->
type
)
{
if
(
first
)
{
valid
=
param
->
reverse
?
tdbTbcMoveToPrev
(
pCursor
->
pCur
)
:
tdbTbcMoveToNext
(
pCursor
->
pCur
);
if
(
valid
<
0
)
break
;
continue
;
}
else
{
break
;
}
}
first
=
false
;
if
(
p
!=
NULL
)
{
if
(
p
!=
NULL
)
{
int32_t
cmp
=
(
*
param
->
filterFunc
)(
p
->
data
,
pKey
->
data
,
pKey
->
type
);
int32_t
cmp
=
(
*
param
->
filterFunc
)(
p
->
data
,
pKey
->
data
,
pKey
->
type
);
if
(
cmp
==
0
)
{
if
(
cmp
==
0
)
{
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
0 → 100644
浏览文件 @
b13c31c9
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sma.h"
#include "tsdb.h"
#define SMA_STORAGE_MINUTES_MAX 86400
#define SMA_STORAGE_MINUTES_DAY 1440
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
/**
* @brief Judge the tsma file split days
*
* @param pCfg
* @param pCont
* @param contLen
* @param days unit is minute
* @return int32_t
*/
int32_t
tdProcessTSmaGetDaysImpl
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
SDecoder
coder
=
{
0
};
tDecoderInit
(
&
coder
,
pCont
,
contLen
);
STSma
tsma
=
{
0
};
if
(
tDecodeSVCreateTSmaReq
(
&
coder
,
&
tsma
)
<
0
)
{
terrno
=
TSDB_CODE_MSG_DECODE_ERROR
;
goto
_err
;
}
STsdbCfg
*
pTsdbCfg
=
&
pCfg
->
tsdbCfg
;
int64_t
sInterval
=
convertTimeFromPrecisionToUnit
(
tsma
.
interval
,
pTsdbCfg
->
precision
,
TIME_UNIT_SECOND
);
if
(
sInterval
<=
0
)
{
*
days
=
pTsdbCfg
->
days
;
return
0
;
}
int64_t
records
=
pTsdbCfg
->
days
*
60
/
sInterval
;
if
(
records
>=
SMA_STORAGE_SPLIT_FACTOR
)
{
*
days
=
pTsdbCfg
->
days
;
}
else
{
int64_t
mInterval
=
convertTimeFromPrecisionToUnit
(
tsma
.
interval
,
pTsdbCfg
->
precision
,
TIME_UNIT_MINUTE
);
int64_t
daysPerFile
=
mInterval
*
SMA_STORAGE_MINUTES_DAY
*
2
;
if
(
daysPerFile
>
SMA_STORAGE_MINUTES_MAX
)
{
*
days
=
SMA_STORAGE_MINUTES_MAX
;
}
else
{
*
days
=
(
int32_t
)
daysPerFile
;
}
if
(
*
days
<
pTsdbCfg
->
days
)
{
*
days
=
pTsdbCfg
->
days
;
}
}
tDecoderClear
(
&
coder
);
return
0
;
_err:
tDecoderClear
(
&
coder
);
return
-
1
;
}
/**
* @brief create tsma meta and result stable
*
* @param pSma
* @param version
* @param pMsg
* @return int32_t
*/
int32_t
tdProcessTSmaCreateImpl
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
pMsg
)
{
SSmaCfg
*
pCfg
=
(
SSmaCfg
*
)
pMsg
;
if
(
TD_VID
(
pSma
->
pVnode
)
==
pCfg
->
dstVgId
)
{
// create tsma meta in dstVgId
if
(
metaCreateTSma
(
SMA_META
(
pSma
),
version
,
pCfg
)
<
0
)
{
return
-
1
;
}
// create stable to save tsma result in dstVgId
SVCreateStbReq
pReq
=
{
0
};
pReq
.
name
=
pCfg
->
dstTbName
;
pReq
.
suid
=
pCfg
->
dstTbUid
;
pReq
.
schemaRow
=
pCfg
->
schemaRow
;
pReq
.
schemaTag
=
pCfg
->
schemaTag
;
if
(
metaCreateSTable
(
SMA_META
(
pSma
),
version
,
&
pReq
)
<
0
)
{
return
-
1
;
}
}
return
0
;
}
/**
* @brief Insert/Update Time-range-wise SMA data.
*
* @param pSma
* @param msg
* @return int32_t
*/
int32_t
tdProcessTSmaInsertImpl
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
const
SArray
*
pDataBlocks
=
(
const
SArray
*
)
msg
;
// TODO: destroy SSDataBlocks(msg)
if
(
!
pDataBlocks
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PTR
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is NULL"
,
SMA_VID
(
pSma
));
return
terrno
;
}
if
(
taosArrayGetSize
(
pDataBlocks
)
<=
0
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PARA
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is empty"
,
SMA_VID
(
pSma
));
return
TSDB_CODE_FAILED
;
}
if
(
tdCheckAndInitSmaEnv
(
pSma
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
0
)
{
terrno
=
TSDB_CODE_TSMA_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
}
SSmaEnv
*
pEnv
=
SMA_TSMA_ENV
(
pSma
);
SSmaStat
*
pStat
=
NULL
;
SSmaStatItem
*
pItem
=
NULL
;
if
(
!
pEnv
||
!
(
pStat
=
SMA_ENV_STAT
(
pEnv
)))
{
terrno
=
TSDB_CODE_TSMA_INVALID_STAT
;
return
TSDB_CODE_FAILED
;
}
tdRefSmaStat
(
pSma
,
pStat
);
pItem
=
&
pStat
->
tsmaStatItem
;
ASSERT
(
pItem
);
if
(
!
pItem
->
pTSma
)
{
// cache smaMeta
STSma
*
pTSma
=
metaGetSmaInfoByIndex
(
SMA_META
(
pSma
),
indexUid
);
if
(
!
pTSma
)
{
terrno
=
TSDB_CODE_TSMA_NO_INDEX_IN_META
;
smaWarn
(
"vgId:%d, tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
}
pItem
->
pTSma
=
pTSma
;
}
STSma
*
pTSma
=
pItem
->
pTSma
;
ASSERT
(
pTSma
->
indexUid
==
indexUid
);
SMetaReader
mr
=
{
0
};
const
char
*
dbName
=
"testDb"
;
if
(
metaGetTableEntryByName
(
&
mr
,
dbName
)
!=
0
)
{
smaDebug
(
"vgId:%d, tsma no table testTb exists for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
SVCreateStbReq
pReq
=
{
0
};
pReq
.
name
=
dbName
;
pReq
.
suid
=
pTSma
->
dstTbUid
;
pReq
.
schemaRow
=
pCfg
->
schemaRow
;
pReq
.
schemaTag
=
pCfg
->
schemaTag
;
}
SSubmitReq
*
pSubmitReq
=
NULL
;
buildSubmitReqFromDataBlock
(
&
pSubmitReq
,
(
const
SArray
*
)
msg
,
NULL
,
pItem
->
pTSma
->
dstVgId
,
pItem
->
pTSma
->
dstTbUid
);
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
b13c31c9
...
@@ -110,6 +110,8 @@ int32_t tsdbBegin(STsdb *pTsdb) {
...
@@ -110,6 +110,8 @@ int32_t tsdbBegin(STsdb *pTsdb) {
}
}
int32_t
tsdbCommit
(
STsdb
*
pTsdb
)
{
int32_t
tsdbCommit
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SCommitH
commith
=
{
0
};
SCommitH
commith
=
{
0
};
SDFileSet
*
pSet
=
NULL
;
SDFileSet
*
pSet
=
NULL
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
b13c31c9
...
@@ -20,6 +20,7 @@ extern const char *TSDB_LEVEL_DNAME[];
...
@@ -20,6 +20,7 @@ extern const char *TSDB_LEVEL_DNAME[];
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
static
const
char
*
tsdbTxnFname
[]
=
{
"current.t"
,
"current"
};
static
const
char
*
tsdbTxnFname
[]
=
{
"current.t"
,
"current"
};
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
#define TSDB_MAX_INIT_FSETS (365000)
static
int
tsdbComparFidFSet
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbComparFidFSet
(
const
void
*
arg1
,
const
void
*
arg2
);
static
void
tsdbResetFSStatus
(
SFSStatus
*
pStatus
);
static
void
tsdbResetFSStatus
(
SFSStatus
*
pStatus
);
...
@@ -210,6 +211,10 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) {
...
@@ -210,6 +211,10 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) {
return
NULL
;
return
NULL
;
}
}
if
(
maxFSet
>
TSDB_MAX_INIT_FSETS
)
{
maxFSet
=
TSDB_MAX_INIT_FSETS
;
}
pfs
->
cstatus
=
tsdbNewFSStatus
(
maxFSet
);
pfs
->
cstatus
=
tsdbNewFSStatus
(
maxFSet
);
if
(
pfs
->
cstatus
==
NULL
)
{
if
(
pfs
->
cstatus
==
NULL
)
{
tsdbFreeFS
(
pfs
);
tsdbFreeFS
(
pfs
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
b13c31c9
...
@@ -289,7 +289,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
...
@@ -289,7 +289,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
}
}
int32_t
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int32_t
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int32_t
ret
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
int32_t
ret
=
TAOS_SYNC_OTHER_ERROR
;
if
(
syncEnvIsStart
())
{
if
(
syncEnvIsStart
())
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
...
@@ -370,13 +370,13 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -370,13 +370,13 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
else
{
}
else
{
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
ret
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
ret
=
TAOS_SYNC_OTHER_ERROR
;
}
}
syncNodeRelease
(
pSyncNode
);
syncNodeRelease
(
pSyncNode
);
}
else
{
}
else
{
vError
(
"==vnodeProcessSyncReq== error syncEnv stop"
);
vError
(
"==vnodeProcessSyncReq== error syncEnv stop"
);
ret
=
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
ret
=
TAOS_SYNC_OTHER_ERROR
;
}
}
return
ret
;
return
ret
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
b13c31c9
...
@@ -283,11 +283,14 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
...
@@ -283,11 +283,14 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
syncSetMsgCb
(
pVnode
->
sync
,
&
pVnode
->
msgCb
);
syncSetMsgCb
(
pVnode
->
sync
,
&
pVnode
->
msgCb
);
syncStart
(
pVnode
->
sync
);
/*
if (pVnode->config.standby) {
if (pVnode->config.standby) {
syncStartStandBy(pVnode->sync);
syncStartStandBy(pVnode->sync);
} else {
} else {
syncStart(pVnode->sync);
syncStart(pVnode->sync);
}
}
*/
}
}
void
vnodeSyncClose
(
SVnode
*
pVnode
)
{
syncStop
(
pVnode
->
sync
);
}
void
vnodeSyncClose
(
SVnode
*
pVnode
)
{
syncStop
(
pVnode
->
sync
);
}
source/libs/catalog/inc/catalogInt.h
浏览文件 @
b13c31c9
...
@@ -57,6 +57,8 @@ enum {
...
@@ -57,6 +57,8 @@ enum {
CTG_OP_DROP_TB_META
,
CTG_OP_DROP_TB_META
,
CTG_OP_UPDATE_USER
,
CTG_OP_UPDATE_USER
,
CTG_OP_UPDATE_VG_EPSET
,
CTG_OP_UPDATE_VG_EPSET
,
CTG_OP_UPDATE_TB_INDEX
,
CTG_OP_DROP_TB_INDEX
,
CTG_OP_MAX
CTG_OP_MAX
};
};
...
@@ -128,25 +130,33 @@ typedef struct SCtgUserCtx {
...
@@ -128,25 +130,33 @@ typedef struct SCtgUserCtx {
SUserAuthInfo
user
;
SUserAuthInfo
user
;
}
SCtgUserCtx
;
}
SCtgUserCtx
;
typedef
struct
SCtgTbMetaCache
{
typedef
STableIndexRsp
STableIndex
;
SRWLatch
stbLock
;
SRWLatch
metaLock
;
// RC between cache destroy and all other operations
SHashObj
*
metaCache
;
//key:tbname, value:STableMeta
SHashObj
*
stbCache
;
//key:suid, value:STableMeta*
}
SCtgTbMetaCache
;
typedef
struct
SCtgDBCache
{
typedef
struct
SCtgTbCache
{
SRWLatch
metaLock
;
STableMeta
*
pMeta
;
SRWLatch
indexLock
;
STableIndex
*
pIndex
;
}
SCtgTbCache
;
typedef
struct
SCtgVgCache
{
SRWLatch
vgLock
;
SRWLatch
vgLock
;
SDBVgInfo
*
vgInfo
;
}
SCtgVgCache
;
typedef
struct
SCtgDBCache
{
SRWLatch
dbLock
;
// RC between destroy tbCache/stbCache and all reads
uint64_t
dbId
;
uint64_t
dbId
;
int8_t
deleted
;
int8_t
deleted
;
SDBVgInfo
*
vgInfo
;
SCtgVgCache
vgCache
;
SCtgTbMetaCache
tbCache
;
SHashObj
*
tbCache
;
// key:tbname, value:SCtgTbCache
SHashObj
*
stbCache
;
// key:suid, value:STableMeta*
}
SCtgDBCache
;
}
SCtgDBCache
;
typedef
struct
SCtgRentSlot
{
typedef
struct
SCtgRentSlot
{
SRWLatch
lock
;
SRWLatch
lock
;
bool
needSort
;
bool
needSort
;
SArray
*
meta
;
// element is SDbVgVersion or SSTable
Meta
Version
SArray
*
meta
;
// element is SDbVgVersion or SSTableVersion
}
SCtgRentSlot
;
}
SCtgRentSlot
;
typedef
struct
SCtgRentMgmt
{
typedef
struct
SCtgRentMgmt
{
...
@@ -245,8 +255,10 @@ typedef struct SCtgCacheStat {
...
@@ -245,8 +255,10 @@ typedef struct SCtgCacheStat {
uint64_t
userNum
;
uint64_t
userNum
;
uint64_t
vgHitNum
;
uint64_t
vgHitNum
;
uint64_t
vgMissNum
;
uint64_t
vgMissNum
;
uint64_t
tblHitNum
;
uint64_t
tbMetaHitNum
;
uint64_t
tblMissNum
;
uint64_t
tbMetaMissNum
;
uint64_t
tbIndexHitNum
;
uint64_t
tbIndexMissNum
;
uint64_t
userHitNum
;
uint64_t
userHitNum
;
uint64_t
userMissNum
;
uint64_t
userMissNum
;
}
SCtgCacheStat
;
}
SCtgCacheStat
;
...
@@ -268,10 +280,10 @@ typedef struct SCtgUpdateVgMsg {
...
@@ -268,10 +280,10 @@ typedef struct SCtgUpdateVgMsg {
SDBVgInfo
*
dbInfo
;
SDBVgInfo
*
dbInfo
;
}
SCtgUpdateVgMsg
;
}
SCtgUpdateVgMsg
;
typedef
struct
SCtgUpdateTb
l
Msg
{
typedef
struct
SCtgUpdateTb
Meta
Msg
{
SCatalog
*
pCtg
;
SCatalog
*
pCtg
;
STableMetaOutput
*
output
;
STableMetaOutput
*
pMeta
;
}
SCtgUpdateTb
l
Msg
;
}
SCtgUpdateTb
Meta
Msg
;
typedef
struct
SCtgDropDBMsg
{
typedef
struct
SCtgDropDBMsg
{
SCatalog
*
pCtg
;
SCatalog
*
pCtg
;
...
@@ -305,6 +317,17 @@ typedef struct SCtgUpdateUserMsg {
...
@@ -305,6 +317,17 @@ typedef struct SCtgUpdateUserMsg {
SGetUserAuthRsp
userAuth
;
SGetUserAuthRsp
userAuth
;
}
SCtgUpdateUserMsg
;
}
SCtgUpdateUserMsg
;
typedef
struct
SCtgUpdateTbIndexMsg
{
SCatalog
*
pCtg
;
STableIndex
*
pIndex
;
}
SCtgUpdateTbIndexMsg
;
typedef
struct
SCtgDropTbIndexMsg
{
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
tbName
[
TSDB_TABLE_NAME_LEN
];
}
SCtgDropTbIndexMsg
;
typedef
struct
SCtgUpdateEpsetMsg
{
typedef
struct
SCtgUpdateEpsetMsg
{
SCatalog
*
pCtg
;
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
@@ -465,12 +488,11 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *action);
...
@@ -465,12 +488,11 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *action);
int32_t
ctgOpUpdateEpset
(
SCtgCacheOperation
*
operation
);
int32_t
ctgOpUpdateEpset
(
SCtgCacheOperation
*
operation
);
int32_t
ctgAcquireVgInfoFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
);
int32_t
ctgAcquireVgInfoFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
);
void
ctgReleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
);
void
ctgReleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
);
void
ctgReleaseVgInfo
(
SCtgDBCache
*
dbCache
);
void
ctgRUnlockVgInfo
(
SCtgDBCache
*
dbCache
);
int32_t
ctgAcquireVgInfoFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
);
int32_t
ctgTbMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
);
int32_t
ctgTbMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
);
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgReadTbVerFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
int32_t
*
sver
,
int32_t
*
tver
,
int32_t
*
tbType
,
uint64_t
*
suid
,
char
*
stbName
);
int32_t
ctgReadTbVerFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
int32_t
*
sver
,
int32_t
*
tver
,
int32_t
*
tbType
,
uint64_t
*
suid
,
char
*
stbName
);
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
c
onst
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
);
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
c
har
*
user
,
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
);
int32_t
ctgDropDbCacheEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
);
int32_t
ctgDropDbCacheEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
);
int32_t
ctgDropDbVgroupEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
bool
syncReq
);
int32_t
ctgDropDbVgroupEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
bool
syncReq
);
int32_t
ctgDropStbMetaEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
stbName
,
uint64_t
suid
,
bool
syncReq
);
int32_t
ctgDropStbMetaEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
stbName
,
uint64_t
suid
,
bool
syncReq
);
...
@@ -479,12 +501,18 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
...
@@ -479,12 +501,18 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
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
);
int32_t
ctgUpdateTbIndexEnqueue
(
SCatalog
*
pCtg
,
STableIndex
**
pIndex
,
bool
syncOp
);
int32_t
ctgMetaRentInit
(
SCtgRentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
);
int32_t
ctgMetaRentInit
(
SCtgRentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
);
int32_t
ctgMetaRentAdd
(
SCtgRentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
);
int32_t
ctgMetaRentAdd
(
SCtgRentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
);
int32_t
ctgMetaRentGet
(
SCtgRentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
);
int32_t
ctgMetaRentGet
(
SCtgRentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
);
int32_t
ctgUpdateTbMetaToCache
(
SCatalog
*
pCtg
,
STableMetaOutput
*
pOut
,
bool
syncReq
);
int32_t
ctgUpdateTbMetaToCache
(
SCatalog
*
pCtg
,
STableMetaOutput
*
pOut
,
bool
syncReq
);
int32_t
ctgStartUpdateThread
();
int32_t
ctgStartUpdateThread
();
int32_t
ctgRelaunchGetTbMetaTask
(
SCtgTask
*
pTask
);
int32_t
ctgRelaunchGetTbMetaTask
(
SCtgTask
*
pTask
);
void
ctgReleaseVgInfoToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
);
int32_t
ctgReadTbIndexFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
ctgDropTbIndexEnqueue
(
SCatalog
*
pCtg
,
SName
*
pName
,
bool
syncOp
);
int32_t
ctgOpDropTbIndex
(
SCtgCacheOperation
*
operation
);
int32_t
ctgOpUpdateTbIndex
(
SCtgCacheOperation
*
operation
);
...
@@ -493,7 +521,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
...
@@ -493,7 +521,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
int32_t
ctgGetQnodeListFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetQnodeListFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetDBCfgFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetDBCfgFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetIndexInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetIndexInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
indexName
,
SIndexInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbIndexFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
name
,
SArray
*
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbIndexFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
name
,
STableIndex
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUdfInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUdfInfoFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUserDbAuthFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
SGetUserAuthRsp
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetUserDbAuthFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
SGetUserAuthRsp
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
...
@@ -521,6 +549,8 @@ void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
...
@@ -521,6 +549,8 @@ 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
);
char
*
ctgTaskTypeStr
(
CTG_TASK_TYPE
type
);
char
*
ctgTaskTypeStr
(
CTG_TASK_TYPE
type
);
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
SCtgTask
*
pTask
);
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
SCtgTask
*
pTask
);
int32_t
ctgCloneTableIndex
(
SArray
*
pIndex
,
SArray
**
pRes
);
void
ctgFreeSTableIndex
(
void
*
info
);
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
b13c31c9
...
@@ -96,8 +96,7 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -96,8 +96,7 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
if
(
NULL
!=
dbCache
)
{
if
(
NULL
!=
dbCache
)
{
input
.
dbId
=
dbCache
->
dbId
;
input
.
dbId
=
dbCache
->
dbId
;
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
input
.
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
input
.
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
...
@@ -349,8 +348,8 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, co
...
@@ -349,8 +348,8 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, co
int32_t
code
=
0
;
int32_t
code
=
0
;
*
pass
=
false
;
*
pass
=
false
;
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
user
,
dbFName
,
type
,
&
inCache
,
pass
));
CTG_ERR_RET
(
ctgChkAuthFromCache
(
pCtg
,
(
char
*
)
user
,
(
char
*
)
dbFName
,
type
,
&
inCache
,
pass
));
if
(
inCache
)
{
if
(
inCache
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -382,6 +381,45 @@ _return:
...
@@ -382,6 +381,45 @@ _return:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTbIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pRes
)
{
CTG_ERR_RET
(
ctgReadTbIndexFromCache
(
pCtg
,
pTableName
,
pRes
));
if
(
*
pRes
)
{
return
TSDB_CODE_SUCCESS
;
}
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
if
(
NULL
==
pIndex
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
int32_t
code
=
ctgGetTbIndexFromMnode
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pIndex
,
NULL
);
if
(
TSDB_CODE_MND_DB_INDEX_NOT_EXIST
==
code
)
{
code
=
0
;
goto
_return
;
}
CTG_ERR_JRET
(
code
);
SArray
*
pInfo
=
NULL
;
CTG_ERR_JRET
(
ctgCloneTableIndex
(
pIndex
->
pIndex
,
&
pInfo
));
*
pRes
=
pInfo
;
CTG_ERR_JRET
(
ctgUpdateTbIndexEnqueue
(
pCtg
,
&
pIndex
,
false
));
return
TSDB_CODE_SUCCESS
;
_return:
tFreeSTableIndexRsp
(
pIndex
);
taosMemoryFree
(
pIndex
);
taosArrayDestroyEx
(
*
pRes
,
tFreeSTableIndexInfo
);
*
pRes
=
NULL
;
CTG_RET
(
code
);
}
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
int32_t
ctgGetTbDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
pTableName
,
SArray
**
pVgList
)
{
STableMeta
*
tbMeta
=
NULL
;
STableMeta
*
tbMeta
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -404,7 +442,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
...
@@ -404,7 +442,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgInfo
->
vgHash
;
vgHash
=
dbCache
->
vg
Cache
.
vg
Info
->
vgHash
;
}
else
{
}
else
{
vgHash
=
vgInfo
->
vgHash
;
vgHash
=
vgInfo
->
vgHash
;
}
}
...
@@ -442,7 +480,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
...
@@ -442,7 +480,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTabl
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgR
elease
VgInfo
(
dbCache
);
ctgR
Unlock
VgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
...
@@ -631,12 +669,11 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers
...
@@ -631,12 +669,11 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
*
version
=
dbCache
->
vgInfo
->
vgVersion
;
*
version
=
dbCache
->
vg
Cache
.
vg
Info
->
vgVersion
;
*
dbId
=
dbCache
->
dbId
;
*
dbId
=
dbCache
->
dbId
;
*
tableNum
=
dbCache
->
vgInfo
->
numOfTable
;
*
tableNum
=
dbCache
->
vg
Cache
.
vg
Info
->
numOfTable
;
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"Got db vgVersion from cache, dbFName:%s, vgVersion:%d"
,
dbFName
,
*
version
);
ctgDebug
(
"Got db vgVersion from cache, dbFName:%s, vgVersion:%d"
,
dbFName
,
*
version
);
...
@@ -661,7 +698,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -661,7 +698,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
if
(
dbCache
)
{
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgInfo
->
vgHash
;
vgHash
=
dbCache
->
vg
Cache
.
vg
Info
->
vgHash
;
}
else
{
}
else
{
vgHash
=
vgInfo
->
vgHash
;
vgHash
=
vgInfo
->
vgHash
;
}
}
...
@@ -674,7 +711,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
...
@@ -674,7 +711,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char*
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgR
elease
VgInfo
(
dbCache
);
ctgR
Unlock
VgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
...
@@ -741,6 +778,30 @@ _return:
...
@@ -741,6 +778,30 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
)
{
CTG_API_ENTER
();
int32_t
code
=
0
;
if
(
NULL
==
pCtg
||
NULL
==
pRsp
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
if
(
NULL
==
pIndex
)
{
CTG_API_LEAVE
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
pIndex
,
pRsp
,
sizeof
(
STableIndex
));
CTG_ERR_JRET
(
ctgUpdateTbIndexEnqueue
(
pCtg
,
&
pIndex
,
false
));
_return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -932,12 +993,12 @@ int32_t catalogGetTableHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const
...
@@ -932,12 +993,12 @@ int32_t catalogGetTableHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgInfo
,
pTableName
,
pVgroup
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vg
Cache
.
vg
Info
,
pTableName
,
pVgroup
));
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgR
elease
VgInfo
(
dbCache
);
ctgR
Unlock
VgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
...
@@ -1060,14 +1121,14 @@ _return:
...
@@ -1060,14 +1121,14 @@ _return:
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTable
MetaVersion
**
stables
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTable
Version
**
stables
,
uint32_t
*
num
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
stables
||
NULL
==
num
)
{
if
(
NULL
==
pCtg
||
NULL
==
stables
||
NULL
==
num
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableMeta
Version
)));
CTG_API_LEAVE
(
ctgMetaRentGet
(
&
pCtg
->
stbRent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTable
Version
)));
}
}
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCtg
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
...
@@ -1138,7 +1199,12 @@ int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo *pConn, const SNam
...
@@ -1138,7 +1199,12 @@ int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo *pConn, const SNam
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctgGetTbIndexFromMnode
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pRes
,
NULL
));
int32_t
code
=
0
;
CTG_ERR_JRET
(
ctgGetTbIndex
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pRes
));
_return:
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
b13c31c9
...
@@ -344,6 +344,11 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, SCtgJob *pJob, const SCatalogReq* p
...
@@ -344,6 +344,11 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, SCtgJob *pJob, const SCatalogReq* p
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbIndexNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableIndex
,
i
);
ctgDropTbIndexEnqueue
(
pCtg
,
name
,
true
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -680,15 +685,14 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
...
@@ -680,15 +685,14 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
&
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
&
dbCache
));
if
(
NULL
!=
dbCache
)
{
if
(
NULL
!=
dbCache
)
{
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
vgInfo
=
{
0
};
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vgInfo
,
ctx
->
pName
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vg
Cache
.
vg
Info
,
ctx
->
pName
,
&
vgInfo
));
ctgDebug
(
"will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d"
,
tNameGetTableName
(
ctx
->
pName
),
ctx
->
flag
);
ctgDebug
(
"will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d"
,
tNameGetTableName
(
ctx
->
pName
),
ctx
->
flag
);
ctx
->
vgId
=
vgInfo
.
vgId
;
ctx
->
vgId
=
vgInfo
.
vgId
;
CTG_ERR_JRET
(
ctgGetTbMetaFromVnode
(
pCtg
,
pConn
,
ctx
->
pName
,
&
vgInfo
,
NULL
,
pTask
));
CTG_ERR_JRET
(
ctgGetTbMetaFromVnode
(
pCtg
,
pConn
,
ctx
->
pName
,
&
vgInfo
,
NULL
,
pTask
));
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
else
{
}
else
{
SBuildUseDBInput
input
=
{
0
};
SBuildUseDBInput
input
=
{
0
};
...
@@ -786,7 +790,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
...
@@ -786,7 +790,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgR
elease
VgInfo
(
dbCache
);
ctgR
Unlock
VgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
...
@@ -866,9 +870,15 @@ _return:
...
@@ -866,9 +870,15 @@ _return:
int32_t
ctgHandleGetTbIndexRsp
(
SCtgTask
*
pTask
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
ctgHandleGetTbIndexRsp
(
SCtgTask
*
pTask
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
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
));
TSWAP
(
pTask
->
res
,
pTask
->
msgCtx
.
out
);
STableIndex
*
pOut
=
(
STableIndex
*
)
pTask
->
msgCtx
.
out
;
SArray
*
pInfo
=
NULL
;
CTG_ERR_JRET
(
ctgCloneTableIndex
(
pOut
->
pIndex
,
&
pInfo
));
pTask
->
res
=
pInfo
;
SCtgTbIndexCtx
*
ctx
=
pTask
->
taskCtx
;
CTG_ERR_JRET
(
ctgUpdateTbIndexEnqueue
(
pTask
->
pJob
->
pCtg
,
(
STableIndex
**
)
&
pTask
->
msgCtx
.
out
,
false
));
_return:
_return:
if
(
TSDB_CODE_MND_DB_INDEX_NOT_EXIST
==
code
)
{
if
(
TSDB_CODE_MND_DB_INDEX_NOT_EXIST
==
code
)
{
...
@@ -1008,7 +1018,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
...
@@ -1008,7 +1018,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
&
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
&
dbCache
));
if
(
dbCache
)
{
if
(
dbCache
)
{
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
vgInfo
=
{
0
};
CTG_ERR_RET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vgInfo
,
ctx
->
pName
,
&
vgInfo
));
CTG_ERR_RET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vg
Cache
.
vg
Info
,
ctx
->
pName
,
&
vgInfo
));
ctgDebug
(
"will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d"
,
tNameGetTableName
(
ctx
->
pName
),
ctx
->
flag
);
ctgDebug
(
"will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d"
,
tNameGetTableName
(
ctx
->
pName
),
ctx
->
flag
);
...
@@ -1026,8 +1036,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
...
@@ -1026,8 +1036,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) {
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
...
@@ -1057,7 +1066,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
...
@@ -1057,7 +1066,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
dbCache
));
if
(
NULL
!=
dbCache
)
{
if
(
NULL
!=
dbCache
)
{
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
dbCache
->
vgInfo
->
vgHash
,
(
SArray
**
)
&
pTask
->
res
));
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
dbCache
->
vg
Cache
.
vg
Info
->
vgHash
,
(
SArray
**
)
&
pTask
->
res
));
CTG_ERR_JRET
(
ctgHandleTaskEnd
(
pTask
,
0
));
CTG_ERR_JRET
(
ctgHandleTaskEnd
(
pTask
,
0
));
}
else
{
}
else
{
...
@@ -1072,8 +1081,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
...
@@ -1072,8 +1081,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) {
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
...
@@ -1092,7 +1100,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
...
@@ -1092,7 +1100,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
if
(
NULL
==
pTask
->
res
)
{
if
(
NULL
==
pTask
->
res
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vgInfo
,
pCtx
->
pName
,
(
SVgroupInfo
*
)
pTask
->
res
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vg
Cache
.
vg
Info
,
pCtx
->
pName
,
(
SVgroupInfo
*
)
pTask
->
res
));
CTG_ERR_JRET
(
ctgHandleTaskEnd
(
pTask
,
0
));
CTG_ERR_JRET
(
ctgHandleTaskEnd
(
pTask
,
0
));
}
else
{
}
else
{
...
@@ -1107,8 +1115,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
...
@@ -1107,8 +1115,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) {
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
...
@@ -1119,6 +1126,15 @@ int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) {
...
@@ -1119,6 +1126,15 @@ int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) {
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SCtgTbIndexCtx
*
pCtx
=
(
SCtgTbIndexCtx
*
)
pTask
->
taskCtx
;
SCtgTbIndexCtx
*
pCtx
=
(
SCtgTbIndexCtx
*
)
pTask
->
taskCtx
;
SArray
*
pRes
=
NULL
;
CTG_ERR_RET
(
ctgReadTbIndexFromCache
(
pCtg
,
pCtx
->
pName
,
&
pRes
));
if
(
pRes
)
{
pTask
->
res
=
pRes
;
CTG_ERR_RET
(
ctgHandleTaskEnd
(
pTask
,
0
));
return
TSDB_CODE_SUCCESS
;
}
CTG_ERR_RET
(
ctgGetTbIndexFromMnode
(
pCtg
,
pConn
,
pCtx
->
pName
,
NULL
,
pTask
));
CTG_ERR_RET
(
ctgGetTbIndexFromMnode
(
pCtg
,
pConn
,
pCtx
->
pName
,
NULL
,
pTask
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1157,9 +1173,9 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
...
@@ -1157,9 +1173,9 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
SDbInfo
*
pInfo
=
(
SDbInfo
*
)
pTask
->
res
;
SDbInfo
*
pInfo
=
(
SDbInfo
*
)
pTask
->
res
;
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
dbCache
));
if
(
NULL
!=
dbCache
)
{
if
(
NULL
!=
dbCache
)
{
pInfo
->
vgVer
=
dbCache
->
vgInfo
->
vgVersion
;
pInfo
->
vgVer
=
dbCache
->
vg
Cache
.
vg
Info
->
vgVersion
;
pInfo
->
dbId
=
dbCache
->
dbId
;
pInfo
->
dbId
=
dbCache
->
dbId
;
pInfo
->
tbNum
=
dbCache
->
vgInfo
->
numOfTable
;
pInfo
->
tbNum
=
dbCache
->
vg
Cache
.
vg
Info
->
numOfTable
;
}
else
{
}
else
{
pInfo
->
vgVer
=
CTG_DEFAULT_INVALID_VERSION
;
pInfo
->
vgVer
=
CTG_DEFAULT_INVALID_VERSION
;
}
}
...
@@ -1169,8 +1185,7 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
...
@@ -1169,8 +1185,7 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) {
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
b13c31c9
...
@@ -59,18 +59,27 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {
...
@@ -59,18 +59,27 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {
CTG_OP_UPDATE_VG_EPSET
,
CTG_OP_UPDATE_VG_EPSET
,
"update epset"
,
"update epset"
,
ctgOpUpdateEpset
ctgOpUpdateEpset
}
},
{
CTG_OP_UPDATE_TB_INDEX
,
"update tbIndex"
,
ctgOpUpdateTbIndex
},
{
CTG_OP_DROP_TB_INDEX
,
"drop tbIndex"
,
ctgOpDropTbIndex
}
};
};
int32_t
ctg
Acquire
VgInfo
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
bool
*
inCache
)
{
int32_t
ctg
RLock
VgInfo
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
bool
*
inCache
)
{
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
vgLock
);
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
vg
Cache
.
vg
Lock
);
if
(
dbCache
->
deleted
)
{
if
(
dbCache
->
deleted
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vg
Cache
.
vg
Lock
);
ctgDebug
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
ctgDebug
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
...
@@ -79,8 +88,8 @@ int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) {
...
@@ -79,8 +88,8 @@ int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) {
}
}
if
(
NULL
==
dbCache
->
vgInfo
)
{
if
(
NULL
==
dbCache
->
vg
Cache
.
vg
Info
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vg
Cache
.
vg
Lock
);
*
inCache
=
false
;
*
inCache
=
false
;
ctgDebug
(
"db vgInfo is empty, dbId:%"
PRIx64
,
dbCache
->
dbId
);
ctgDebug
(
"db vgInfo is empty, dbId:%"
PRIx64
,
dbCache
->
dbId
);
...
@@ -92,50 +101,47 @@ int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) {
...
@@ -92,50 +101,47 @@ int32_t ctgAcquireVgInfo(SCatalog *pCtg, SCtgDBCache *dbCache, bool *inCache) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgW
Acquire
VgInfo
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
int32_t
ctgW
Lock
VgInfo
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vg
Cache
.
vg
Lock
);
if
(
dbCache
->
deleted
)
{
if
(
dbCache
->
deleted
)
{
ctgDebug
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
ctgDebug
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vg
Cache
.
vg
Lock
);
CTG_ERR_RET
(
TSDB_CODE_CTG_DB_DROPPED
);
CTG_ERR_RET
(
TSDB_CODE_CTG_DB_DROPPED
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
ctgR
eleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
void
ctgR
UnlockVgInfo
(
SCtgDBCache
*
dbCache
)
{
taosHashRelease
(
pCtg
->
dbCache
,
dbCache
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgCache
.
vgLock
);
}
}
void
ctg
Release
VgInfo
(
SCtgDBCache
*
dbCache
)
{
void
ctg
WUnlock
VgInfo
(
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_
READ
,
&
dbCache
->
vgLock
);
CTG_UNLOCK
(
CTG_
WRITE
,
&
dbCache
->
vgCache
.
vgLock
);
}
}
void
ctg
WReleaseVgInfo
(
SCtgDBCache
*
dbCache
)
{
void
ctg
ReleaseDBCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
CTG_UNLOCK
(
CTG_
WRITE
,
&
dbCache
->
vg
Lock
);
CTG_UNLOCK
(
CTG_
READ
,
&
dbCache
->
db
Lock
);
}
}
int32_t
ctgAcquireDBCacheImpl
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
,
bool
acquire
)
{
int32_t
ctgAcquireDBCacheImpl
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
,
bool
acquire
)
{
char
*
p
=
strchr
(
dbFName
,
'.'
);
char
*
p
=
strchr
(
dbFName
,
'.'
);
if
(
p
&&
CTG_IS_SYS_DBNAME
(
p
+
1
))
{
if
(
p
&&
CTG_IS_SYS_DBNAME
(
p
+
1
))
{
dbFName
=
p
+
1
;
dbFName
=
p
+
1
;
}
}
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
(
SCtgDBCache
*
)
taosHashGet
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
));
if
(
acquire
)
{
dbCache
=
(
SCtgDBCache
*
)
taosHashAcquire
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
));
}
else
{
dbCache
=
(
SCtgDBCache
*
)
taosHashGet
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
));
}
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
*
pCache
=
NULL
;
*
pCache
=
NULL
;
ctgDebug
(
"db not in cache, dbFName:%s"
,
dbFName
);
ctgDebug
(
"db not in cache, dbFName:%s"
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
acquire
)
{
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
dbLock
);
}
if
(
dbCache
->
deleted
)
{
if
(
dbCache
->
deleted
)
{
if
(
acquire
)
{
if
(
acquire
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
...
@@ -159,15 +165,35 @@ int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache)
...
@@ -159,15 +165,35 @@ int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache)
CTG_RET
(
ctgAcquireDBCacheImpl
(
pCtg
,
dbFName
,
pCache
,
false
));
CTG_RET
(
ctgAcquireDBCacheImpl
(
pCtg
,
dbFName
,
pCache
,
false
));
}
}
void
ctgReleaseVgInfoToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
ctgRUnlockVgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
int32_t
ctgAcquireVgInfoFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
)
{
void
ctgReleaseTbMetaToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
SCtgTbCache
*
pCache
)
{
SCtgDBCache
*
dbCache
=
NULL
;
if
(
pCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
}
if
(
NULL
==
pCtg
->
dbCache
)
{
if
(
dbCache
)
{
ctgDebug
(
"empty db cache, dbFName:%s"
,
dbFName
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
goto
_return
;
}
}
}
void
ctgReleaseTbIndexToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
SCtgTbCache
*
pCache
)
{
if
(
pCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
indexLock
);
taosHashRelease
(
dbCache
->
tbCache
,
pCache
);
}
if
(
dbCache
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
}
int32_t
ctgAcquireVgInfoFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
SCtgDBCache
**
pCache
)
{
SCtgDBCache
*
dbCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
ctgDebug
(
"db %s not in cache"
,
dbFName
);
...
@@ -175,7 +201,7 @@ int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCac
...
@@ -175,7 +201,7 @@ int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCac
}
}
bool
inCache
=
false
;
bool
inCache
=
false
;
ctg
Acquire
VgInfo
(
pCtg
,
dbCache
,
&
inCache
);
ctg
RLock
VgInfo
(
pCtg
,
dbCache
,
&
inCache
);
if
(
!
inCache
)
{
if
(
!
inCache
)
{
ctgDebug
(
"vgInfo of db %s not in cache"
,
dbFName
);
ctgDebug
(
"vgInfo of db %s not in cache"
,
dbFName
);
goto
_return
;
goto
_return
;
...
@@ -202,54 +228,160 @@ _return:
...
@@ -202,54 +228,160 @@ _return:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgTbMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
)
{
int32_t
ctgAcquireTbMetaFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
SCtgDBCache
*
dbCache
=
NULL
;
*
exist
=
0
;
SCtgTbCache
*
pCache
=
NULL
;
ctgWarn
(
"empty db cache, dbFName:%s, tbName:%s"
,
dbFName
,
tbName
);
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
return
TSDB_CODE_SUCCESS
;
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
goto
_return
;
}
int32_t
sz
=
0
;
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
tbName
,
dbFName
);
goto
_return
;
}
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
if
(
NULL
==
pCache
->
pMeta
)
{
ctgDebug
(
"tb %s meta not in cache, dbFName:%s"
,
tbName
,
dbFName
);
goto
_return
;
}
}
*
pDb
=
dbCache
;
*
pTb
=
pCache
;
ctgDebug
(
"tb %s meta got in cache, dbFName:%s"
,
tbName
,
dbFName
);
CTG_CACHE_STAT_INC
(
tbMetaHitNum
,
1
);
return
TSDB_CODE_SUCCESS
;
_return:
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_CACHE_STAT_INC
(
tbMetaMissNum
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgAcquireStbMetaFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
uint64_t
suid
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
pCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
goto
_return
;
}
int32_t
sz
=
0
;
char
*
stName
=
taosHashAcquire
(
dbCache
->
stbCache
,
&
suid
,
sizeof
(
suid
));
if
(
NULL
==
stName
)
{
ctgDebug
(
"stb %"
PRIx64
" not in cache, dbFName:%s"
,
suid
,
dbFName
);
goto
_return
;
}
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
stName
,
strlen
(
stName
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"stb %"
PRIx64
" name %s not in cache, dbFName:%s"
,
suid
,
stName
,
dbFName
);
taosHashRelease
(
dbCache
->
stbCache
,
stName
);
goto
_return
;
}
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
if
(
NULL
==
pCache
->
pMeta
)
{
ctgDebug
(
"stb %"
PRIx64
" meta not in cache, dbFName:%s"
,
suid
,
dbFName
);
goto
_return
;
}
*
pDb
=
dbCache
;
*
pTb
=
pCache
;
ctgDebug
(
"stb %"
PRIx64
" meta got in cache, dbFName:%s"
,
suid
,
dbFName
);
CTG_CACHE_STAT_INC
(
tbMetaHitNum
,
1
);
return
TSDB_CODE_SUCCESS
;
_return:
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_CACHE_STAT_INC
(
tbMetaMissNum
,
1
);
*
pDb
=
NULL
;
*
pTb
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgAcquireTbIndexFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
*
exist
=
0
;
ctgDebug
(
"db %s not in cache"
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
goto
_return
;
}
int32_t
sz
=
0
;
SCtgTbCache
*
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
tbName
,
dbFName
);
goto
_return
;
}
CTG_LOCK
(
CTG_READ
,
&
pCache
->
indexLock
);
if
(
NULL
==
pCache
->
pIndex
)
{
ctgDebug
(
"tb %s index not in cache, dbFName:%s"
,
tbName
,
dbFName
);
goto
_return
;
}
}
size_t
sz
=
0
;
*
pDb
=
dbCache
;
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
*
pTb
=
pCache
;
STableMeta
*
tbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
metaCache
,
tbName
,
strlen
(
tbName
));
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctgDebug
(
"tb %s index got in cache, dbFName:%s"
,
tbName
,
dbFName
);
if
(
NULL
==
tbMeta
)
{
CTG_CACHE_STAT_INC
(
tbIndexHitNum
,
1
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
_return:
ctgReleaseTbIndexToCache
(
pCtg
,
dbCache
,
pCache
);
CTG_CACHE_STAT_INC
(
tbIndexMissNum
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgTbMetaExistInCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
int32_t
*
exist
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
tbCache
=
NULL
;
ctgAcquireTbMetaFromCache
(
pCtg
,
dbFName
,
tbName
,
&
dbCache
,
&
tbCache
);
if
(
NULL
==
tbCache
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
*
exist
=
0
;
*
exist
=
0
;
ctgDebug
(
"tbmeta not in cache, dbFName:%s, tbName:%s"
,
dbFName
,
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
exist
=
1
;
*
exist
=
1
;
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"tbmeta is in cache, dbFName:%s, tbName:%s"
,
dbFName
,
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
ctgReadTbMetaFromCache
(
SCatalog
*
pCtg
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
tbCache
=
NULL
;
*
pTableMeta
=
NULL
;
*
pTableMeta
=
NULL
;
if
(
NULL
==
pCtg
->
dbCache
)
{
ctgDebug
(
"empty tbmeta cache, tbName:%s"
,
ctx
->
pName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
if
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
if
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
strcpy
(
dbFName
,
ctx
->
pName
->
dbname
);
strcpy
(
dbFName
,
ctx
->
pName
->
dbname
);
...
@@ -257,202 +389,194 @@ int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta**
...
@@ -257,202 +389,194 @@ int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta**
tNameGetFullDbName
(
ctx
->
pName
,
dbFName
);
tNameGetFullDbName
(
ctx
->
pName
,
dbFName
);
}
}
ctgAcquire
DBCache
(
pCtg
,
dbFName
,
&
d
bCache
);
ctgAcquire
TbMetaFromCache
(
pCtg
,
dbFName
,
ctx
->
pName
->
tname
,
&
dbCache
,
&
t
bCache
);
if
(
NULL
==
d
bCache
)
{
if
(
NULL
==
t
bCache
)
{
ctg
Debug
(
"db %d.%s not in cache"
,
ctx
->
pName
->
acctId
,
ctx
->
pName
->
dbnam
e
);
ctg
ReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCach
e
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
sz
=
0
;
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
taosHashGetDup_m
(
dbCache
->
tbCache
.
metaCache
,
ctx
->
pName
->
tname
,
strlen
(
ctx
->
pName
->
tname
),
(
void
**
)
pTableMeta
,
&
sz
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
NULL
==
*
pTableMeta
)
{
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"tbl not in cache, dbFName:%s, tbName:%s"
,
dbFName
,
ctx
->
pName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
STableMeta
*
tbMeta
=
*
pTableMeta
;
ctx
->
tbInfo
.
inCache
=
true
;
ctx
->
tbInfo
.
inCache
=
true
;
ctx
->
tbInfo
.
dbId
=
dbCache
->
dbId
;
ctx
->
tbInfo
.
dbId
=
dbCache
->
dbId
;
ctx
->
tbInfo
.
suid
=
tbMeta
->
suid
;
ctx
->
tbInfo
.
suid
=
tbMeta
->
suid
;
ctx
->
tbInfo
.
tbType
=
tbMeta
->
tableType
;
ctx
->
tbInfo
.
tbType
=
tbMeta
->
tableType
;
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
int32_t
metaSize
=
CTG_META_SIZE
(
tbMeta
);
ctgDebug
(
"Got meta from cache, type:%d, dbFName:%s, tbName:%s"
,
tbMeta
->
tableType
,
dbFName
,
ctx
->
pName
->
tname
);
*
pTableMeta
=
taosMemoryCalloc
(
1
,
metaSize
);
if
(
NULL
==
*
pTableMeta
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
CTG_CACHE_STAT_INC
(
tblHitNum
,
1
);
memcpy
(
*
pTableMeta
,
tbMeta
,
metaSize
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgDebug
(
"Got tb %s meta from cache, type:%d, dbFName:%s"
,
ctx
->
pName
->
tname
,
tbMeta
->
tableType
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// PROCESS FOR CHILD TABLE
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
int32_t
metaSize
=
sizeof
(
SCTableMeta
);
*
pTableMeta
=
taosMemoryCalloc
(
1
,
metaSize
);
STableMeta
**
stbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
stbCache
,
&
tbMeta
->
suid
,
sizeof
(
tbMeta
->
suid
));
if
(
NULL
==
*
pTableMeta
)
{
if
(
NULL
==
stbMeta
||
NULL
==
*
stbMeta
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgError
(
"stb not in stbCache, suid:%"
PRIx64
,
tbMeta
->
suid
);
goto
_return
;
}
}
if
((
*
stbMeta
)
->
suid
!=
tbMeta
->
suid
)
{
memcpy
(
*
pTableMeta
,
tbMeta
,
metaSize
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgError
(
"stable suid in stbCache mis-match, expected suid:%"
PRIx64
",actual suid:%"
PRIx64
,
tbMeta
->
suid
,
(
*
stbMeta
)
->
suid
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgDebug
(
"Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s"
,
ctx
->
pName
->
tname
,
ctx
->
tbInfo
.
tbType
,
dbFName
);
ctgAcquireStbMetaFromCache
(
pCtg
,
dbFName
,
ctx
->
tbInfo
.
suid
,
&
dbCache
,
&
tbCache
);
if
(
NULL
==
tbCache
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
taosMemoryFreeClear
(
*
pTableMeta
);
ctgDebug
(
"stb %"
PRIx64
" meta not in cache"
,
ctx
->
tbInfo
.
suid
);
return
TSDB_CODE_SUCCESS
;
}
STableMeta
*
stbMeta
=
tbCache
->
pMeta
;
if
(
stbMeta
->
suid
!=
ctx
->
tbInfo
.
suid
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgError
(
"stb suid %"
PRIx64
" in stbCache mis-match, expected suid:%"
PRIx64
,
stbMeta
->
suid
,
ctx
->
tbInfo
.
suid
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
int32_t
metaSize
=
CTG_META_SIZE
(
*
stbMeta
);
metaSize
=
CTG_META_SIZE
(
stbMeta
);
*
pTableMeta
=
taosMemoryRealloc
(
*
pTableMeta
,
metaSize
);
*
pTableMeta
=
taosMemoryRealloc
(
*
pTableMeta
,
metaSize
);
if
(
NULL
==
*
pTableMeta
)
{
if
(
NULL
==
*
pTableMeta
)
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgError
(
"realloc size[%d] failed"
,
metaSize
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
memcpy
(
&
(
*
pTableMeta
)
->
sversion
,
&
(
*
stbMeta
)
->
sversion
,
metaSize
-
sizeof
(
SCTableMeta
));
memcpy
(
&
(
*
pTableMeta
)
->
sversion
,
&
stbMeta
->
sversion
,
metaSize
-
sizeof
(
SCTableMeta
));
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"Got tb %s meta from cache, dbFName:%s"
,
ctx
->
pName
->
tname
,
dbFName
);
CTG_CACHE_STAT_INC
(
tblHitNum
,
1
);
ctgDebug
(
"Got tbmeta from cache, dbFName:%s, tbName:%s"
,
dbFName
,
ctx
->
pName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
ctgRelease
DBCache
(
pCtg
,
d
bCache
);
ctgRelease
TbMetaToCache
(
pCtg
,
dbCache
,
t
bCache
);
taosMemoryFreeClear
(
*
pTableMeta
);
taosMemoryFreeClear
(
*
pTableMeta
);
CTG_CACHE_STAT_INC
(
tblMissNum
,
1
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgReadTbVerFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
int32_t
*
sver
,
int32_t
*
tver
,
int32_t
*
tbType
,
uint64_t
*
suid
,
int32_t
ctgReadTbVerFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
int32_t
*
sver
,
int32_t
*
tver
,
int32_t
*
tbType
,
uint64_t
*
suid
,
char
*
stbName
)
{
char
*
stbName
)
{
*
sver
=
-
1
;
*
sver
=
-
1
;
*
tver
=
-
1
;
*
tver
=
-
1
;
if
(
NULL
==
pCtg
->
dbCache
)
{
ctgDebug
(
"empty tbmeta cache, tbName:%s"
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
tbCache
=
NULL
;
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
dbFName
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
ctgAcquire
DBCache
(
pCtg
,
dbFName
,
&
d
bCache
);
ctgAcquire
TbMetaFromCache
(
pCtg
,
dbFName
,
pTableName
->
tname
,
&
dbCache
,
&
t
bCache
);
if
(
NULL
==
d
bCache
)
{
if
(
NULL
==
t
bCache
)
{
ctg
Debug
(
"db %s not in cache"
,
pTableName
->
tnam
e
);
ctg
ReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCach
e
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
STableMeta
*
tbMeta
=
tbCache
->
pMeta
;
STableMeta
*
tbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
metaCache
,
pTableName
->
tname
,
strlen
(
pTableName
->
tname
));
*
tbType
=
tbMeta
->
tableType
;
if
(
tbMeta
)
{
*
suid
=
tbMeta
->
suid
;
*
tbType
=
tbMeta
->
tableType
;
*
suid
=
tbMeta
->
suid
;
if
(
*
tbType
!=
TSDB_CHILD_TABLE
)
{
*
sver
=
tbMeta
->
sversion
;
*
tver
=
tbMeta
->
tversion
;
}
}
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
NULL
==
tbMeta
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
if
(
*
tbType
!=
TSDB_CHILD_TABLE
)
{
if
(
*
tbType
!=
TSDB_CHILD_TABLE
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
)
;
*
sver
=
tbMeta
->
sversion
;
ctgDebug
(
"Got sver %d tver %d from cache, type:%d, dbFName:%s, tbName:%s"
,
*
sver
,
*
tver
,
*
tbType
,
dbFName
,
pTableName
->
tname
)
;
*
tver
=
tbMeta
->
tversion
;
ctgDebug
(
"Got tb %s ver from cache, dbFName:%s, tbType:%d, sver:%d, tver:%d, suid:%"
PRIx64
,
pTableName
->
tname
,
dbFName
,
*
tbType
,
*
sver
,
*
tver
,
*
suid
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
ctgDebug
(
"Got subtable meta from cache, dbFName:%s, tbName:%s, suid:%"
PRIx64
,
dbFName
,
pTableName
->
tname
,
*
suid
);
// PROCESS FOR CHILD TABLE
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgDebug
(
"Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s"
,
pTableName
->
tname
,
dbFName
);
STableMeta
**
stbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
stbCache
,
suid
,
sizeof
(
*
suid
));
if
(
NULL
==
stbMeta
||
NULL
==
*
stbMeta
)
{
ctgAcquireStbMetaFromCache
(
pCtg
,
dbFName
,
*
suid
,
&
dbCache
,
&
tbCache
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
if
(
NULL
==
tbCache
)
{
ctgRelease
DBCache
(
pCtg
,
d
bCache
);
ctgRelease
TbMetaToCache
(
pCtg
,
dbCache
,
t
bCache
);
ctgDebug
(
"stb
not in stbCache, suid:%"
PRIx64
,
*
suid
);
ctgDebug
(
"stb
%"
PRIx64
" meta not in cache"
,
*
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
((
*
stbMeta
)
->
suid
!=
*
suid
)
{
STableMeta
*
stbMeta
=
tbCache
->
pMeta
;
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
if
(
stbMeta
->
suid
!=
*
suid
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgError
(
"stable suid in stbCache mis-match, expected suid:%"
PRIx64
",actual suid:%"
PRIx64
,
*
suid
,
ctgError
(
"stb suid %"
PRIx64
" in stbCache mis-match, expected suid:%"
PRIx64
,
stbMeta
->
suid
,
*
suid
);
(
*
stbMeta
)
->
suid
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
size_t
nameLen
=
0
;
size_t
nameLen
=
0
;
char
*
name
=
taosHashGetKey
(
*
stbMeta
,
&
nameLen
);
char
*
name
=
taosHashGetKey
(
tbCache
,
&
nameLen
);
strncpy
(
stbName
,
name
,
nameLen
);
strncpy
(
stbName
,
name
,
nameLen
);
stbName
[
nameLen
]
=
0
;
stbName
[
nameLen
]
=
0
;
*
sver
=
(
*
stbMeta
)
->
sversion
;
*
sver
=
stbMeta
->
sversion
;
*
tver
=
(
*
stbMeta
)
->
tversion
;
*
tver
=
stbMeta
->
tversion
;
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"Got tb %s sver %d tver %d from cache, type:%d, dbFName:%s"
,
pTableName
->
tname
,
*
sver
,
*
tver
,
*
tbType
,
dbFName
);
ctgDebug
(
"Got sver %d tver %d from cache, type:%d, dbFName:%s, tbName:%s"
,
*
sver
,
*
tver
,
*
tbType
,
dbFName
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgReadTbTypeFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tableName
,
int32_t
*
tbType
)
{
int32_t
ctgReadTbTypeFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tableName
,
int32_t
*
tbType
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
SCtgDBCache
*
dbCache
=
NULL
;
ctgWarn
(
"empty db cache, dbFName:%s, tbName:%s"
,
dbFName
,
tableName
);
SCtgTbCache
*
tbCache
=
NULL
;
CTG_ERR_RET
(
ctgAcquireTbMetaFromCache
(
pCtg
,
dbFName
,
tableName
,
&
dbCache
,
&
tbCache
));
if
(
NULL
==
tbCache
)
{
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
tbType
=
tbCache
->
pMeta
->
tableType
;
ctgReleaseTbMetaToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgDebug
(
"Got tb %s tbType %d from cache, dbFName:%s"
,
tableName
,
*
tbType
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgReadTbIndexFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
SArray
**
pRes
)
{
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
SCtgTbCache
*
tbCache
=
NULL
;
if
(
NULL
==
dbCache
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
return
TSDB_CODE_SUCCESS
;
tNameGetFullDbName
(
pTableName
,
dbFName
);
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
*
pRes
=
NULL
;
STableMeta
*
pTableMeta
=
(
STableMeta
*
)
taosHashAcquire
(
dbCache
->
tbCache
.
metaCache
,
tableName
,
strlen
(
tableName
));
if
(
NULL
==
pTableMeta
)
{
ctgAcquireTbIndexFromCache
(
pCtg
,
dbFName
,
pTableName
->
tname
,
&
dbCache
,
&
tbCache
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
NULL
==
tbCache
)
{
ctgWarn
(
"tbl not in cache, dbFName:%s, tbName:%s"
,
dbFName
,
tableName
);
ctgReleaseTbIndexToCache
(
pCtg
,
dbCache
,
tbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
tbType
=
atomic_load_8
(
&
pTableMeta
->
tableType
);
CTG_ERR_JRET
(
ctgCloneTableIndex
(
tbCache
->
pIndex
->
pIndex
,
pRes
));
taosHashRelease
(
dbCache
->
tbCache
.
metaCache
,
pTableMeta
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
_return:
ctgRelease
DBCache
(
pCtg
,
d
bCache
);
ctgRelease
TbIndexToCache
(
pCtg
,
dbCache
,
t
bCache
);
ctgDebug
(
"Got tbtype from cache, dbFName:%s, tbName:%s, type:%d"
,
dbFName
,
tableName
,
*
tbType
);
CTG_RET
(
code
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
c
onst
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
)
{
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
c
har
*
user
,
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
)
{
if
(
NULL
==
pCtg
->
userCache
)
{
if
(
NULL
==
pCtg
->
userCache
)
{
ctgDebug
(
"empty user auth cache, user:%s"
,
user
);
ctgDebug
(
"empty user auth cache, user:%s"
,
user
);
goto
_return
;
goto
_return
;
...
@@ -718,9 +842,9 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool sy
...
@@ -718,9 +842,9 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool sy
op
->
opId
=
CTG_OP_UPDATE_TB_META
;
op
->
opId
=
CTG_OP_UPDATE_TB_META
;
op
->
syncOp
=
syncOp
;
op
->
syncOp
=
syncOp
;
SCtgUpdateTb
lMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTbl
Msg
));
SCtgUpdateTb
MetaMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTbMeta
Msg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateTb
l
Msg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateTb
Meta
Msg
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
...
@@ -730,7 +854,7 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool sy
...
@@ -730,7 +854,7 @@ int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool sy
}
}
msg
->
pCtg
=
pCtg
;
msg
->
pCtg
=
pCtg
;
msg
->
output
=
output
;
msg
->
pMeta
=
output
;
op
->
data
=
msg
;
op
->
data
=
msg
;
...
@@ -805,6 +929,67 @@ _return:
...
@@ -805,6 +929,67 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgUpdateTbIndexEnqueue
(
SCatalog
*
pCtg
,
STableIndex
**
pIndex
,
bool
syncOp
)
{
int32_t
code
=
0
;
SCtgCacheOperation
*
op
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgCacheOperation
));
op
->
opId
=
CTG_OP_UPDATE_TB_INDEX
;
op
->
syncOp
=
syncOp
;
SCtgUpdateTbIndexMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTbIndexMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateTbIndexMsg
));
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
msg
->
pIndex
=
*
pIndex
;
op
->
data
=
msg
;
CTG_ERR_JRET
(
ctgEnqueue
(
pCtg
,
op
));
*
pIndex
=
NULL
;
return
TSDB_CODE_SUCCESS
;
_return:
taosArrayDestroyEx
((
*
pIndex
)
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
*
pIndex
);
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgDropTbIndexEnqueue
(
SCatalog
*
pCtg
,
SName
*
pName
,
bool
syncOp
)
{
int32_t
code
=
0
;
SCtgCacheOperation
*
op
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgCacheOperation
));
op
->
opId
=
CTG_OP_DROP_TB_INDEX
;
op
->
syncOp
=
syncOp
;
SCtgDropTbIndexMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgDropTbIndexMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgDropTbIndexMsg
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
tNameGetFullDbName
(
pName
,
msg
->
dbFName
);
strcpy
(
msg
->
tbName
,
pName
->
tname
);
op
->
data
=
msg
;
CTG_ERR_JRET
(
ctgEnqueue
(
pCtg
,
op
));
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgMetaRentInit
(
SCtgRentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
)
{
int32_t
ctgMetaRentInit
(
SCtgRentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
)
{
mgmt
->
slotRIdx
=
0
;
mgmt
->
slotRIdx
=
0
;
mgmt
->
slotNum
=
rentSec
/
CTG_RENT_SLOT_SECOND
;
mgmt
->
slotNum
=
rentSec
/
CTG_RENT_SLOT_SECOND
;
...
@@ -875,7 +1060,7 @@ int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t si
...
@@ -875,7 +1060,7 @@ int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t si
void
*
orig
=
taosArraySearch
(
slot
->
meta
,
&
id
,
searchCompare
,
TD_EQ
);
void
*
orig
=
taosArraySearch
(
slot
->
meta
,
&
id
,
searchCompare
,
TD_EQ
);
if
(
NULL
==
orig
)
{
if
(
NULL
==
orig
)
{
q
Error
(
"meta not found in slot, id:%"
PRIx64
", slot idx:%d, type:%d, size:%d"
,
id
,
widx
,
mgmt
->
type
,
(
int32_t
)
taosArrayGetSize
(
slot
->
meta
));
q
Debug
(
"meta not found in slot, id:%"
PRIx64
", slot idx:%d, type:%d, size:%d"
,
id
,
widx
,
mgmt
->
type
,
(
int32_t
)
taosArrayGetSize
(
slot
->
meta
));
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
...
@@ -888,7 +1073,7 @@ _return:
...
@@ -888,7 +1073,7 @@ _return:
CTG_UNLOCK
(
CTG_WRITE
,
&
slot
->
lock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
slot
->
lock
);
if
(
code
)
{
if
(
code
)
{
q
Warn
(
"meta in rent update failed, will try to add it, code:%x, id:%"
PRIx64
", slot idx:%d, type:%d"
,
code
,
id
,
widx
,
mgmt
->
type
);
q
Debug
(
"meta in rent update failed, will try to add it, code:%x, id:%"
PRIx64
", slot idx:%d, type:%d"
,
code
,
id
,
widx
,
mgmt
->
type
);
CTG_RET
(
ctgMetaRentAdd
(
mgmt
,
meta
,
id
,
size
));
CTG_RET
(
ctgMetaRentAdd
(
mgmt
,
meta
,
id
,
size
));
}
}
...
@@ -1006,14 +1191,14 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
...
@@ -1006,14 +1191,14 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) {
SCtgDBCache
newDBCache
=
{
0
};
SCtgDBCache
newDBCache
=
{
0
};
newDBCache
.
dbId
=
dbId
;
newDBCache
.
dbId
=
dbId
;
newDBCache
.
tbCache
.
metaCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
newDBCache
.
tbCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
newDBCache
.
tbCache
.
metaCache
)
{
if
(
NULL
==
newDBCache
.
tbCache
)
{
ctgError
(
"taosHashInit %d metaCache failed"
,
gCtgMgmt
.
cfg
.
maxTblCacheNum
);
ctgError
(
"taosHashInit %d metaCache failed"
,
gCtgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
newDBCache
.
tbCache
.
stbCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
newDBCache
.
stbCache
=
taosHashInit
(
gCtgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
newDBCache
.
tbCache
.
stbCache
)
{
if
(
NULL
==
newDBCache
.
stbCache
)
{
ctgError
(
"taosHashInit %d stbCache failed"
,
gCtgMgmt
.
cfg
.
maxTblCacheNum
);
ctgError
(
"taosHashInit %d stbCache failed"
,
gCtgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
...
@@ -1050,22 +1235,22 @@ _return:
...
@@ -1050,22 +1235,22 @@ _return:
}
}
void
ctgRemoveStbRent
(
SCatalog
*
pCtg
,
SCtgTbMetaCache
*
cache
)
{
void
ctgRemoveStbRent
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
cache
->
stbLock
);
if
(
NULL
==
dbCache
->
stbCache
)
{
if
(
cache
->
stbCache
)
{
return
;
void
*
pIter
=
taosHashIterate
(
cache
->
stbCache
,
NULL
);
}
while
(
pIter
)
{
uint64_t
*
suid
=
NULL
;
void
*
pIter
=
taosHashIterate
(
dbCache
->
stbCache
,
NULL
);
suid
=
taosHashGetKey
(
pIter
,
NULL
);
while
(
pIter
)
{
uint64_t
*
suid
=
NULL
;
suid
=
taosHashGetKey
(
pIter
,
NULL
);
if
(
TSDB_CODE_SUCCESS
==
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
*
suid
,
ctgStbVersionSortCompare
,
ctgStbVersionSearchCompare
))
{
if
(
TSDB_CODE_SUCCESS
==
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
*
suid
,
ctgStbVersionSortCompare
,
ctgStbVersionSearchCompare
))
{
ctgDebug
(
"stb removed from rent, suid:%"
PRIx64
,
*
suid
);
ctgDebug
(
"stb removed from rent, suid:%"
PRIx64
,
*
suid
);
}
pIter
=
taosHashIterate
(
cache
->
stbCache
,
pIter
);
}
}
pIter
=
taosHashIterate
(
dbCache
->
stbCache
,
pIter
);
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
cache
->
stbLock
);
}
}
...
@@ -1074,15 +1259,16 @@ int32_t ctgRemoveDBFromCache(SCatalog* pCtg, SCtgDBCache *dbCache, const char* d
...
@@ -1074,15 +1259,16 @@ int32_t ctgRemoveDBFromCache(SCatalog* pCtg, SCtgDBCache *dbCache, const char* d
ctgInfo
(
"start to remove db from cache, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbCache
->
dbId
);
ctgInfo
(
"start to remove db from cache, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbCache
->
dbId
);
atomic_store_8
(
&
dbCache
->
deleted
,
1
);
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
dbLock
);
ctgRemoveStbRent
(
pCtg
,
&
dbCache
->
tbCache
);
atomic_store_8
(
&
dbCache
->
deleted
,
1
);
ctgRemoveStbRent
(
pCtg
,
dbCache
);
ctgFreeDbCache
(
dbCache
);
ctgFreeDbCache
(
dbCache
);
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCtg
->
dbRent
,
dbCache
->
dbId
,
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
dbLock
);
ctgDebug
(
"db removed from rent, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbCache
->
dbId
);
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCtg
->
dbRent
,
dbId
,
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
ctgDebug
(
"db removed from rent, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbId
);
if
(
taosHashRemove
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
)))
{
if
(
taosHashRemove
(
pCtg
->
dbCache
,
dbFName
,
strlen
(
dbFName
)))
{
ctgInfo
(
"taosHashRemove from dbCache failed, may be removed, dbFName:%s"
,
dbFName
);
ctgInfo
(
"taosHashRemove from dbCache failed, may be removed, dbFName:%s"
,
dbFName
);
...
@@ -1090,7 +1276,6 @@ int32_t ctgRemoveDBFromCache(SCatalog* pCtg, SCtgDBCache *dbCache, const char* d
...
@@ -1090,7 +1276,6 @@ int32_t ctgRemoveDBFromCache(SCatalog* pCtg, SCtgDBCache *dbCache, const char* d
}
}
CTG_CACHE_STAT_DEC
(
dbNum
,
1
);
CTG_CACHE_STAT_DEC
(
dbNum
,
1
);
ctgInfo
(
"db removed from cache, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbId
);
ctgInfo
(
"db removed from cache, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1138,120 +1323,76 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt
...
@@ -1138,120 +1323,76 @@ int32_t ctgGetAddDBCache(SCatalog* pCtg, const char *dbFName, uint64_t dbId, SCt
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgUpdateRentStbVersion
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
uint64_t
dbId
,
uint64_t
suid
,
SCtgTbCache
*
pCache
)
{
int32_t
ctgWriteDBVgInfoToCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
,
SDBVgInfo
**
pDbInfo
)
{
SSTableVersion
metaRent
=
{.
dbId
=
dbId
,
.
suid
=
suid
};
int32_t
code
=
0
;
if
(
pCache
->
pMeta
)
{
SDBVgInfo
*
dbInfo
=
*
pDbInfo
;
metaRent
.
sversion
=
pCache
->
pMeta
->
sversion
;
metaRent
.
tversion
=
pCache
->
pMeta
->
tversion
;
if
(
NULL
==
dbInfo
->
vgHash
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
dbInfo
->
vgVersion
<
0
||
taosHashGetSize
(
dbInfo
->
vgHash
)
<=
0
)
{
ctgError
(
"invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d"
,
dbFName
,
dbInfo
->
vgHash
,
dbInfo
->
vgVersion
,
taosHashGetSize
(
dbInfo
->
vgHash
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
bool
newAdded
=
false
;
if
(
pCache
->
pIndex
)
{
SDbVgVersion
vgVersion
=
{.
dbId
=
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
,
.
numOfTable
=
dbInfo
->
numOfTable
};
metaRent
.
smaVer
=
pCache
->
pIndex
->
version
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_RET
(
ctgGetAddDBCache
(
pCtg
,
dbFName
,
dbId
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"conflict db update, ignore this update, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
dbId
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgWAcquireVgInfo
(
pCtg
,
dbCache
));
if
(
dbCache
->
vgInfo
)
{
strcpy
(
metaRent
.
dbFName
,
dbFName
);
if
(
dbInfo
->
vgVersion
<
dbCache
->
vgInfo
->
vgVersion
)
{
strcpy
(
metaRent
.
stbName
,
tbName
);
ctgDebug
(
"db vgVersion is old, dbFName:%s, vgVersion:%d, currentVersion:%d"
,
dbFName
,
dbInfo
->
vgVersion
,
dbCache
->
vgInfo
->
vgVersion
);
ctgWReleaseVgInfo
(
dbCache
);
CTG_ERR_RET
(
ctgMetaRentUpdate
(
&
pCtg
->
stbRent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableVersion
),
ctgStbVersionSortCompare
,
ctgStbVersionSearchCompare
));
return
TSDB_CODE_SUCCESS
;
}
if
(
dbInfo
->
vgVersion
==
dbCache
->
vgInfo
->
vgVersion
&&
dbInfo
->
numOfTable
==
dbCache
->
vgInfo
->
numOfTable
)
{
ctgDebug
(
"no new db vgVersion or numOfTable, dbFName:%s, vgVersion:%d, numOfTable:%d"
,
dbFName
,
dbInfo
->
vgVersion
,
dbInfo
->
numOfTable
);
ctgWReleaseVgInfo
(
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
ctgFreeVgInfo
(
dbCache
->
vgInfo
);
}
dbCache
->
vgInfo
=
dbInfo
;
*
pDbInfo
=
NULL
;
ctgDebug
(
"db vgInfo updated, dbFName:%s, vgVersion:%d, dbId:%"
PRIx64
,
dbFName
,
vgVersion
.
vgVersion
,
vgVersion
.
dbId
);
ctgWReleaseVgInfo
(
dbCache
);
dbCache
=
NULL
;
ctgDebug
(
"db %s,%"
PRIx64
" stb %s,%"
PRIx64
" sver %d tver %d smaVer %d updated to stbRent"
,
dbFName
,
dbId
,
tbName
,
suid
,
metaRent
.
sversion
,
metaRent
.
tversion
,
metaRent
.
smaVer
);
strncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
return
TSDB_CODE_SUCCESS
;
CTG_ERR_RET
(
ctgMetaRentUpdate
(
&
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
CTG_RET
(
code
);
}
}
int32_t
ctgWriteTbMetaToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
char
*
dbFName
,
uint64_t
dbId
,
char
*
tbName
,
STableMeta
*
meta
,
int32_t
metaSize
)
{
int32_t
ctgWriteTbMetaToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
char
*
dbFName
,
uint64_t
dbId
,
char
*
tbName
,
STableMeta
*
meta
,
int32_t
metaSize
)
{
SCtgTbMetaCache
*
tbCache
=
&
dbCache
->
tbCache
;
if
(
NULL
==
dbCache
->
tbCache
||
NULL
==
dbCache
->
stbCache
)
{
taosMemoryFree
(
meta
);
CTG_LOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
if
(
dbCache
->
deleted
||
NULL
==
tbCache
->
metaCache
||
NULL
==
tbCache
->
stbCache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
ctgError
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
ctgError
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
CTG_ERR_RET
(
TSDB_CODE_CTG_DB_DROPPED
);
CTG_ERR_RET
(
TSDB_CODE_CTG_DB_DROPPED
);
}
}
bool
isStb
=
meta
->
tableType
==
TSDB_SUPER_TABLE
;
SCtgTbCache
*
pCache
=
taosHashGet
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
STableMeta
*
orig
=
(
pCache
?
pCache
->
pMeta
:
NULL
);
int8_t
origType
=
0
;
int8_t
origType
=
0
;
uint64_t
origSuid
=
0
;
uint64_t
origSuid
=
0
;
bool
isStb
=
meta
->
tableType
==
TSDB_SUPER_TABLE
;
STableMeta
*
orig
=
taosHashGet
(
tbCache
->
metaCache
,
tbName
,
strlen
(
tbName
));
if
(
orig
)
{
if
(
orig
)
{
origType
=
orig
->
tableType
;
origType
=
orig
->
tableType
;
if
(
origType
==
meta
->
tableType
&&
orig
->
uid
==
meta
->
uid
&&
orig
->
sversion
>=
meta
->
sversion
&&
orig
->
tversion
>=
meta
->
tversion
)
{
if
(
origType
==
meta
->
tableType
&&
orig
->
uid
==
meta
->
uid
&&
orig
->
sversion
>=
meta
->
sversion
&&
orig
->
tversion
>=
meta
->
tversion
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
taosMemoryFree
(
meta
);
ctgDebug
(
"ignore table %s meta update"
,
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
origType
==
TSDB_SUPER_TABLE
)
{
if
(
origType
==
TSDB_SUPER_TABLE
)
{
CTG_LOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
if
(
taosHashRemove
(
dbCache
->
stbCache
,
&
orig
->
suid
,
sizeof
(
orig
->
suid
)))
{
if
(
taosHashRemove
(
tbCache
->
stbCache
,
&
orig
->
suid
,
sizeof
(
orig
->
suid
)))
{
ctgError
(
"stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
ctgError
(
"stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
}
else
{
}
else
{
CTG_CACHE_STAT_DEC
(
stblNum
,
1
);
CTG_CACHE_STAT_DEC
(
stblNum
,
1
);
ctgDebug
(
"stb removed from stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
ctgDebug
(
"stb removed from stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
orig
->
suid
,
ctgStbVersionSortCompare
,
ctgStbVersionSearchCompare
);
origSuid
=
orig
->
suid
;
origSuid
=
orig
->
suid
;
}
}
}
}
if
(
isStb
)
{
if
(
NULL
==
pCache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
)
;
SCtgTbCache
cache
=
{
0
}
;
}
cache
.
pMeta
=
meta
;
if
(
taosHashPut
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
),
&
cache
,
sizeof
(
SCtgTbCache
))
!=
0
)
{
if
(
taosHashPut
(
tbCache
->
metaCache
,
tbName
,
strlen
(
tbName
),
meta
,
metaSize
)
!=
0
)
{
taosMemoryFree
(
meta
);
if
(
isStb
)
{
ctgError
(
"taosHashPut new tbCache failed, dbFName:%s, tbName:%s, tbType:%d"
,
dbFName
,
tbName
,
meta
->
tableType
);
CTG_
UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_
ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
pCache
=
taosHashGet
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
ctgError
(
"taosHashPut tbmeta to cache failed, dbFName:%s, tbName:%s, tbType:%d"
,
dbFName
,
tbName
,
meta
->
tableType
);
}
else
{
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
taosMemoryFree
(
pCache
->
pMeta
);
pCache
->
pMeta
=
meta
;
}
}
if
(
NULL
==
orig
)
{
if
(
NULL
==
orig
)
{
...
@@ -1262,30 +1403,71 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
...
@@ -1262,30 +1403,71 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
ctgdShowTableMeta
(
pCtg
,
tbName
,
meta
);
ctgdShowTableMeta
(
pCtg
,
tbName
,
meta
);
if
(
!
isStb
)
{
if
(
!
isStb
)
{
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
STableMeta
*
tbMeta
=
taosHashGet
(
tbCache
->
metaCache
,
tbName
,
strlen
(
tbName
));
if
(
origSuid
!=
meta
->
suid
&&
taosHashPut
(
dbCache
->
stbCache
,
&
meta
->
suid
,
sizeof
(
meta
->
suid
),
tbName
,
strlen
(
tbName
)
+
1
)
!=
0
)
{
if
(
taosHashPut
(
tbCache
->
stbCache
,
&
meta
->
suid
,
sizeof
(
meta
->
suid
),
&
tbMeta
,
POINTER_BYTES
)
!=
0
)
{
ctgError
(
"taosHashPut to stable cache failed, suid:%"
PRIx64
,
meta
->
suid
);
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
ctgError
(
"taosHashPut stable to stable cache failed, suid:%"
PRIx64
,
meta
->
suid
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
CTG_CACHE_STAT_INC
(
stblNum
,
1
);
CTG_CACHE_STAT_INC
(
stblNum
,
1
);
ctgDebug
(
"stb %"
PRIx64
" updated to cache, dbFName:%s, tbName:%s, tbType:%d"
,
meta
->
suid
,
dbFName
,
tbName
,
meta
->
tableType
);
CTG_ERR_RET
(
ctgUpdateRentStbVersion
(
pCtg
,
dbFName
,
tbName
,
dbId
,
meta
->
suid
,
pCache
));
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
return
TSDB_CODE_SUCCESS
;
}
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
int32_t
ctgWriteTbIndexToCache
(
SCatalog
*
pCtg
,
SCtgDBCache
*
dbCache
,
char
*
dbFName
,
char
*
tbName
,
STableIndex
**
index
)
{
if
(
NULL
==
dbCache
->
tbCache
)
{
ctgFreeSTableIndex
(
*
index
);
taosMemoryFreeClear
(
*
index
);
ctgError
(
"db is dropping, dbId:%"
PRIx64
,
dbCache
->
dbId
);
CTG_ERR_RET
(
TSDB_CODE_CTG_DB_DROPPED
);
}
ctgDebug
(
"stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d"
,
dbFName
,
tbName
,
meta
->
tableType
);
STableIndex
*
pIndex
=
*
index
;
uint64_t
suid
=
pIndex
->
suid
;
SCtgTbCache
*
pCache
=
taosHashGet
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pCache
)
{
SCtgTbCache
cache
=
{
0
};
cache
.
pIndex
=
pIndex
;
if
(
taosHashPut
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
),
&
cache
,
sizeof
(
cache
))
!=
0
)
{
ctgFreeSTableIndex
(
*
index
);
taosMemoryFreeClear
(
*
index
);
ctgError
(
"taosHashPut new tbCache failed, tbName:%s"
,
tbName
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
SSTableMetaVersion
metaRent
=
{.
dbId
=
dbId
,
.
suid
=
meta
->
suid
,
.
sversion
=
meta
->
sversion
,
.
tversion
=
meta
->
tversion
};
*
index
=
NULL
;
strcpy
(
metaRent
.
dbFName
,
dbFName
);
ctgDebug
(
"table %s index updated to cache, ver:%d, num:%d"
,
tbName
,
pIndex
->
version
,
(
int32_t
)
taosArrayGetSize
(
pIndex
->
pIndex
));
strcpy
(
metaRent
.
stbName
,
tbName
);
CTG_ERR_RET
(
ctgMetaRentAdd
(
&
pCtg
->
stbRent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableMetaVersion
)));
if
(
suid
)
{
CTG_ERR_RET
(
ctgUpdateRentStbVersion
(
pCtg
,
dbFName
,
tbName
,
dbCache
->
dbId
,
pIndex
->
suid
,
&
cache
));
}
return
TSDB_CODE_SUCCESS
;
}
if
(
pCache
->
pIndex
)
{
if
(
0
==
suid
)
{
suid
=
pCache
->
pIndex
->
suid
;
}
taosArrayDestroyEx
(
pCache
->
pIndex
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
pCache
->
pIndex
);
}
pCache
->
pIndex
=
pIndex
;
*
index
=
NULL
;
ctgDebug
(
"table %s index updated to cache, ver:%d, num:%d"
,
tbName
,
pIndex
->
version
,
(
int32_t
)
taosArrayGetSize
(
pIndex
->
pIndex
));
if
(
suid
)
{
CTG_ERR_RET
(
ctgUpdateRentStbVersion
(
pCtg
,
dbFName
,
tbName
,
dbCache
->
dbId
,
suid
,
pCache
));
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1305,12 +1487,67 @@ _return:
...
@@ -1305,12 +1487,67 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
operation
)
{
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgUpdateVgMsg
*
msg
=
operation
->
data
;
SCtgUpdateVgMsg
*
msg
=
operation
->
data
;
SDBVgInfo
*
dbInfo
=
msg
->
dbInfo
;
char
*
dbFName
=
msg
->
dbFName
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
CTG_ERR_JRET
(
ctgWriteDBVgInfoToCache
(
msg
->
pCtg
,
msg
->
dbFName
,
msg
->
dbId
,
&
msg
->
dbInfo
));
if
(
NULL
==
dbInfo
->
vgHash
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
dbInfo
->
vgVersion
<
0
||
taosHashGetSize
(
dbInfo
->
vgHash
)
<=
0
)
{
ctgError
(
"invalid db vgInfo, dbFName:%s, vgHash:%p, vgVersion:%d, vgHashSize:%d"
,
dbFName
,
dbInfo
->
vgHash
,
dbInfo
->
vgVersion
,
taosHashGetSize
(
dbInfo
->
vgHash
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
bool
newAdded
=
false
;
SDbVgVersion
vgVersion
=
{.
dbId
=
msg
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
,
.
numOfTable
=
dbInfo
->
numOfTable
};
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_RET
(
ctgGetAddDBCache
(
msg
->
pCtg
,
dbFName
,
msg
->
dbId
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"conflict db update, ignore this update, dbFName:%s, dbId:%"
PRIx64
,
dbFName
,
msg
->
dbId
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
SCtgVgCache
*
vgCache
=
&
dbCache
->
vgCache
;
CTG_ERR_RET
(
ctgWLockVgInfo
(
msg
->
pCtg
,
dbCache
));
if
(
vgCache
->
vgInfo
)
{
SDBVgInfo
*
vgInfo
=
vgCache
->
vgInfo
;
if
(
dbInfo
->
vgVersion
<
vgInfo
->
vgVersion
)
{
ctgDebug
(
"db vgVer is old, dbFName:%s, vgVer:%d, curVer:%d"
,
dbFName
,
dbInfo
->
vgVersion
,
vgInfo
->
vgVersion
);
ctgWUnlockVgInfo
(
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
if
(
dbInfo
->
vgVersion
==
vgInfo
->
vgVersion
&&
dbInfo
->
numOfTable
==
vgInfo
->
numOfTable
)
{
ctgDebug
(
"no new db vgVer or numOfTable, dbFName:%s, vgVer:%d, numOfTable:%d"
,
dbFName
,
dbInfo
->
vgVersion
,
dbInfo
->
numOfTable
);
ctgWUnlockVgInfo
(
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
ctgFreeVgInfo
(
vgInfo
);
}
vgCache
->
vgInfo
=
dbInfo
;
msg
->
dbInfo
=
NULL
;
ctgDebug
(
"db vgInfo updated, dbFName:%s, vgVer:%d, dbId:%"
PRIx64
,
dbFName
,
vgVersion
.
vgVersion
,
vgVersion
.
dbId
);
ctgWUnlockVgInfo
(
dbCache
);
dbCache
=
NULL
;
strncpy
(
vgVersion
.
dbFName
,
dbFName
,
sizeof
(
vgVersion
.
dbFName
));
CTG_ERR_RET
(
ctgMetaRentUpdate
(
&
msg
->
pCtg
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionSortCompare
,
ctgDbVgVersionSearchCompare
));
_return:
_return:
...
@@ -1356,14 +1593,14 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
...
@@ -1356,14 +1593,14 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
goto
_return
;
goto
_return
;
}
}
CTG_ERR_RET
(
ctgW
Acquire
VgInfo
(
pCtg
,
dbCache
));
CTG_ERR_RET
(
ctgW
Lock
VgInfo
(
pCtg
,
dbCache
));
ctgFreeVgInfo
(
dbCache
->
vgInfo
);
ctgFreeVgInfo
(
dbCache
->
vg
Cache
.
vg
Info
);
dbCache
->
vgInfo
=
NULL
;
dbCache
->
vg
Cache
.
vg
Info
=
NULL
;
ctgDebug
(
"db vgInfo removed, dbFName:%s"
,
msg
->
dbFName
);
ctgDebug
(
"db vgInfo removed, dbFName:%s"
,
msg
->
dbFName
);
ctgW
Release
VgInfo
(
dbCache
);
ctgW
Unlock
VgInfo
(
dbCache
);
_return:
_return:
...
@@ -1375,42 +1612,47 @@ _return:
...
@@ -1375,42 +1612,47 @@ _return:
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
operation
)
{
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgUpdateTb
l
Msg
*
msg
=
operation
->
data
;
SCtgUpdateTb
Meta
Msg
*
msg
=
operation
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
STableMetaOutput
*
output
=
msg
->
output
;
STableMetaOutput
*
pMeta
=
msg
->
pMeta
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
if
((
!
CTG_IS_META_CTABLE
(
output
->
metaType
))
&&
NULL
==
output
->
tbMeta
)
{
if
((
!
CTG_IS_META_CTABLE
(
pMeta
->
metaType
))
&&
NULL
==
pMeta
->
tbMeta
)
{
ctgError
(
"no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s"
,
output
->
dbFName
,
output
->
tbName
);
ctgError
(
"no valid tbmeta got from meta rsp, dbFName:%s, tbName:%s"
,
pMeta
->
dbFName
,
pMeta
->
tbName
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
if
(
CTG_IS_META_BOTH
(
output
->
metaType
)
&&
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
if
(
CTG_IS_META_BOTH
(
pMeta
->
metaType
)
&&
TSDB_SUPER_TABLE
!=
pMeta
->
tbMeta
->
tableType
)
{
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
output
->
tbMeta
->
tableType
);
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
pMeta
->
tbMeta
->
tableType
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
CTG_ERR_JRET
(
ctgGetAddDBCache
(
pCtg
,
output
->
dbFName
,
output
->
dbId
,
&
dbCache
));
CTG_ERR_JRET
(
ctgGetAddDBCache
(
pCtg
,
pMeta
->
dbFName
,
pMeta
->
dbId
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"conflict db update, ignore this update, dbFName:%s, dbId:%"
PRIx64
,
output
->
dbFName
,
output
->
dbId
);
ctgInfo
(
"conflict db update, ignore this update, dbFName:%s, dbId:%"
PRIx64
,
pMeta
->
dbFName
,
pMeta
->
dbId
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
if
(
CTG_IS_META_TABLE
(
output
->
metaType
)
||
CTG_IS_META_BOTH
(
output
->
metaType
))
{
if
(
CTG_IS_META_TABLE
(
pMeta
->
metaType
)
||
CTG_IS_META_BOTH
(
pMeta
->
metaType
))
{
int32_t
metaSize
=
CTG_META_SIZE
(
output
->
tbMeta
);
int32_t
metaSize
=
CTG_META_SIZE
(
pMeta
->
tbMeta
);
CTG_ERR_JRET
(
ctgWriteTbMetaToCache
(
pCtg
,
dbCache
,
pMeta
->
dbFName
,
pMeta
->
dbId
,
pMeta
->
tbName
,
pMeta
->
tbMeta
,
metaSize
));
CTG_ERR_JRET
(
ctgWriteTbMetaToCache
(
pCtg
,
dbCache
,
output
->
dbFName
,
output
->
dbId
,
output
->
tbName
,
output
->
tbMeta
,
metaSize
))
;
pMeta
->
tbMeta
=
NULL
;
}
}
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
)
||
CTG_IS_META_BOTH
(
output
->
metaType
))
{
if
(
CTG_IS_META_CTABLE
(
pMeta
->
metaType
)
||
CTG_IS_META_BOTH
(
pMeta
->
metaType
))
{
CTG_ERR_JRET
(
ctgWriteTbMetaToCache
(
pCtg
,
dbCache
,
output
->
dbFName
,
output
->
dbId
,
output
->
ctbName
,
(
STableMeta
*
)
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
)));
SCTableMeta
*
ctbMeta
=
taosMemoryMalloc
(
sizeof
(
SCTableMeta
));
if
(
NULL
==
ctbMeta
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
ctbMeta
,
&
pMeta
->
ctbMeta
,
sizeof
(
SCTableMeta
));
CTG_ERR_JRET
(
ctgWriteTbMetaToCache
(
pCtg
,
dbCache
,
pMeta
->
dbFName
,
pMeta
->
dbId
,
pMeta
->
ctbName
,
(
STableMeta
*
)
ctbMeta
,
sizeof
(
SCTableMeta
)));
}
}
_return:
_return:
if
(
output
)
{
if
(
pMeta
)
{
taosMemoryFreeClear
(
output
->
tbMeta
);
taosMemoryFreeClear
(
pMeta
->
tbMeta
);
taosMemoryFreeClear
(
output
);
taosMemoryFreeClear
(
pMeta
);
}
}
taosMemoryFreeClear
(
msg
);
taosMemoryFreeClear
(
msg
);
...
@@ -1435,22 +1677,17 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
...
@@ -1435,22 +1677,17 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
if
(
taosHashRemove
(
dbCache
->
stbCache
,
&
msg
->
suid
,
sizeof
(
msg
->
suid
)))
{
if
(
taosHashRemove
(
dbCache
->
tbCache
.
stbCache
,
&
msg
->
suid
,
sizeof
(
msg
->
suid
)))
{
ctgDebug
(
"stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
ctgDebug
(
"stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
}
else
{
}
else
{
CTG_CACHE_STAT_DEC
(
stblNum
,
1
);
CTG_CACHE_STAT_DEC
(
stblNum
,
1
);
}
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
taosHashRemove
(
dbCache
->
tbCache
,
msg
->
stbName
,
strlen
(
msg
->
stbName
)))
{
if
(
taosHashRemove
(
dbCache
->
tbCache
.
metaCache
,
msg
->
stbName
,
strlen
(
msg
->
stbName
)))
{
ctgError
(
"stb not exist in cache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
ctgError
(
"stb not exist in cache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
}
else
{
}
else
{
CTG_CACHE_STAT_DEC
(
tblNum
,
1
);
CTG_CACHE_STAT_DEC
(
tblNum
,
1
);
}
}
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
ctgInfo
(
"stb removed from cache, dbFName:%s, stbName:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
ctgInfo
(
"stb removed from cache, dbFName:%s, stbName:%s, suid:%"
PRIx64
,
msg
->
dbFName
,
msg
->
stbName
,
msg
->
suid
);
...
@@ -1477,21 +1714,18 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
...
@@ -1477,21 +1714,18 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
}
}
if
(
dbCache
->
dbId
!=
msg
->
dbId
)
{
if
(
dbCache
->
dbId
!=
msg
->
dbId
)
{
ctgDebug
(
"dbId
already modified, dbFName:%s, current:%"
PRIx64
", dbId:%"
PRIx64
", tbName:%s"
,
msg
->
dbFName
,
dbCache
->
dbId
,
msg
->
dbId
,
msg
->
tbName
);
ctgDebug
(
"dbId
%"
PRIx64
" not match with curId %"
PRIx64
", dbFName:%s, tbName:%s"
,
msg
->
dbId
,
dbCache
->
dbId
,
msg
->
dbFName
,
msg
->
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
taosHashRemove
(
dbCache
->
tbCache
,
msg
->
tbName
,
strlen
(
msg
->
tbName
)))
{
if
(
taosHashRemove
(
dbCache
->
tbCache
.
metaCache
,
msg
->
tbName
,
strlen
(
msg
->
tbName
)))
{
ctgError
(
"tb %s not exist in cache, dbFName:%s"
,
msg
->
tbName
,
msg
->
dbFName
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
ctgError
(
"stb not exist in cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
else
{
}
else
{
CTG_CACHE_STAT_DEC
(
tblNum
,
1
);
CTG_CACHE_STAT_DEC
(
tblNum
,
1
);
}
}
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctg
Info
(
"table removed from cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tb
Name
);
ctg
Debug
(
"table %s removed from cache, dbFName:%s"
,
msg
->
tbName
,
msg
->
dbF
Name
);
_return:
_return:
...
@@ -1553,7 +1787,6 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
...
@@ -1553,7 +1787,6 @@ int32_t ctgOpUpdateUser(SCtgCacheOperation *operation) {
_return:
_return:
taosHashCleanup
(
msg
->
userAuth
.
createdDbs
);
taosHashCleanup
(
msg
->
userAuth
.
createdDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readDbs
);
taosHashCleanup
(
msg
->
userAuth
.
readDbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
taosHashCleanup
(
msg
->
userAuth
.
writeDbs
);
...
@@ -1569,24 +1802,22 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
...
@@ -1569,24 +1802,22 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_
RET
(
ctgAcquire
DBCache
(
pCtg
,
msg
->
dbFName
,
&
dbCache
));
CTG_ERR_
JRET
(
ctgGet
DBCache
(
pCtg
,
msg
->
dbFName
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not exist, ignore epset update"
,
msg
->
dbFName
);
ctgDebug
(
"db %s not exist, ignore epset update"
,
msg
->
dbFName
);
goto
_return
;
goto
_return
;
}
}
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgWLockVgInfo
(
pCtg
,
dbCache
));
CTG_ERR_RET
(
ctgWAcquireVgInfo
(
pCtg
,
dbCache
));
SDBVgInfo
*
vgInfo
=
dbCache
->
vgCache
.
vgInfo
;
if
(
NULL
==
dbCache
->
vgInfo
)
{
if
(
NULL
==
vgInfo
)
{
ctgWReleaseVgInfo
(
dbCache
);
ctgDebug
(
"vgroup in db %s not cached, ignore epset update"
,
msg
->
dbFName
);
ctgDebug
(
"vgroup in db %s not cached, ignore epset update"
,
msg
->
dbFName
);
goto
_return
;
goto
_return
;
}
}
SVgroupInfo
*
pInfo
=
taosHashGet
(
dbCache
->
vgInfo
->
vgHash
,
&
msg
->
vgId
,
sizeof
(
msg
->
vgId
));
SVgroupInfo
*
pInfo
=
taosHashGet
(
vgInfo
->
vgHash
,
&
msg
->
vgId
,
sizeof
(
msg
->
vgId
));
if
(
NULL
==
pInfo
)
{
if
(
NULL
==
pInfo
)
{
ctgWReleaseVgInfo
(
dbCache
);
ctgDebug
(
"no vgroup %d in db %s, ignore epset update"
,
msg
->
vgId
,
msg
->
dbFName
);
ctgDebug
(
"no vgroup %d in db %s, ignore epset update"
,
msg
->
vgId
,
msg
->
dbFName
);
goto
_return
;
goto
_return
;
}
}
...
@@ -1599,14 +1830,68 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
...
@@ -1599,14 +1830,68 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
pInfo
->
epSet
=
msg
->
epSet
;
pInfo
->
epSet
=
msg
->
epSet
;
ctgWReleaseVgInfo
(
dbCache
);
_return:
_return:
if
(
dbCache
)
{
if
(
dbCache
)
{
ctgReleaseDBCache
(
msg
->
pCtg
,
dbCache
);
ctgWUnlockVgInfo
(
dbCache
);
}
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgOpUpdateTbIndex
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgUpdateTbIndexMsg
*
msg
=
operation
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
STableIndex
*
pIndex
=
msg
->
pIndex
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_JRET
(
ctgGetAddDBCache
(
pCtg
,
pIndex
->
dbFName
,
0
,
&
dbCache
));
CTG_ERR_JRET
(
ctgWriteTbIndexToCache
(
pCtg
,
dbCache
,
pIndex
->
dbFName
,
pIndex
->
tbName
,
&
pIndex
));
_return:
if
(
pIndex
)
{
taosArrayDestroyEx
(
pIndex
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
pIndex
);
}
}
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgOpDropTbIndex
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgDropTbIndexMsg
*
msg
=
operation
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBCache
(
pCtg
,
msg
->
dbFName
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
return
TSDB_CODE_SUCCESS
;
}
STableIndex
*
pIndex
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
));
if
(
NULL
==
pIndex
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
strcpy
(
pIndex
->
tbName
,
msg
->
tbName
);
strcpy
(
pIndex
->
dbFName
,
msg
->
dbFName
);
pIndex
->
version
=
-
1
;
CTG_ERR_JRET
(
ctgWriteTbIndexToCache
(
pCtg
,
dbCache
,
pIndex
->
dbFName
,
pIndex
->
tbName
,
&
pIndex
));
_return:
if
(
pIndex
)
{
taosArrayDestroyEx
(
pIndex
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
pIndex
);
}
taosMemoryFreeClear
(
msg
);
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
CTG_RET
(
code
);
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
b13c31c9
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "catalogInt.h"
#include "catalogInt.h"
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
SCtgDebug
gCTGDebug
=
{
.
apiEnable
=
true
};
SCtgDebug
gCTGDebug
=
{
0
};
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
void
ctgdUserCallback
(
SMetaData
*
pResult
,
void
*
param
,
int32_t
code
)
{
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
ASSERT
(
*
(
int32_t
*
)
param
==
1
);
...
@@ -266,11 +266,11 @@ int32_t ctgdGetStatNum(char *option, void *res) {
...
@@ -266,11 +266,11 @@ int32_t ctgdGetStatNum(char *option, void *res) {
}
}
int32_t
ctgdGetTbMetaNum
(
SCtgDBCache
*
dbCache
)
{
int32_t
ctgdGetTbMetaNum
(
SCtgDBCache
*
dbCache
)
{
return
dbCache
->
tbCache
.
metaCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
tbCache
.
meta
Cache
)
:
0
;
return
dbCache
->
tbCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
tb
Cache
)
:
0
;
}
}
int32_t
ctgdGetStbNum
(
SCtgDBCache
*
dbCache
)
{
int32_t
ctgdGetStbNum
(
SCtgDBCache
*
dbCache
)
{
return
dbCache
->
tbCache
.
stbCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
return
dbCache
->
stbCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
stbCache
)
:
0
;
}
}
int32_t
ctgdGetRentNum
(
SCtgRentMgmt
*
rent
)
{
int32_t
ctgdGetRentNum
(
SCtgRentMgmt
*
rent
)
{
...
@@ -363,17 +363,17 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
...
@@ -363,17 +363,17 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
dbFName
=
taosHashGetKey
(
pIter
,
&
len
);
dbFName
=
taosHashGetKey
(
pIter
,
&
len
);
int32_t
metaNum
=
dbCache
->
tbCache
.
metaCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
meta
Cache
)
:
0
;
int32_t
metaNum
=
dbCache
->
tbCache
?
taosHashGetSize
(
dbCache
->
tb
Cache
)
:
0
;
int32_t
stbNum
=
dbCache
->
tbCache
.
stbCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
stbCache
?
taosHashGetSize
(
dbCache
->
stbCache
)
:
0
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
hashMethod
=
-
1
;
int32_t
hashMethod
=
-
1
;
int32_t
vgNum
=
0
;
int32_t
vgNum
=
0
;
if
(
dbCache
->
vgInfo
)
{
if
(
dbCache
->
vg
Cache
.
vg
Info
)
{
vgVersion
=
dbCache
->
vgInfo
->
vgVersion
;
vgVersion
=
dbCache
->
vg
Cache
.
vg
Info
->
vgVersion
;
hashMethod
=
dbCache
->
vgInfo
->
hashMethod
;
hashMethod
=
dbCache
->
vg
Cache
.
vg
Info
->
hashMethod
;
if
(
dbCache
->
vgInfo
->
vgHash
)
{
if
(
dbCache
->
vg
Cache
.
vg
Info
->
vgHash
)
{
vgNum
=
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
vgNum
=
taosHashGetSize
(
dbCache
->
vg
Cache
.
vg
Info
->
vgHash
);
}
}
}
}
...
...
source/libs/catalog/src/ctgRemote.c
浏览文件 @
b13c31c9
...
@@ -431,7 +431,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
...
@@ -431,7 +431,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTbIndexFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
name
,
S
Array
*
*
out
,
SCtgTask
*
pTask
)
{
int32_t
ctgGetTbIndexFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SName
*
name
,
S
TableIndex
*
out
,
SCtgTask
*
pTask
)
{
char
*
msg
=
NULL
;
char
*
msg
=
NULL
;
int32_t
msgLen
=
0
;
int32_t
msgLen
=
0
;
int32_t
reqType
=
TDMT_MND_GET_TABLE_INDEX
;
int32_t
reqType
=
TDMT_MND_GET_TABLE_INDEX
;
...
@@ -448,10 +448,11 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
...
@@ -448,10 +448,11 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
}
}
if
(
pTask
)
{
if
(
pTask
)
{
void
*
pOut
=
taosMemoryCalloc
(
1
,
POINTER_BYTES
);
void
*
pOut
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIndex
)
);
if
(
NULL
==
pOut
)
{
if
(
NULL
==
pOut
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
CTG_ERR_RET
(
ctgUpdateMsgCtx
(
&
pTask
->
msgCtx
,
reqType
,
pOut
,
(
char
*
)
tbFName
));
CTG_ERR_RET
(
ctgUpdateMsgCtx
(
&
pTask
->
msgCtx
,
reqType
,
pOut
,
(
char
*
)
tbFName
));
CTG_RET
(
ctgAsyncSendMsg
(
pCtg
,
pConn
,
pTask
,
reqType
,
msg
,
msgLen
));
CTG_RET
(
ctgAsyncSendMsg
(
pCtg
,
pConn
,
pTask
,
reqType
,
msg
,
msgLen
));
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
b13c31c9
...
@@ -44,6 +44,16 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
...
@@ -44,6 +44,16 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
}
}
}
}
void
ctgFreeSTableIndex
(
void
*
info
)
{
if
(
NULL
==
info
)
{
return
;
}
STableIndex
*
pInfo
=
(
STableIndex
*
)
info
;
taosArrayDestroyEx
(
pInfo
->
pIndex
,
tFreeSTableIndexInfo
);
}
void
ctgFreeSMetaData
(
SMetaData
*
pData
)
{
void
ctgFreeSMetaData
(
SMetaData
*
pData
)
{
taosArrayDestroy
(
pData
->
pTableMeta
);
taosArrayDestroy
(
pData
->
pTableMeta
);
pData
->
pTableMeta
=
NULL
;
pData
->
pTableMeta
=
NULL
;
...
@@ -110,25 +120,39 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
...
@@ -110,25 +120,39 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) {
taosMemoryFreeClear
(
mgmt
->
slots
);
taosMemoryFreeClear
(
mgmt
->
slots
);
}
}
void
ctgFreeStbMetaCache
(
SCtgDBCache
*
dbCache
)
{
if
(
NULL
==
dbCache
->
stbCache
)
{
return
;
}
void
ctgFreeTbMetaCache
(
SCtgTbMetaCache
*
cache
)
{
int32_t
stblNum
=
taosHashGetSize
(
dbCache
->
stbCache
);
CTG_LOCK
(
CTG_WRITE
,
&
cache
->
stbLock
);
taosHashCleanup
(
dbCache
->
stbCache
);
if
(
cache
->
stbCache
)
{
dbCache
->
stbCache
=
NULL
;
int32_t
stblNum
=
taosHashGetSize
(
cache
->
stbCache
);
CTG_CACHE_STAT_DEC
(
stblNum
,
stblNum
);
taosHashCleanup
(
cache
->
stbCache
);
}
cache
->
stbCache
=
NULL
;
CTG_CACHE_STAT_DEC
(
stblNum
,
stblNum
);
void
ctgFreeTbCacheImpl
(
SCtgTbCache
*
pCache
)
{
taosMemoryFreeClear
(
pCache
->
pMeta
);
if
(
pCache
->
pIndex
)
{
taosArrayDestroyEx
(
pCache
->
pIndex
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
pCache
->
pIndex
);
}
}
void
ctgFreeTbCache
(
SCtgDBCache
*
dbCache
)
{
if
(
NULL
==
dbCache
->
tbCache
)
{
return
;
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
cache
->
stbLock
);
CTG_LOCK
(
CTG_WRITE
,
&
cache
->
metaLock
);
int32_t
tblNum
=
taosHashGetSize
(
dbCache
->
tbCache
);
if
(
cache
->
metaCache
)
{
SCtgTbCache
*
pCache
=
taosHashIterate
(
dbCache
->
tbCache
,
NULL
);
int32_t
tblNum
=
taosHashGetSize
(
cache
->
metaCache
);
while
(
NULL
!=
pCache
)
{
taosHashCleanup
(
cache
->
metaCache
);
ctgFreeTbCacheImpl
(
pCache
);
cache
->
metaCache
=
NULL
;
pCache
=
taosHashIterate
(
dbCache
->
tbCache
,
pCache
);
CTG_CACHE_STAT_DEC
(
tblNum
,
tblNum
);
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
cache
->
metaLock
);
taosHashCleanup
(
dbCache
->
tbCache
);
dbCache
->
tbCache
=
NULL
;
CTG_CACHE_STAT_DEC
(
tblNum
,
tblNum
);
}
}
void
ctgFreeVgInfo
(
SDBVgInfo
*
vgInfo
)
{
void
ctgFreeVgInfo
(
SDBVgInfo
*
vgInfo
)
{
...
@@ -144,16 +168,18 @@ void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
...
@@ -144,16 +168,18 @@ void ctgFreeVgInfo(SDBVgInfo *vgInfo) {
taosMemoryFreeClear
(
vgInfo
);
taosMemoryFreeClear
(
vgInfo
);
}
}
void
ctgFreeVgInfoCache
(
SCtgDBCache
*
dbCache
)
{
ctgFreeVgInfo
(
dbCache
->
vgCache
.
vgInfo
);
}
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
)
{
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
)
{
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
return
;
return
;
}
}
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
ctgFreeVgInfoCache
(
dbCache
);
ctgFreeVgInfo
(
dbCache
->
vgInfo
);
ctgFreeStbMetaCache
(
dbCache
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
ctgFreeTbCache
(
dbCache
);
ctgFreeTbMetaCache
(
&
dbCache
->
tbCache
);
}
}
...
@@ -167,16 +193,13 @@ void ctgFreeHandle(SCatalog* pCtg) {
...
@@ -167,16 +193,13 @@ void ctgFreeHandle(SCatalog* pCtg) {
void
*
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
SCtgDBCache
*
dbCache
=
pIter
;
SCtgDBCache
*
dbCache
=
pIter
;
atomic_store_8
(
&
dbCache
->
deleted
,
1
);
atomic_store_8
(
&
dbCache
->
deleted
,
1
);
ctgFreeDbCache
(
dbCache
);
ctgFreeDbCache
(
dbCache
);
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
pIter
);
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
pIter
);
}
}
taosHashCleanup
(
pCtg
->
dbCache
);
taosHashCleanup
(
pCtg
->
dbCache
);
CTG_CACHE_STAT_DEC
(
dbNum
,
dbNum
);
CTG_CACHE_STAT_DEC
(
dbNum
,
dbNum
);
}
}
...
@@ -186,14 +209,12 @@ void ctgFreeHandle(SCatalog* pCtg) {
...
@@ -186,14 +209,12 @@ void ctgFreeHandle(SCatalog* pCtg) {
void
*
pIter
=
taosHashIterate
(
pCtg
->
userCache
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pCtg
->
userCache
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
SCtgUserAuth
*
userCache
=
pIter
;
SCtgUserAuth
*
userCache
=
pIter
;
ctgFreeSCtgUserAuth
(
userCache
);
ctgFreeSCtgUserAuth
(
userCache
);
pIter
=
taosHashIterate
(
pCtg
->
userCache
,
pIter
);
pIter
=
taosHashIterate
(
pCtg
->
userCache
,
pIter
);
}
}
taosHashCleanup
(
pCtg
->
userCache
);
taosHashCleanup
(
pCtg
->
userCache
);
CTG_CACHE_STAT_DEC
(
userNum
,
userNum
);
CTG_CACHE_STAT_DEC
(
userNum
,
userNum
);
}
}
...
@@ -252,9 +273,9 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
...
@@ -252,9 +273,9 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
break
;
break
;
}
}
case
TDMT_MND_GET_TABLE_INDEX
:
{
case
TDMT_MND_GET_TABLE_INDEX
:
{
S
Array
**
pOut
=
(
SArray
*
*
)
pCtx
->
out
;
S
TableIndex
*
pOut
=
(
STableIndex
*
)
pCtx
->
out
;
if
(
pOut
)
{
if
(
pOut
)
{
taosArrayDestroyEx
(
*
pOut
,
tFreeSTableIndexInfo
);
taosArrayDestroyEx
(
pOut
->
pIndex
,
tFreeSTableIndexInfo
);
taosMemoryFreeClear
(
pCtx
->
out
);
taosMemoryFreeClear
(
pCtx
->
out
);
}
}
break
;
break
;
...
@@ -535,9 +556,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
...
@@ -535,9 +556,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
}
}
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
int32_t
ctgStbVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
uint64_t
*
)
key1
<
((
SSTable
Meta
Version
*
)
key2
)
->
suid
)
{
if
(
*
(
uint64_t
*
)
key1
<
((
SSTableVersion
*
)
key2
)
->
suid
)
{
return
-
1
;
return
-
1
;
}
else
if
(
*
(
uint64_t
*
)
key1
>
((
SSTable
Meta
Version
*
)
key2
)
->
suid
)
{
}
else
if
(
*
(
uint64_t
*
)
key1
>
((
SSTableVersion
*
)
key2
)
->
suid
)
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
...
@@ -555,9 +576,9 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) {
...
@@ -555,9 +576,9 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) {
}
}
int32_t
ctgStbVersionSortCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
int32_t
ctgStbVersionSortCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
SSTable
MetaVersion
*
)
key1
)
->
suid
<
((
SSTableMeta
Version
*
)
key2
)
->
suid
)
{
if
(((
SSTable
Version
*
)
key1
)
->
suid
<
((
SSTable
Version
*
)
key2
)
->
suid
)
{
return
-
1
;
return
-
1
;
}
else
if
(((
SSTable
MetaVersion
*
)
key1
)
->
suid
>
((
SSTableMeta
Version
*
)
key2
)
->
suid
)
{
}
else
if
(((
SSTable
Version
*
)
key1
)
->
suid
>
((
SSTable
Version
*
)
key2
)
->
suid
)
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
...
@@ -640,6 +661,27 @@ int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput)
...
@@ -640,6 +661,27 @@ int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgCloneTableIndex
(
SArray
*
pIndex
,
SArray
**
pRes
)
{
if
(
NULL
==
pIndex
)
{
*
pRes
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
num
=
taosArrayGetSize
(
pIndex
);
*
pRes
=
taosArrayInit
(
num
,
sizeof
(
STableIndexInfo
));
if
(
NULL
==
*
pRes
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
STableIndexInfo
*
pInfo
=
taosArrayGet
(
pIndex
,
i
);
taosArrayPush
(
*
pRes
,
pInfo
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
SCtgTask
*
pTask
)
{
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
SCtgTask
*
pTask
)
{
if
(
msgType
==
TDMT_VND_TABLE_META
)
{
if
(
msgType
==
TDMT_VND_TABLE_META
)
{
SCtgTbMetaCtx
*
ctx
=
(
SCtgTbMetaCtx
*
)
pTask
->
taskCtx
;
SCtgTbMetaCtx
*
ctx
=
(
SCtgTbMetaCtx
*
)
pTask
->
taskCtx
;
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
b13c31c9
...
@@ -895,9 +895,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
...
@@ -895,9 +895,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
output
=
(
STableMetaOutput
*
)
taosMemoryMalloc
(
sizeof
(
STableMetaOutput
));
output
=
(
STableMetaOutput
*
)
taosMemoryMalloc
(
sizeof
(
STableMetaOutput
));
ctgTestBuildCTableMetaOutput
(
output
);
ctgTestBuildCTableMetaOutput
(
output
);
SCtgUpdateTb
lMsg
*
msg
=
(
SCtgUpdateTblMsg
*
)
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTbl
Msg
));
SCtgUpdateTb
MetaMsg
*
msg
=
(
SCtgUpdateTbMetaMsg
*
)
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTbMeta
Msg
));
msg
->
pCtg
=
pCtg
;
msg
->
pCtg
=
pCtg
;
msg
->
output
=
output
;
msg
->
pMeta
=
output
;
operation
.
data
=
msg
;
operation
.
data
=
msg
;
code
=
ctgOpUpdateTbMeta
(
&
operation
);
code
=
ctgOpUpdateTbMeta
(
&
operation
);
...
@@ -989,7 +989,7 @@ TEST(tableMeta, normalTable) {
...
@@ -989,7 +989,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
SDbVgVersion
*
dbs
=
NULL
;
SDbVgVersion
*
dbs
=
NULL
;
SSTable
Meta
Version
*
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
;
while
(
i
<
5
)
{
while
(
i
<
5
)
{
...
@@ -1098,7 +1098,7 @@ TEST(tableMeta, childTableCase) {
...
@@ -1098,7 +1098,7 @@ TEST(tableMeta, childTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
SDbVgVersion
*
dbs
=
NULL
;
SDbVgVersion
*
dbs
=
NULL
;
SSTable
Meta
Version
*
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
;
while
(
i
<
5
)
{
while
(
i
<
5
)
{
...
@@ -1220,7 +1220,7 @@ TEST(tableMeta, superTableCase) {
...
@@ -1220,7 +1220,7 @@ TEST(tableMeta, superTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
SDbVgVersion
*
dbs
=
NULL
;
SDbVgVersion
*
dbs
=
NULL
;
SSTable
Meta
Version
*
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
;
while
(
i
<
5
)
{
while
(
i
<
5
)
{
...
@@ -2299,7 +2299,7 @@ TEST(rentTest, allRent) {
...
@@ -2299,7 +2299,7 @@ TEST(rentTest, allRent) {
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
ctgTestStop
=
false
;
ctgTestStop
=
false
;
SDbVgVersion
*
dbs
=
NULL
;
SDbVgVersion
*
dbs
=
NULL
;
SSTable
Meta
Version
*
stable
=
NULL
;
SSTableVersion
*
stable
=
NULL
;
uint32_t
num
=
0
;
uint32_t
num
=
0
;
ctgTestInitLogFile
();
ctgTestInitLogFile
();
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
b13c31c9
...
@@ -582,6 +582,15 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
...
@@ -582,6 +582,15 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
return
offset
;
return
offset
;
}
}
static
void
clearPartitionOperator
(
SPartitionOperatorInfo
*
pInfo
)
{
void
*
ite
=
NULL
;
while
(
(
ite
=
taosHashIterate
(
pInfo
->
pGroupSet
,
ite
))
!=
NULL
)
{
taosArrayDestroy
(
((
SDataGroupInfo
*
)
ite
)
->
pPageList
);
}
taosHashClear
(
pInfo
->
pGroupSet
);
clearDiskbasedBuf
(
pInfo
->
pBuf
);
}
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
...
@@ -591,6 +600,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
...
@@ -591,6 +600,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
pInfo
->
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pInfo
->
pGroupIter
);
pInfo
->
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pInfo
->
pGroupIter
);
if
(
pInfo
->
pGroupIter
==
NULL
)
{
if
(
pInfo
->
pGroupIter
==
NULL
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
clearPartitionOperator
(
pInfo
);
return
NULL
;
return
NULL
;
}
}
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
b13c31c9
...
@@ -97,7 +97,14 @@ static int32_t sifGetOperParamNum(EOperatorType ty) {
...
@@ -97,7 +97,14 @@ static int32_t sifGetOperParamNum(EOperatorType ty) {
}
}
return
2
;
return
2
;
}
}
static
int32_t
sifValidateColumn
(
SColumnNode
*
cn
)
{
static
int32_t
sifValidOp
(
EOperatorType
ty
)
{
if
((
ty
>=
OP_TYPE_ADD
&&
ty
<=
OP_TYPE_BIT_OR
)
||
(
ty
==
OP_TYPE_IN
||
ty
==
OP_TYPE_NOT_IN
)
||
(
ty
==
OP_TYPE_LIKE
||
ty
==
OP_TYPE_NOT_LIKE
||
ty
==
OP_TYPE_MATCH
||
ty
==
OP_TYPE_NMATCH
))
{
return
-
1
;
}
return
0
;
}
static
int32_t
sifValidColumn
(
SColumnNode
*
cn
)
{
// add more check
// add more check
if
(
cn
==
NULL
)
{
if
(
cn
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_INPUT
;
return
TSDB_CODE_QRY_INVALID_INPUT
;
...
@@ -176,6 +183,7 @@ static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
...
@@ -176,6 +183,7 @@ static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
memcpy
(
param
->
colName
,
r
->
literal
,
strlen
(
r
->
literal
));
memcpy
(
param
->
colName
,
r
->
literal
,
strlen
(
r
->
literal
));
// sprintf(param->colName, "%s_%s", l->colName, r->literal);
// sprintf(param->colName, "%s_%s", l->colName, r->literal);
param
->
colValType
=
r
->
typeData
;
param
->
colValType
=
r
->
typeData
;
param
->
status
=
SFLT_COARSE_INDEX
;
return
0
;
return
0
;
// memcpy(param->colName, l->colName, sizeof(l->colName));
// memcpy(param->colName, l->colName, sizeof(l->colName));
}
}
...
@@ -197,7 +205,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
...
@@ -197,7 +205,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
case
QUERY_NODE_COLUMN
:
{
case
QUERY_NODE_COLUMN
:
{
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
/*only support tag column*/
/*only support tag column*/
SIF_ERR_RET
(
sifValid
ate
Column
(
cn
));
SIF_ERR_RET
(
sifValidColumn
(
cn
));
param
->
colId
=
cn
->
colId
;
param
->
colId
=
cn
->
colId
;
param
->
colValType
=
cn
->
node
.
resType
.
type
;
param
->
colValType
=
cn
->
node
.
resType
.
type
;
...
@@ -247,11 +255,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
...
@@ -247,11 +255,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
return
code
;
return
code
;
}
}
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
if
(
NULL
==
paramList
)
{
if
(
NULL
==
paramList
)
{
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
if
(
nodeType
(
node
->
pLeft
)
==
QUERY_NODE_OPERATOR
)
{
if
(
nodeType
(
node
->
pLeft
)
==
QUERY_NODE_OPERATOR
&&
(((
SOperatorNode
*
)(
node
->
pLeft
))
->
opType
==
OP_TYPE_JSON_GET_VALUE
))
{
SNode
*
interNode
=
(
node
->
pLeft
);
SNode
*
interNode
=
(
node
->
pLeft
);
SIF_ERR_JRET
(
sifInitJsonParam
(
interNode
,
&
paramList
[
0
],
ctx
));
SIF_ERR_JRET
(
sifInitJsonParam
(
interNode
,
&
paramList
[
0
],
ctx
));
if
(
nParam
>
1
)
{
if
(
nParam
>
1
)
{
...
@@ -505,6 +515,11 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta
...
@@ -505,6 +515,11 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
sifValidOp
(
node
->
opType
)
<
0
)
{
output
->
status
=
SFLT_NOT_INDEX
;
return
code
;
}
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
if
(
nParam
<=
1
)
{
output
->
status
=
SFLT_NOT_INDEX
;
output
->
status
=
SFLT_NOT_INDEX
;
...
@@ -513,9 +528,15 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
...
@@ -513,9 +528,15 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
return
code
;
return
code
;
}
}
SIFParam
*
params
=
NULL
;
SIFParam
*
params
=
NULL
;
SIF_ERR_RET
(
sifInitOperParams
(
&
params
,
node
,
ctx
));
SIF_ERR_RET
(
sifInitOperParams
(
&
params
,
node
,
ctx
));
if
(
params
[
0
].
status
==
SFLT_NOT_INDEX
||
(
nParam
>
1
&&
params
[
1
].
status
==
SFLT_NOT_INDEX
))
{
output
->
status
=
SFLT_NOT_INDEX
;
return
code
;
}
// ugly code, refactor later
// ugly code, refactor later
output
->
arg
=
ctx
->
arg
;
output
->
arg
=
ctx
->
arg
;
sif_func_t
operFn
=
sifNullFunc
;
sif_func_t
operFn
=
sifNullFunc
;
...
...
source/libs/parser/src/parInsertData.c
浏览文件 @
b13c31c9
...
@@ -283,6 +283,8 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) {
...
@@ -283,6 +283,8 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) {
if
(
!
dataBuf
->
ordered
)
{
if
(
!
dataBuf
->
ordered
)
{
char
*
pBlockData
=
pBlocks
->
data
;
char
*
pBlockData
=
pBlocks
->
data
;
// todo. qsort is unstable, if timestamp is same, should get the last one
qsort
(
pBlockData
,
pBlocks
->
numOfRows
,
dataBuf
->
rowSize
,
rowDataCompar
);
qsort
(
pBlockData
,
pBlocks
->
numOfRows
,
dataBuf
->
rowSize
,
rowDataCompar
);
int32_t
i
=
0
;
int32_t
i
=
0
;
...
@@ -350,6 +352,8 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
...
@@ -350,6 +352,8 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
if
(
!
dataBuf
->
ordered
)
{
if
(
!
dataBuf
->
ordered
)
{
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
// todo. qsort is unstable, if timestamp is same, should get the last one
qsort
(
pBlkKeyTuple
,
nRows
,
sizeof
(
SBlockKeyTuple
),
rowDataCompar
);
qsort
(
pBlkKeyTuple
,
nRows
,
sizeof
(
SBlockKeyTuple
),
rowDataCompar
);
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
b13c31c9
...
@@ -484,13 +484,11 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
...
@@ -484,13 +484,11 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
}
STableIndexRsp
out
=
{
0
}
;
STableIndexRsp
*
out
=
(
STableIndexRsp
*
)
output
;
if
(
tDeserializeSTableIndexRsp
(
msg
,
msgSize
,
&
out
)
!=
0
)
{
if
(
tDeserializeSTableIndexRsp
(
msg
,
msgSize
,
out
)
!=
0
)
{
qError
(
"tDeserializeSTableIndexRsp failed, msgSize:%d"
,
msgSize
);
qError
(
"tDeserializeSTableIndexRsp failed, msgSize:%d"
,
msgSize
);
return
TSDB_CODE_INVALID_MSG
;
return
TSDB_CODE_INVALID_MSG
;
}
}
*
(
void
**
)
output
=
out
.
pIndex
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
b13c31c9
...
@@ -837,7 +837,6 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
...
@@ -837,7 +837,6 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
SQWorker
*
mgmt
=
qwAcquire
(
refId
);
SQWorker
*
mgmt
=
qwAcquire
(
refId
);
if
(
NULL
==
mgmt
)
{
if
(
NULL
==
mgmt
)
{
QW_DLOG
(
"qwAcquire %"
PRIx64
"failed"
,
refId
);
QW_DLOG
(
"qwAcquire %"
PRIx64
"failed"
,
refId
);
taosMemoryFree
(
param
);
return
;
return
;
}
}
...
...
source/libs/scalar/src/filter.c
浏览文件 @
b13c31c9
...
@@ -1476,6 +1476,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
...
@@ -1476,6 +1476,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_VALUE
].
num
;
++
i
)
{
for
(
uint32_t
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_VALUE
].
num
;
++
i
)
{
SFilterField
*
field
=
&
info
->
fields
[
FLD_TYPE_VALUE
].
fields
[
i
];
SFilterField
*
field
=
&
info
->
fields
[
FLD_TYPE_VALUE
].
fields
[
i
];
if
(
field
->
desc
)
{
if
(
field
->
desc
)
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
field
->
desc
))
{
qDebug
(
"VAL%d => [type:not value node][val:NIL]"
,
i
);
//TODO
continue
;
}
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
if
(
dType
->
type
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
if
(
dType
->
type
==
TSDB_DATA_TYPE_VALUE_ARRAY
)
{
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
b13c31c9
...
@@ -168,6 +168,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo);
...
@@ -168,6 +168,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo);
void
syncNodeStart
(
SSyncNode
*
pSyncNode
);
void
syncNodeStart
(
SSyncNode
*
pSyncNode
);
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
);
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
// option
// option
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
...
@@ -232,6 +233,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
...
@@ -232,6 +233,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
bool
syncNodeInRaftGroup
(
SSyncNode
*
ths
,
SRaftId
*
pRaftId
);
bool
syncNodeInRaftGroup
(
SSyncNode
*
ths
,
SRaftId
*
pRaftId
);
SSyncSnapshotSender
*
syncNodeGetSnapshotSender
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
SSyncSnapshotSender
*
syncNodeGetSnapshotSender
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
void
syncStartNormal
(
int64_t
rid
);
void
syncStartStandBy
(
int64_t
rid
);
// for debug --------------
// for debug --------------
void
syncNodePrint
(
SSyncNode
*
pObj
);
void
syncNodePrint
(
SSyncNode
*
pObj
);
void
syncNodePrint2
(
char
*
s
,
SSyncNode
*
pObj
);
void
syncNodePrint2
(
char
*
s
,
SSyncNode
*
pObj
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
b13c31c9
...
@@ -995,7 +995,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -995,7 +995,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
ths
->
commitIndex
=
snapshot
.
lastApplyIndex
;
ths
->
commitIndex
=
snapshot
.
lastApplyIndex
;
sDebug
(
"vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s"
,
ths
->
vgId
,
commitBegin
,
sDebug
(
"vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s"
,
ths
->
vgId
,
commitBegin
,
commitEnd
,
syncUtilState2String
(
ths
->
state
));
commitEnd
,
syncUtilState2String
(
ths
->
state
));
}
}
SyncIndex
beginIndex
=
ths
->
commitIndex
+
1
;
SyncIndex
beginIndex
=
ths
->
commitIndex
+
1
;
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
b13c31c9
...
@@ -57,7 +57,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -57,7 +57,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
pSyncNode
->
commitIndex
=
snapshot
.
lastApplyIndex
;
pSyncNode
->
commitIndex
=
snapshot
.
lastApplyIndex
;
sDebug
(
"vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s"
,
pSyncNode
->
vgId
,
sDebug
(
"vgId:%d sync event commit by snapshot from index:%ld to index:%ld, %s"
,
pSyncNode
->
vgId
,
pSyncNode
->
commitIndex
,
snapshot
.
lastApplyIndex
,
syncUtilState2String
(
pSyncNode
->
state
));
pSyncNode
->
commitIndex
,
snapshot
.
lastApplyIndex
,
syncUtilState2String
(
pSyncNode
->
state
));
}
}
// update commit index
// update commit index
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
b13c31c9
...
@@ -149,12 +149,12 @@ void syncStop(int64_t rid) {
...
@@ -149,12 +149,12 @@ void syncStop(int64_t rid) {
int32_t
syncSetStandby
(
int64_t
rid
)
{
int32_t
syncSetStandby
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
return
-
1
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
-
1
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
// state change
// state change
...
@@ -174,14 +174,88 @@ int32_t syncSetStandby(int64_t rid) {
...
@@ -174,14 +174,88 @@ int32_t syncSetStandby(int64_t rid) {
return
0
;
return
0
;
}
}
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pSyncCfg
)
{
int32_t
syncReconfigBuild
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
,
SRpcMsg
*
pRpcMsg
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_OTHER_ERROR
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
int32_t
ret
=
0
;
int32_t
ret
=
0
;
char
*
newconfig
=
syncCfg2Str
((
SSyncCfg
*
)
pSyncCfg
);
bool
IamInNew
=
false
;
for
(
int
i
=
0
;
i
<
pNewCfg
->
replicaNum
;
++
i
)
{
if
(
strcmp
((
pNewCfg
->
nodeInfo
)[
i
].
nodeFqdn
,
pSyncNode
->
myNodeInfo
.
nodeFqdn
)
==
0
&&
(
pNewCfg
->
nodeInfo
)[
i
].
nodePort
==
pSyncNode
->
myNodeInfo
.
nodePort
)
{
IamInNew
=
true
;
}
/*
SRaftId newId;
newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort);
newId.vgId = pSyncNode->vgId;
if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) {
IamInNew = true;
}
*/
}
if
(
!
IamInNew
)
{
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
TAOS_SYNC_NOT_IN_NEW_CONFIG
;
}
char
*
newconfig
=
syncCfg2Str
((
SSyncCfg
*
)
pNewCfg
);
pRpcMsg
->
msgType
=
TDMT_SYNC_CONFIG_CHANGE
;
pRpcMsg
->
info
.
noResp
=
1
;
pRpcMsg
->
contLen
=
strlen
(
newconfig
)
+
1
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
snprintf
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
"%s"
,
newconfig
);
taosMemoryFree
(
newconfig
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
}
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_OTHER_ERROR
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
bool
IamInNew
=
false
;
for
(
int
i
=
0
;
i
<
pNewCfg
->
replicaNum
;
++
i
)
{
if
(
strcmp
((
pNewCfg
->
nodeInfo
)[
i
].
nodeFqdn
,
pSyncNode
->
myNodeInfo
.
nodeFqdn
)
==
0
&&
(
pNewCfg
->
nodeInfo
)[
i
].
nodePort
==
pSyncNode
->
myNodeInfo
.
nodePort
)
{
IamInNew
=
true
;
}
/*
// some problem in inet_addr
SRaftId newId = EMPTY_RAFT_ID;
newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort);
newId.vgId = pSyncNode->vgId;
if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) {
IamInNew = true;
}
*/
}
if
(
!
IamInNew
)
{
sError
(
"sync reconfig error, not in new config"
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
TAOS_SYNC_NOT_IN_NEW_CONFIG
;
}
char
*
newconfig
=
syncCfg2Str
((
SSyncCfg
*
)
pNewCfg
);
if
(
gRaftDetailLog
)
{
if
(
gRaftDetailLog
)
{
sInfo
(
"==syncReconfig== newconfig:%s"
,
newconfig
);
sInfo
(
"==syncReconfig== newconfig:%s"
,
newconfig
);
}
}
int32_t
ret
=
0
;
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
msgType
=
TDMT_SYNC_CONFIG_CHANGE
;
rpcMsg
.
msgType
=
TDMT_SYNC_CONFIG_CHANGE
;
rpcMsg
.
info
.
noResp
=
1
;
rpcMsg
.
info
.
noResp
=
1
;
...
@@ -189,58 +263,59 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) {
...
@@ -189,58 +263,59 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) {
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
snprintf
(
rpcMsg
.
pCont
,
rpcMsg
.
contLen
,
"%s"
,
newconfig
);
snprintf
(
rpcMsg
.
pCont
,
rpcMsg
.
contLen
,
"%s"
,
newconfig
);
taosMemoryFree
(
newconfig
);
taosMemoryFree
(
newconfig
);
ret
=
syncPropose
(
rid
,
&
rpcMsg
,
false
);
ret
=
syncNodePropose
(
pSyncNode
,
&
rpcMsg
,
false
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
return
ret
;
}
}
int32_t
syncLeaderTransfer
(
int64_t
rid
)
{
int32_t
syncLeaderTransfer
(
int64_t
rid
)
{
int32_t
ret
=
0
;
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_OTHER_ERROR
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
if
(
pSyncNode
->
peersNum
==
0
)
{
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
TAOS_SYNC_OTHER_ERROR
;
}
SNodeInfo
newLeader
=
(
pSyncNode
->
peersNodeInfo
)[
0
];
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
int32_t
ret
=
syncLeaderTransferTo
(
rid
,
newLeader
);
return
ret
;
return
ret
;
}
}
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
)
{
int32_t
syncLeaderTransferTo
(
int64_t
rid
,
SNodeInfo
newLeader
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
return
false
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
assert
(
rid
==
pSyncNode
->
rid
);
ASSERT
(
rid
==
pSyncNode
->
rid
);
int32_t
ret
=
0
;
int32_t
ret
=
0
;
if
(
pSyncNode
->
replicaNum
==
1
)
{
if
(
pSyncNode
->
replicaNum
==
1
)
{
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
sError
(
"only one replica, cannot drop leader"
);
sError
(
"only one replica, cannot drop leader"
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
TAOS_SYNC_ONLY_ONE_REPLICA
;
return
TAOS_SYNC_ONLY_ONE_REPLICA
;
}
}
SyncLeaderTransfer
*
pMsg
=
syncLeaderTransferBuild
(
pSyncNode
->
vgId
);
SyncLeaderTransfer
*
pMsg
=
syncLeaderTransferBuild
(
pSyncNode
->
vgId
);
pMsg
->
newLeaderId
.
addr
=
syncUtilAddr2U64
(
newLeader
.
nodeFqdn
,
newLeader
.
nodePort
);
pMsg
->
newLeaderId
.
addr
=
syncUtilAddr2U64
(
newLeader
.
nodeFqdn
,
newLeader
.
nodePort
);
pMsg
->
newLeaderId
.
vgId
=
pSyncNode
->
vgId
;
pMsg
->
newLeaderId
.
vgId
=
pSyncNode
->
vgId
;
pMsg
->
newNodeInfo
=
newLeader
;
ASSERT
(
pMsg
!=
NULL
);
ASSERT
(
pMsg
!=
NULL
);
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
syncLeaderTransfer2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncLeaderTransfer2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncLeaderTransferDestroy
(
pMsg
);
syncLeaderTransferDestroy
(
pMsg
);
ret
=
syncPropose
(
rid
,
&
rpcMsg
,
false
);
ret
=
syncNodePropose
(
pSyncNode
,
&
rpcMsg
,
false
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
return
ret
;
}
}
int32_t
syncReconfigRaw
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
,
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
char
*
newconfig
=
syncCfg2Str
((
SSyncCfg
*
)
pNewCfg
);
pRpcMsg
->
msgType
=
TDMT_SYNC_CONFIG_CHANGE
;
pRpcMsg
->
info
.
noResp
=
1
;
pRpcMsg
->
contLen
=
strlen
(
newconfig
)
+
1
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
snprintf
(
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
,
"%s"
,
newconfig
);
taosMemoryFree
(
newconfig
);
return
ret
;
}
bool
syncCanLeaderTransfer
(
int64_t
rid
)
{
bool
syncCanLeaderTransfer
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
...
@@ -273,8 +348,6 @@ bool syncCanLeaderTransfer(int64_t rid) {
...
@@ -273,8 +348,6 @@ bool syncCanLeaderTransfer(int64_t rid) {
return
matchOK
;
return
matchOK
;
}
}
int32_t
syncGiveUpLeader
(
int64_t
rid
)
{
return
0
;
}
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
syncForwardToPeer
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
syncPropose
(
rid
,
pMsg
,
isWeak
);
int32_t
ret
=
syncPropose
(
rid
,
pMsg
,
isWeak
);
return
ret
;
return
ret
;
...
@@ -469,16 +542,26 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
...
@@ -469,16 +542,26 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
SSyncNode
*
pSyncNode
=
taosAcquireRef
(
tsNodeRefId
,
rid
);
SSyncNode
*
pSyncNode
=
taosAcquireRef
(
tsNodeRefId
,
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_
PROPOSE_
OTHER_ERROR
;
return
TAOS_SYNC_OTHER_ERROR
;
}
}
assert
(
rid
==
pSyncNode
->
rid
);
assert
(
rid
==
pSyncNode
->
rid
);
sDebug
(
"vgId:%d sync event propose msgType:%s"
,
pSyncNode
->
vgId
,
TMSG_INFO
(
pMsg
->
msgType
));
ret
=
syncNodePropose
(
pSyncNode
,
pMsg
,
isWeak
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
}
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
TAOS_SYNC_PROPOSE_SUCCESS
;
sDebug
(
"vgId:%d sync event propose msgType:%s"
,
pSyncNode
->
vgId
,
TMSG_INFO
(
pMsg
->
msgType
));
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
SRespStub
stub
;
SRespStub
stub
;
stub
.
createTime
=
taosGetTimestampMs
();
stub
.
createTime
=
taosGetTimestampMs
();
stub
.
rpcMsg
=
*
pMsg
;
stub
.
rpcMsg
=
*
pMsg
;
uint64_t
seqNum
=
syncRespMgrAdd
(
pSyncNode
->
pSyncRespMgr
,
&
stub
);
uint64_t
seqNum
=
syncRespMgrAdd
(
pSyncNode
->
pSyncRespMgr
,
&
stub
);
sDebug
(
"vgId:%d
,
sync event propose, type:%s seq:%"
PRIu64
" handle:%p"
,
pSyncNode
->
vgId
,
TMSG_INFO
(
pMsg
->
msgType
),
sDebug
(
"vgId:%d sync event propose, type:%s seq:%"
PRIu64
" handle:%p"
,
pSyncNode
->
vgId
,
TMSG_INFO
(
pMsg
->
msgType
),
seqNum
,
pMsg
->
info
.
handle
);
seqNum
,
pMsg
->
info
.
handle
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild2
(
pMsg
,
seqNum
,
isWeak
,
pSyncNode
->
vgId
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild2
(
pMsg
,
seqNum
,
isWeak
,
pSyncNode
->
vgId
);
...
@@ -488,16 +571,14 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
...
@@ -488,16 +571,14 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak) {
if
(
pSyncNode
->
FpEqMsg
!=
NULL
&&
(
*
pSyncNode
->
FpEqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
)
==
0
)
{
if
(
pSyncNode
->
FpEqMsg
!=
NULL
&&
(
*
pSyncNode
->
FpEqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
)
==
0
)
{
ret
=
TAOS_SYNC_PROPOSE_SUCCESS
;
ret
=
TAOS_SYNC_PROPOSE_SUCCESS
;
}
else
{
}
else
{
s
Trace
(
"syncPropose pSyncNode->FpEqMsg is NULL"
);
s
Error
(
"syncPropose pSyncNode->FpEqMsg is NULL"
);
}
}
syncClientRequestDestroy
(
pSyncMsg
);
syncClientRequestDestroy
(
pSyncMsg
);
}
else
{
}
else
{
sDebug
(
"vgId:%d, failed to propose since not leader, type:%s handle:%p %s"
,
pSyncNode
->
vgId
,
sError
(
"syncPropose not leader, %s"
,
syncUtilState2String
(
pSyncNode
->
state
));
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
info
.
handle
,
syncUtilState2String
(
pSyncNode
->
state
));
ret
=
TAOS_SYNC_PROPOSE_NOT_LEADER
;
ret
=
TAOS_SYNC_PROPOSE_NOT_LEADER
;
}
}
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
return
ret
;
}
}
...
@@ -1162,8 +1243,14 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l
...
@@ -1162,8 +1243,14 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l
int32_t
oldReplicaNum
=
pSyncNode
->
replicaNum
;
int32_t
oldReplicaNum
=
pSyncNode
->
replicaNum
;
SRaftId
oldReplicasId
[
TSDB_MAX_REPLICA
];
SRaftId
oldReplicasId
[
TSDB_MAX_REPLICA
];
memcpy
(
oldReplicasId
,
pSyncNode
->
replicasId
,
sizeof
(
oldReplicasId
));
memcpy
(
oldReplicasId
,
pSyncNode
->
replicasId
,
sizeof
(
oldReplicasId
));
SSyncSnapshotSender
*
oldSenders
[
TSDB_MAX_REPLICA
];
SSyncSnapshotSender
*
oldSenders
[
TSDB_MAX_REPLICA
];
memcpy
(
oldSenders
,
pSyncNode
->
senders
,
sizeof
(
oldSenders
));
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
oldSenders
[
i
]
=
(
pSyncNode
->
senders
)[
i
];
sDebug
(
"vgId:%d sync event save senders %d, %p"
,
pSyncNode
->
vgId
,
i
,
oldSenders
[
i
]);
if
(
gRaftDetailLog
)
{
;
}
}
// init internal
// init internal
pSyncNode
->
myNodeInfo
=
pSyncNode
->
pRaftCfg
->
cfg
.
nodeInfo
[
pSyncNode
->
pRaftCfg
->
cfg
.
myIndex
];
pSyncNode
->
myNodeInfo
=
pSyncNode
->
pRaftCfg
->
cfg
.
nodeInfo
[
pSyncNode
->
pRaftCfg
->
cfg
.
myIndex
];
...
@@ -1195,24 +1282,51 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l
...
@@ -1195,24 +1282,51 @@ void syncNodeUpdateConfig(SSyncNode* pSyncNode, SSyncCfg* newConfig, SyncIndex l
pSyncNode
->
quorum
=
syncUtilQuorum
(
pSyncNode
->
pRaftCfg
->
cfg
.
replicaNum
);
pSyncNode
->
quorum
=
syncUtilQuorum
(
pSyncNode
->
pRaftCfg
->
cfg
.
replicaNum
);
// reset snapshot senders, memory leak
// reset snapshot senders
// clear new
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
(
pSyncNode
->
senders
)[
i
]
=
NULL
;
(
pSyncNode
->
senders
)[
i
]
=
NULL
;
}
}
// reset new
for
(
int
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
// reset sender
bool
reset
=
false
;
for
(
int
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
for
(
int
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
if
(
syncUtilSameId
(
&
(
pSyncNode
->
replicasId
)[
i
],
&
oldReplicasId
[
j
]))
{
if
(
syncUtilSameId
(
&
(
pSyncNode
->
replicasId
)[
i
],
&
oldReplicasId
[
j
]))
{
char
host
[
128
];
char
host
[
128
];
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
((
pSyncNode
->
replicasId
)[
i
].
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
((
pSyncNode
->
replicasId
)[
i
].
addr
,
host
,
sizeof
(
host
),
&
port
);
sDebug
(
"vgId:%d sync event reset sender for %lu, %s:%d"
,
pSyncNode
->
vgId
,
(
pSyncNode
->
replicasId
)[
i
].
addr
,
host
,
port
);
sDebug
(
"vgId:%d sync event reset sender for %lu, newIndex:%d, %s:%d, %p"
,
pSyncNode
->
vgId
,
(
pSyncNode
->
replicasId
)[
i
].
addr
,
i
,
host
,
port
,
oldSenders
[
j
]);
(
pSyncNode
->
senders
)[
i
]
=
oldSenders
[
j
];
(
pSyncNode
->
senders
)[
i
]
=
oldSenders
[
j
];
oldSenders
[
j
]
=
NULL
;
reset
=
true
;
// reset replicaIndex
int32_t
oldreplicaIndex
=
(
pSyncNode
->
senders
)[
i
]
->
replicaIndex
;
(
pSyncNode
->
senders
)[
i
]
->
replicaIndex
=
i
;
sDebug
(
"vgId:%d sync event udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d"
,
pSyncNode
->
vgId
,
oldreplicaIndex
,
i
,
host
,
port
,
(
pSyncNode
->
senders
)[
i
],
reset
);
}
}
}
}
}
}
// create new
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
if
((
pSyncNode
->
senders
)[
i
]
==
NULL
)
{
if
((
pSyncNode
->
senders
)[
i
]
==
NULL
)
{
(
pSyncNode
->
senders
)[
i
]
=
snapshotSenderCreate
(
pSyncNode
,
i
);
(
pSyncNode
->
senders
)[
i
]
=
snapshotSenderCreate
(
pSyncNode
,
i
);
sDebug
(
"vgId:%d sync event create new sender %p replicaIndex:%d"
,
pSyncNode
->
vgId
,
(
pSyncNode
->
senders
)[
i
],
i
);
}
}
// free old
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
if
(
oldSenders
[
i
]
!=
NULL
)
{
snapshotSenderDestroy
(
oldSenders
[
i
]);
sDebug
(
"vgId:%d sync event delete old sender %p replicaIndex:%d"
,
pSyncNode
->
vgId
,
oldSenders
[
i
],
i
);
oldSenders
[
i
]
=
NULL
;
}
}
}
}
...
@@ -1272,8 +1386,8 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
...
@@ -1272,8 +1386,8 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
}
}
void
syncNodeBecomeFollower
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
)
{
void
syncNodeBecomeFollower
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
)
{
sDebug
(
"vgId:%d sync event become follower, isStandBy:%d,
%s"
,
pSyncNode
->
vgId
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
sDebug
(
"vgId:%d sync event become follower, isStandBy:%d,
replicaNum:%d, %s"
,
pSyncNode
->
vgId
,
debugStr
);
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
debugStr
);
// maybe clear leader cache
// maybe clear leader cache
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
...
@@ -1307,8 +1421,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
...
@@ -1307,8 +1421,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
// /\ UNCHANGED <<messages, currentTerm, votedFor, candidateVars, logVars>>
// /\ UNCHANGED <<messages, currentTerm, votedFor, candidateVars, logVars>>
//
//
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
)
{
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
,
const
char
*
debugStr
)
{
sDebug
(
"vgId:%d sync event become leader, isStandBy:%d,
%s"
,
pSyncNode
->
vgId
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
sDebug
(
"vgId:%d sync event become leader, isStandBy:%d,
replicaNum:%d %s"
,
pSyncNode
->
vgId
,
debugStr
);
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
debugStr
);
// state change
// state change
pSyncNode
->
state
=
TAOS_SYNC_STATE_LEADER
;
pSyncNode
->
state
=
TAOS_SYNC_STATE_LEADER
;
...
@@ -1658,14 +1772,24 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
...
@@ -1658,14 +1772,24 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqHeartbeatTimer=="
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqHeartbeatTimer=="
,
&
rpcMsg
);
if
(
pSyncNode
->
FpEqMsg
!=
NULL
)
{
if
(
pSyncNode
->
FpEqMsg
!=
NULL
)
{
pSyncNode
->
FpEqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
int32_t
code
=
pSyncNode
->
FpEqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
sError
(
"vgId:%d sync enqueue timer msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
rpcFreeCont
(
rpcMsg
.
pCont
);
return
;
}
}
else
{
}
else
{
sTrace
(
"syncNodeEqHeartbeatTimer pSyncNode->FpEqMsg is NULL"
);
sTrace
(
"syncNodeEqHeartbeatTimer pSyncNode->FpEqMsg is NULL"
);
}
}
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
if
(
gSyncEnv
!=
NULL
)
{
taosTmrReset
(
syncNodeEqHeartbeatTimer
,
pSyncNode
->
heartbeatTimerMS
,
pSyncNode
,
gSyncEnv
->
pTimerManager
,
taosTmrReset
(
syncNodeEqHeartbeatTimer
,
pSyncNode
->
heartbeatTimerMS
,
pSyncNode
,
gSyncEnv
->
pTimerManager
,
&
pSyncNode
->
pHeartbeatTimer
);
&
pSyncNode
->
pHeartbeatTimer
);
}
else
{
sError
(
"sync env is already stop"
);
}
}
else
{
}
else
{
sTrace
(
"==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%"
PRIu64
", heartbeatTimerLogicClockUser:%"
PRIu64
sTrace
(
"==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%"
PRIu64
", heartbeatTimerLogicClockUser:%"
PRIu64
""
,
""
,
...
@@ -1847,10 +1971,52 @@ const char* syncStr(ESyncState state) {
...
@@ -1847,10 +1971,52 @@ const char* syncStr(ESyncState state) {
}
}
static
int32_t
syncDoLeaderTransfer
(
SSyncNode
*
ths
,
SRpcMsg
*
pRpcMsg
,
SSyncRaftEntry
*
pEntry
)
{
static
int32_t
syncDoLeaderTransfer
(
SSyncNode
*
ths
,
SRpcMsg
*
pRpcMsg
,
SSyncRaftEntry
*
pEntry
)
{
SyncLeaderTransfer
*
pSyncLeaderTransfer
;
SyncLeaderTransfer
*
pSyncLeaderTransfer
=
syncLeaderTransferFromRpcMsg2
(
pRpcMsg
);
if
(
syncUtilSameId
(
&
(
pSyncLeaderTransfer
->
newLeaderId
),
&
(
ths
->
myRaftId
)))
{
/*
char host[128];
uint16_t port;
syncUtilU642Addr(pSyncLeaderTransfer->newLeaderId.addr, host, sizeof(host), &port);
sDebug("vgId:%d sync event, maybe leader transfer to %s:%d %lu", ths->vgId, host, port,
pSyncLeaderTransfer->newLeaderId.addr);
*/
sDebug
(
"vgId:%d sync event, begin leader transfer"
,
ths
->
vgId
);
if
(
strcmp
(
pSyncLeaderTransfer
->
newNodeInfo
.
nodeFqdn
,
ths
->
myNodeInfo
.
nodeFqdn
)
==
0
&&
pSyncLeaderTransfer
->
newNodeInfo
.
nodePort
==
ths
->
myNodeInfo
.
nodePort
)
{
sDebug
(
"vgId:%d sync event, maybe leader transfer to %s:%d %lu"
,
ths
->
vgId
,
pSyncLeaderTransfer
->
newNodeInfo
.
nodeFqdn
,
pSyncLeaderTransfer
->
newNodeInfo
.
nodePort
,
pSyncLeaderTransfer
->
newLeaderId
.
addr
);
// reset elect timer now!
int32_t
electMS
=
1
;
int32_t
ret
=
syncNodeRestartElectTimer
(
ths
,
electMS
);
ASSERT
(
ret
==
0
);
}
/*
if (syncUtilSameId(&(pSyncLeaderTransfer->newLeaderId), &(ths->myRaftId))) {
// reset elect timer now!
int32_t electMS = 1;
int32_t ret = syncNodeRestartElectTimer(ths, electMS);
ASSERT(ret == 0);
}
*/
if
(
ths
->
pFsm
->
FpLeaderTransferCb
!=
NULL
)
{
SFsmCbMeta
cbMeta
;
cbMeta
.
code
=
0
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
flag
=
0
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
term
=
pEntry
->
term
;
ths
->
pFsm
->
FpLeaderTransferCb
(
ths
->
pFsm
,
pRpcMsg
,
cbMeta
);
}
}
syncLeaderTransferDestroy
(
pSyncLeaderTransfer
);
return
0
;
return
0
;
}
}
...
@@ -1874,26 +2040,31 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
...
@@ -1874,26 +2040,31 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
bool
isDrop
;
bool
isDrop
;
//if (IamInNew || (!IamInNew && ths->state != TAOS_SYNC_STATE_LEADER)) {
//
if (IamInNew || (!IamInNew && ths->state != TAOS_SYNC_STATE_LEADER)) {
if
(
IamInNew
)
{
if
(
IamInNew
)
{
syncNodeUpdateConfig
(
ths
,
&
newSyncCfg
,
pEntry
->
index
,
&
isDrop
);
syncNodeUpdateConfig
(
ths
,
&
newSyncCfg
,
pEntry
->
index
,
&
isDrop
);
// change isStandBy to normal
// change isStandBy to normal
if
(
!
isDrop
)
{
if
(
!
isDrop
)
{
char
tmpbuf
[
128
];
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"config change from %d to %d"
,
oldSyncCfg
.
replicaNum
,
newSyncCfg
.
replicaNum
);
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
syncNodeBecomeLeader
(
ths
,
"config change"
);
syncNodeBecomeLeader
(
ths
,
tmpbuf
);
}
else
{
}
else
{
syncNodeBecomeFollower
(
ths
,
"config change"
);
syncNodeBecomeFollower
(
ths
,
tmpbuf
);
}
}
}
}
}
else
{
}
else
{
syncNodeBecomeFollower
(
ths
,
"config change2"
);
char
tmpbuf
[
128
];
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"config change2 from %d to %d"
,
oldSyncCfg
.
replicaNum
,
newSyncCfg
.
replicaNum
);
syncNodeBecomeFollower
(
ths
,
tmpbuf
);
}
}
if
(
gRaftDetailLog
)
{
if
(
gRaftDetailLog
)
{
char
*
sOld
=
syncCfg2Str
(
&
oldSyncCfg
);
char
*
sOld
=
syncCfg2Str
(
&
oldSyncCfg
);
char
*
sNew
=
syncCfg2Str
(
&
newSyncCfg
);
char
*
sNew
=
syncCfg2Str
(
&
newSyncCfg
);
sInfo
(
"==config change== 0x11 old:%s new:%s isDrop:%d index:%ld
\n
"
,
sOld
,
sNew
,
isDrop
,
pEntry
->
index
);
sInfo
(
"==config change== 0x11 old:%s new:%s isDrop:%d index:%ld IamInNew:%d
\n
"
,
sOld
,
sNew
,
isDrop
,
pEntry
->
index
,
IamInNew
);
taosMemoryFree
(
sOld
);
taosMemoryFree
(
sOld
);
taosMemoryFree
(
sNew
);
taosMemoryFree
(
sNew
);
}
}
...
@@ -1955,7 +2126,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
...
@@ -1955,7 +2126,7 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
}
}
//
config change
//
leader transfer
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_LEADER_TRANSFER
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_LEADER_TRANSFER
)
{
code
=
syncDoLeaderTransfer
(
ths
,
&
rpcMsg
,
pEntry
);
code
=
syncDoLeaderTransfer
(
ths
,
&
rpcMsg
,
pEntry
);
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
b13c31c9
...
@@ -393,7 +393,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
...
@@ -393,7 +393,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
)
{
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
)
{
cJSON
*
pJson
=
snapshotSender2Json
(
pSender
);
cJSON
*
pJson
=
snapshotSender2Json
(
pSender
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
@@ -514,7 +514,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
...
@@ -514,7 +514,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
cJSON_AddStringToObject
(
pFromId
,
"addr"
,
u64buf
);
cJSON_AddStringToObject
(
pFromId
,
"addr"
,
u64buf
);
{
{
uint64_t
u64
=
pReceiver
->
fromId
.
addr
;
uint64_t
u64
=
pReceiver
->
fromId
.
addr
;
cJSON
*
pTmp
=
pFromId
;
cJSON
*
pTmp
=
pFromId
;
char
host
[
128
]
=
{
0
};
char
host
[
128
]
=
{
0
};
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
...
@@ -538,7 +538,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
...
@@ -538,7 +538,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
@@ -588,6 +588,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
...
@@ -588,6 +588,8 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
// maybe update lastconfig
// maybe update lastconfig
if
(
pMsg
->
lastConfigIndex
>=
SYNC_INDEX_BEGIN
)
{
if
(
pMsg
->
lastConfigIndex
>=
SYNC_INDEX_BEGIN
)
{
int32_t
oldReplicaNum
=
pSyncNode
->
replicaNum
;
// update new config myIndex
// update new config myIndex
bool
IamInNew
=
false
;
bool
IamInNew
=
false
;
SSyncCfg
newSyncCfg
=
pMsg
->
lastConfig
;
SSyncCfg
newSyncCfg
=
pMsg
->
lastConfig
;
...
@@ -614,10 +616,12 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
...
@@ -614,10 +616,12 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
// change isStandBy to normal
// change isStandBy to normal
if
(
!
isDrop
)
{
if
(
!
isDrop
)
{
char
tmpbuf
[
128
];
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"config change3 from %d to %d"
,
oldReplicaNum
,
newSyncCfg
.
replicaNum
);
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
syncNodeBecomeLeader
(
pSyncNode
,
"config change"
);
syncNodeBecomeLeader
(
pSyncNode
,
tmpbuf
);
}
else
{
}
else
{
syncNodeBecomeFollower
(
pSyncNode
,
"config change"
);
syncNodeBecomeFollower
(
pSyncNode
,
tmpbuf
);
}
}
}
}
}
}
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
b13c31c9
add_executable
(
syncTest
""
)
add_executable
(
syncTest
""
)
add_executable
(
syncRaftIdCheck
""
)
add_executable
(
syncEnvTest
""
)
add_executable
(
syncEnvTest
""
)
add_executable
(
syncPingTimerTest
""
)
add_executable
(
syncPingTimerTest
""
)
add_executable
(
syncIOTickQTest
""
)
add_executable
(
syncIOTickQTest
""
)
...
@@ -54,6 +55,10 @@ target_sources(syncTest
...
@@ -54,6 +55,10 @@ target_sources(syncTest
PRIVATE
PRIVATE
"syncTest.cpp"
"syncTest.cpp"
)
)
target_sources
(
syncRaftIdCheck
PRIVATE
"syncRaftIdCheck.cpp"
)
target_sources
(
syncEnvTest
target_sources
(
syncEnvTest
PRIVATE
PRIVATE
"syncEnvTest.cpp"
"syncEnvTest.cpp"
...
@@ -257,6 +262,11 @@ target_include_directories(syncTest
...
@@ -257,6 +262,11 @@ target_include_directories(syncTest
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncRaftIdCheck
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncEnvTest
target_include_directories
(
syncEnvTest
PUBLIC
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
...
@@ -508,6 +518,10 @@ target_link_libraries(syncTest
...
@@ -508,6 +518,10 @@ target_link_libraries(syncTest
sync
sync
gtest_main
gtest_main
)
)
target_link_libraries
(
syncRaftIdCheck
sync
gtest_main
)
target_link_libraries
(
syncEnvTest
target_link_libraries
(
syncEnvTest
sync
sync
gtest_main
gtest_main
...
...
source/libs/sync/test/syncRaftIdCheck.cpp
0 → 100644
浏览文件 @
b13c31c9
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncUtil.h"
void
usage
(
char
*
exe
)
{
printf
(
"Usage: %s host port
\n
"
,
exe
);
printf
(
"Usage: %s u64
\n
"
,
exe
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
2
)
{
uint64_t
u64
=
atoll
(
argv
[
1
]);
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
printf
(
"%lu -> %s:%d
\n
"
,
u64
,
host
,
port
);
}
else
if
(
argc
==
3
)
{
uint64_t
u64
;
char
*
host
=
argv
[
1
];
uint16_t
port
=
atoi
(
argv
[
2
]);
u64
=
syncUtilAddr2U64
(
host
,
port
);
printf
(
"%s:%d -> %lu
\n
"
,
host
,
port
,
u64
);
}
else
{
usage
(
argv
[
0
]);
exit
(
-
1
);
}
return
0
;
}
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
b13c31c9
...
@@ -153,6 +153,16 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe
...
@@ -153,6 +153,16 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe
taosMemoryFree
(
s
);
taosMemoryFree
(
s
);
}
}
void
LeaderTransferCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==LeaderTransferCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, flag:%lu, term:%lu "
"currentTerm:%lu
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
SSyncFSM
*
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
...
@@ -172,6 +182,8 @@ SSyncFSM* createFsm() {
...
@@ -172,6 +182,8 @@ SSyncFSM* createFsm() {
pFsm
->
FpSnapshotStopWrite
=
SnapshotStopWrite
;
pFsm
->
FpSnapshotStopWrite
=
SnapshotStopWrite
;
pFsm
->
FpSnapshotDoWrite
=
SnapshotDoWrite
;
pFsm
->
FpSnapshotDoWrite
=
SnapshotDoWrite
;
pFsm
->
FpLeaderTransferCb
=
LeaderTransferCb
;
return
pFsm
;
return
pFsm
;
}
}
...
@@ -277,7 +289,8 @@ void usage(char* exe) {
...
@@ -277,7 +289,8 @@ void usage(char* exe) {
printf
(
printf
(
"usage: %s replicaNum(1-5) myIndex(0-..) enableSnapshot(0/1) lastApplyIndex(>=-1) lastApplyTerm(>=0) "
"usage: %s replicaNum(1-5) myIndex(0-..) enableSnapshot(0/1) lastApplyIndex(>=-1) lastApplyTerm(>=0) "
"writeRecordNum(>=0) "
"writeRecordNum(>=0) "
"isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0) finishLastApplyIndex(>=-1) finishLastApplyTerm(>=0)
\n
"
,
"isStandBy(0/1) isConfigChange(0-5) iterTimes(>=0) finishLastApplyIndex(>=-1) finishLastApplyTerm(>=0) "
"leaderTransfer(0/1)
\n
"
,
exe
);
exe
);
}
}
...
@@ -294,9 +307,9 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
...
@@ -294,9 +307,9 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
sprintf
(
tsTempDir
,
"%s"
,
"."
);
sprintf
(
tsTempDir
,
"%s"
,
"."
);
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_ERROR
;
sDebugFlag
=
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_TRACE
+
DEBUG_INFO
+
DEBUG_ERROR
+
DEBUG_DEBUG
;
if
(
argc
!=
1
2
)
{
if
(
argc
!=
1
3
)
{
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
exit
(
-
1
);
exit
(
-
1
);
}
}
...
@@ -312,12 +325,14 @@ int main(int argc, char** argv) {
...
@@ -312,12 +325,14 @@ int main(int argc, char** argv) {
int32_t
iterTimes
=
atoi
(
argv
[
9
]);
int32_t
iterTimes
=
atoi
(
argv
[
9
]);
int32_t
finishLastApplyIndex
=
atoi
(
argv
[
10
]);
int32_t
finishLastApplyIndex
=
atoi
(
argv
[
10
]);
int32_t
finishLastApplyTerm
=
atoi
(
argv
[
11
]);
int32_t
finishLastApplyTerm
=
atoi
(
argv
[
11
]);
int32_t
leaderTransfer
=
atoi
(
argv
[
12
]);
s
Trace
(
s
Info
(
"args: replicaNum:%d, myIndex:%d, enableSnapshot:%d, lastApplyIndex:%d, lastApplyTerm:%d, writeRecordNum:%d, "
"args: replicaNum:%d, myIndex:%d, enableSnapshot:%d, lastApplyIndex:%d, lastApplyTerm:%d, writeRecordNum:%d, "
"isStandBy:%d, isConfigChange:%d, iterTimes:%d, finishLastApplyIndex:%d, finishLastApplyTerm:%d"
,
"isStandBy:%d, isConfigChange:%d, iterTimes:%d, finishLastApplyIndex:%d, finishLastApplyTerm:%d, "
"leaderTransfer:%d"
,
replicaNum
,
myIndex
,
enableSnapshot
,
lastApplyIndex
,
lastApplyTerm
,
writeRecordNum
,
isStandBy
,
isConfigChange
,
replicaNum
,
myIndex
,
enableSnapshot
,
lastApplyIndex
,
lastApplyTerm
,
writeRecordNum
,
isStandBy
,
isConfigChange
,
iterTimes
,
finishLastApplyIndex
,
finishLastApplyTerm
);
iterTimes
,
finishLastApplyIndex
,
finishLastApplyTerm
,
leaderTransfer
);
// check parameter
// check parameter
assert
(
replicaNum
>=
1
&&
replicaNum
<=
5
);
assert
(
replicaNum
>=
1
&&
replicaNum
<=
5
);
...
@@ -363,24 +378,31 @@ int main(int argc, char** argv) {
...
@@ -363,24 +378,31 @@ int main(int argc, char** argv) {
//---------------------------
//---------------------------
int32_t
alreadySend
=
0
;
int32_t
alreadySend
=
0
;
int32_t
leaderTransferWait
=
0
;
while
(
1
)
{
while
(
1
)
{
char
*
simpleStr
=
syncNode2SimpleStr
(
pSyncNode
);
char
*
simpleStr
=
syncNode2SimpleStr
(
pSyncNode
);
leaderTransferWait
++
;
if
(
leaderTransferWait
==
7
)
{
sTrace
(
"begin leader transfer ..."
);
int32_t
ret
=
syncLeaderTransfer
(
rid
);
}
if
(
alreadySend
<
writeRecordNum
)
{
if
(
alreadySend
<
writeRecordNum
)
{
SRpcMsg
*
pRpcMsg
=
createRpcMsg
(
alreadySend
,
writeRecordNum
,
myIndex
);
SRpcMsg
*
pRpcMsg
=
createRpcMsg
(
alreadySend
,
writeRecordNum
,
myIndex
);
int32_t
ret
=
syncPropose
(
rid
,
pRpcMsg
,
false
);
int32_t
ret
=
syncPropose
(
rid
,
pRpcMsg
,
false
);
if
(
ret
==
TAOS_SYNC_PROPOSE_NOT_LEADER
)
{
if
(
ret
==
TAOS_SYNC_PROPOSE_NOT_LEADER
)
{
sTrace
(
"%s value%d write not leader
"
,
simpleStr
,
alreadySend
);
sTrace
(
"%s value%d write not leader
, leaderTransferWait:%d"
,
simpleStr
,
alreadySend
,
leaderTransferWait
);
}
else
{
}
else
{
assert
(
ret
==
0
);
assert
(
ret
==
0
);
sTrace
(
"%s value%d write ok
"
,
simpleStr
,
alreadySend
);
sTrace
(
"%s value%d write ok
, leaderTransferWait:%d"
,
simpleStr
,
alreadySend
,
leaderTransferWait
);
}
}
alreadySend
++
;
alreadySend
++
;
rpcFreeCont
(
pRpcMsg
->
pCont
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
taosMemoryFree
(
pRpcMsg
);
taosMemoryFree
(
pRpcMsg
);
}
else
{
}
else
{
sTrace
(
"%s
"
,
simpleStr
);
sTrace
(
"%s
, leaderTransferWait:%d"
,
simpleStr
,
leaderTransferWait
);
}
}
taosMsleep
(
1000
);
taosMsleep
(
1000
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
b13c31c9
...
@@ -983,6 +983,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
...
@@ -983,6 +983,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
tDeserializeSEpSet
(
pResp
->
pCont
,
pResp
->
contLen
,
&
epSet
);
tDeserializeSEpSet
(
pResp
->
pCont
,
pResp
->
contLen
,
&
epSet
);
pCtx
->
epSet
=
epSet
;
pCtx
->
epSet
=
epSet
;
if
(
!
transEpSetIsEqual
(
&
epSet
,
&
pCtx
->
epSet
))
{
pCtx
->
retryCount
=
0
;
}
}
}
addConnToPool
(
pThrd
->
pool
,
pConn
);
addConnToPool
(
pThrd
->
pool
,
pConn
);
tTrace
(
"use remote epset, current in use: %d, retry count:%d, try limit: %d"
,
pEpSet
->
inUse
,
pCtx
->
retryCount
+
1
,
tTrace
(
"use remote epset, current in use: %d, retry count:%d, try limit: %d"
,
pEpSet
->
inUse
,
pCtx
->
retryCount
+
1
,
...
...
source/os/src/osLz4.c
浏览文件 @
b13c31c9
...
@@ -45,13 +45,13 @@ int32_t BUILDIN_CLZL(uint64_t val) {
...
@@ -45,13 +45,13 @@ int32_t BUILDIN_CLZL(uint64_t val) {
#else
#else
_MyBitScanReverse64
(
&
r
,
val
);
_MyBitScanReverse64
(
&
r
,
val
);
#endif
#endif
return
(
int
)(
r
>>
3
);
return
(
int
)(
63
-
r
);
}
}
int32_t
BUILDIN_CLZ
(
uint32_t
val
)
{
int32_t
BUILDIN_CLZ
(
uint32_t
val
)
{
unsigned
long
r
=
0
;
unsigned
long
r
=
0
;
_BitScanReverse
(
&
r
,
val
);
_BitScanReverse
(
&
r
,
val
);
return
(
int
)(
r
>>
3
);
return
(
int
)(
31
-
r
);
}
}
int32_t
BUILDIN_CTZL
(
uint64_t
val
)
{
int32_t
BUILDIN_CTZL
(
uint64_t
val
)
{
...
@@ -61,13 +61,13 @@ int32_t BUILDIN_CTZL(uint64_t val) {
...
@@ -61,13 +61,13 @@ int32_t BUILDIN_CTZL(uint64_t val) {
#else
#else
_MyBitScanForward64
(
&
r
,
val
);
_MyBitScanForward64
(
&
r
,
val
);
#endif
#endif
return
(
int
)(
r
>>
3
);
return
(
int
)(
r
);
}
}
int32_t
BUILDIN_CTZ
(
uint32_t
val
)
{
int32_t
BUILDIN_CTZ
(
uint32_t
val
)
{
unsigned
long
r
=
0
;
unsigned
long
r
=
0
;
_BitScanForward
(
&
r
,
val
);
_BitScanForward
(
&
r
,
val
);
return
(
int
)(
r
>>
3
);
return
(
int
)(
r
);
}
}
#endif
#endif
source/util/src/talgo.c
浏览文件 @
b13c31c9
...
@@ -175,7 +175,13 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
...
@@ -175,7 +175,13 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
c
=
compar
(
key
,
p
);
c
=
compar
(
key
,
p
);
if
(
c
==
0
)
{
if
(
c
==
0
)
{
break
;
if
(
flags
==
TD_GT
){
lidx
=
midx
+
1
;
}
else
if
(
flags
==
TD_LT
){
ridx
=
midx
-
1
;
}
else
{
break
;
}
}
else
if
(
c
<
0
)
{
}
else
if
(
c
<
0
)
{
ridx
=
midx
-
1
;
ridx
=
midx
-
1
;
}
else
{
}
else
{
...
@@ -189,6 +195,10 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
...
@@ -189,6 +195,10 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
return
(
c
<=
0
)
?
p
:
(
midx
+
1
<
nmemb
?
p
+
size
:
NULL
);
return
(
c
<=
0
)
?
p
:
(
midx
+
1
<
nmemb
?
p
+
size
:
NULL
);
}
else
if
(
flags
==
TD_LE
)
{
}
else
if
(
flags
==
TD_LE
)
{
return
(
c
>=
0
)
?
p
:
(
midx
>
0
?
p
-
size
:
NULL
);
return
(
c
>=
0
)
?
p
:
(
midx
>
0
?
p
-
size
:
NULL
);
}
else
if
(
flags
==
TD_GT
)
{
return
(
c
<
0
)
?
p
:
(
midx
+
1
<
nmemb
?
p
+
size
:
NULL
);
}
else
if
(
flags
==
TD_LT
)
{
return
(
c
>
0
)
?
p
:
(
midx
>
0
?
p
-
size
:
NULL
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/util/src/tarray.c
浏览文件 @
b13c31c9
...
@@ -458,6 +458,9 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void
...
@@ -458,6 +458,9 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void
}
}
SArray
*
taosArrayDeepCopy
(
const
SArray
*
pSrc
,
FCopy
deepCopy
)
{
SArray
*
taosArrayDeepCopy
(
const
SArray
*
pSrc
,
FCopy
deepCopy
)
{
if
(
NULL
==
pSrc
)
{
return
NULL
;
}
ASSERT
(
pSrc
->
elemSize
==
sizeof
(
void
*
));
ASSERT
(
pSrc
->
elemSize
==
sizeof
(
void
*
));
SArray
*
pArray
=
taosArrayInit
(
pSrc
->
size
,
sizeof
(
void
*
));
SArray
*
pArray
=
taosArrayInit
(
pSrc
->
size
,
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
pSrc
->
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSrc
->
size
;
i
++
)
{
...
...
source/util/test/taosbsearchTest.cpp
浏览文件 @
b13c31c9
...
@@ -248,6 +248,170 @@ TEST(testCase, taosbsearch_greater_or_equal) {
...
@@ -248,6 +248,170 @@ TEST(testCase, taosbsearch_greater_or_equal) {
ASSERT_EQ
(
pRet
,
nullptr
);
ASSERT_EQ
(
pRet
,
nullptr
);
}
}
TEST
(
testCase
,
taosbsearch_greater
)
{
// For equal test
int
key
=
3
;
void
*
pRet
=
NULL
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
NULL
,
0
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 1 element
int
array1
[
1
]
=
{
5
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
5
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
5
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 2 element
int
array2
[
2
]
=
{
3
,
6
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 3 element
int
array3
[
3
]
=
{
3
,
6
,
8
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 4 element
int
array4
[
4
]
=
{
3
,
6
,
8
,
11
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
11
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
13
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 5 element
int
array5
[
5
]
=
{
3
,
6
,
8
,
11
,
15
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
11
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
15
);
key
=
13
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
15
);
key
=
15
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
17
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_GT
);
ASSERT_EQ
(
pRet
,
nullptr
);
}
TEST
(
testCase
,
taosbsearch_less_or_equal
)
{
TEST
(
testCase
,
taosbsearch_less_or_equal
)
{
// For equal test
// For equal test
int
key
=
3
;
int
key
=
3
;
...
@@ -411,4 +575,168 @@ TEST(testCase, taosbsearch_less_or_equal) {
...
@@ -411,4 +575,168 @@ TEST(testCase, taosbsearch_less_or_equal) {
key
=
17
;
key
=
17
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LE
);
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LE
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
15
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
15
);
}
TEST
(
testCase
,
taosbsearch_less
)
{
// For equal test
int
key
=
3
;
void
*
pRet
=
NULL
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
NULL
,
0
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 1 element
int
array1
[
1
]
=
{
5
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
5
);
key
=
5
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array1
,
1
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
// 2 element
int
array2
[
2
]
=
{
3
,
6
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array2
,
2
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
// 3 element
int
array3
[
3
]
=
{
3
,
6
,
8
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array3
,
3
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
// 4 element
int
array4
[
4
]
=
{
3
,
6
,
8
,
11
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
11
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
13
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array4
,
4
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
// 5 element
int
array5
[
5
]
=
{
3
,
6
,
8
,
11
,
15
};
key
=
1
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
3
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
pRet
,
nullptr
);
key
=
4
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
6
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
3
);
key
=
7
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
8
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
6
);
key
=
9
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
11
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
8
);
key
=
13
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
15
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
11
);
key
=
17
;
pRet
=
taosbsearch
((
void
*
)
&
key
,
(
void
*
)
array5
,
5
,
sizeof
(
int
),
compareFunc
,
TD_LT
);
ASSERT_EQ
(
*
(
int
*
)
pRet
,
15
);
}
}
\ No newline at end of file
tests/script/jenkins/basic.txt
浏览文件 @
b13c31c9
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
# ---- mnode
# ---- mnode
./test.sh -f tsim/mnode/basic1.sim
./test.sh -f tsim/mnode/basic1.sim
./test.sh -f tsim/mnode/basic2.sim
./test.sh -f tsim/mnode/basic2.sim
#
./test.sh -f tsim/mnode/basic3.sim
./test.sh -f tsim/mnode/basic3.sim
./test.sh -f tsim/mnode/basic4.sim
./test.sh -f tsim/mnode/basic4.sim
./test.sh -f tsim/mnode/basic5.sim
./test.sh -f tsim/mnode/basic5.sim
...
...
tests/script/tsim/stable/tag_filter.sim
浏览文件 @
b13c31c9
...
@@ -73,5 +73,80 @@ if $rows != 6 then
...
@@ -73,5 +73,80 @@ if $rows != 6 then
endi
endi
print ========== prepare stbBin and ctbBin
sql create table db.stbBin (ts timestamp, c1 int, c2 binary(4)) tags(t1 binary(16))
sql create table db.ctbBin using db.stbBin tags("a")
sql insert into db.ctbBin values(now, 1, "2")
sql create table db.ctbBin1 using db.stbBin tags("b")
sql insert into db.ctbBin1 values(now, 2, "2")
sql create table db.ctbBin2 using db.stbBin tags("c")
sql insert into db.ctbBin2 values(now, 3, "2")
sql create table db.ctbBin3 using db.stbBin tags("d")
sql insert into db.ctbBin3 values(now, 4, "2")
sql select * from db.stbBin where t1 = "a"
if $rows != 1 then
return -1
endi
sql select * from db.stbBin where t1 < "a"
if $rows != 0 then
return -=1
endi
sql select * from db.stbBin where t1 < "b"
if $rows != 1 then
return -1
endi
sql select * from db.stbBin where t1 between "a" and "e"
if $rows != 4 then
return -1
endi
print ========== prepare stbNc and ctbNc
sql create table db.stbNc (ts timestamp, c1 int, c2 binary(4)) tags(t1 nchar(16))
sql create table db.ctbNc using db.stbNc tags("a")
sql insert into db.ctbNc values(now, 1, "2")
sql create table db.ctbNc1 using db.stbNc tags("b")
sql insert into db.ctbNc1 values(now, 2, "2")
sql create table db.ctbNc2 using db.stbNc tags("c")
sql insert into db.ctbNc2 values(now, 3, "2")
sql create table db.ctbNc3 using db.stbNc tags("d")
sql insert into db.ctbNc3 values(now, 4, "2")
sql select * from db.stbNc where t1 = "a"
if $rows != 1 then
return -1
endi
sql select * from db.stbNc where t1 < "a"
if $rows != 0 then
return -=1
endi
sql select * from db.stbNc where t1 < "b"
if $rows != 1 then
return -1
endi
sql select * from db.stbNc where t1 between "a" and "e"
if $rows != 4 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/system-test/7-tmq/subscribeDb1.py
浏览文件 @
b13c31c9
...
@@ -437,12 +437,12 @@ class TDTestCase:
...
@@ -437,12 +437,12 @@ class TDTestCase:
event
.
wait
()
event
.
wait
()
tdLog
.
info
(
"start consume processor"
)
tdLog
.
info
(
"start consume processor"
)
pollDelay
=
10
0
pollDelay
=
2
0
showMsg
=
1
showMsg
=
1
showRow
=
1
showRow
=
1
self
.
startTmqSimProcess
(
buildPath
,
cfgPath
,
pollDelay
,
parameterDict
[
"dbName"
],
showMsg
,
showRow
)
self
.
startTmqSimProcess
(
buildPath
,
cfgPath
,
pollDelay
,
parameterDict
[
"dbName"
],
showMsg
,
showRow
)
time
.
sleep
(
5
)
time
.
sleep
(
3
)
tdLog
.
info
(
"pkill consume processor"
)
tdLog
.
info
(
"pkill consume processor"
)
if
(
platform
.
system
().
lower
()
==
'windows'
):
if
(
platform
.
system
().
lower
()
==
'windows'
):
os
.
system
(
"TASKKILL /F /IM tmq_sim.exe"
)
os
.
system
(
"TASKKILL /F /IM tmq_sim.exe"
)
...
@@ -465,7 +465,7 @@ class TDTestCase:
...
@@ -465,7 +465,7 @@ class TDTestCase:
totalConsumeRows
+=
resultList
[
i
]
totalConsumeRows
+=
resultList
[
i
]
if
totalConsumeRows
>=
expectrowcnt
or
totalConsumeRows
<=
0
:
if
totalConsumeRows
>=
expectrowcnt
or
totalConsumeRows
<=
0
:
tdLog
.
info
(
"act consume rows: %d, expect consume rows
: %d
"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"act consume rows: %d, expect consume rows
between %d and 0
"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
exit
(
"tmq consume rows error!"
)
tdLog
.
exit
(
"tmq consume rows error!"
)
time
.
sleep
(
15
)
time
.
sleep
(
15
)
...
...
tests/system-test/fulltest.sh
浏览文件 @
b13c31c9
...
@@ -104,7 +104,7 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
...
@@ -104,7 +104,7 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py
python3 ./test.py
-f
7-tmq/basic5.py
python3 ./test.py
-f
7-tmq/basic5.py
python3 ./test.py
-f
7-tmq/subscribeDb.py
python3 ./test.py
-f
7-tmq/subscribeDb.py
python3 ./test.py
-f
7-tmq/subscribeDb0.py
python3 ./test.py
-f
7-tmq/subscribeDb0.py
#
python3 ./test.py -f 7-tmq/subscribeDb1.py
python3 ./test.py
-f
7-tmq/subscribeDb1.py
python3 ./test.py
-f
7-tmq/subscribeStb.py
python3 ./test.py
-f
7-tmq/subscribeStb.py
python3 ./test.py
-f
7-tmq/subscribeStb0.py
python3 ./test.py
-f
7-tmq/subscribeStb0.py
python3 ./test.py
-f
7-tmq/subscribeStb1.py
python3 ./test.py
-f
7-tmq/subscribeStb1.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录