Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
14426025
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
14426025
编写于
5月 27, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add async get db info api
上级
e7b8a7d5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
335 addition
and
125 deletion
+335
-125
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+14
-4
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+43
-28
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+27
-15
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+90
-4
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+147
-66
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+9
-3
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+5
-5
未找到文件。
include/libs/catalog/catalog.h
浏览文件 @
14426025
...
@@ -52,23 +52,31 @@ typedef struct SUserAuthInfo {
...
@@ -52,23 +52,31 @@ typedef struct SUserAuthInfo {
AUTH_TYPE
type
;
AUTH_TYPE
type
;
}
SUserAuthInfo
;
}
SUserAuthInfo
;
typedef
struct
SDbInfo
{
int32_t
vgVer
;
int32_t
tbNum
;
int64_t
dbId
;
}
SDbInfo
;
typedef
struct
SCatalogReq
{
typedef
struct
SCatalogReq
{
SArray
*
pTableMeta
;
// element is SNAME
SArray
*
pDbVgroup
;
// element is db full name
SArray
*
pDbVgroup
;
// element is db full name
SArray
*
pDbCfg
;
// element is db full name
SArray
*
pDbInfo
;
// element is db full name
SArray
*
pTableMeta
;
// element is SNAME
SArray
*
pTableHash
;
// element is SNAME
SArray
*
pTableHash
;
// element is SNAME
SArray
*
pUdf
;
// element is udf name
SArray
*
pUdf
;
// element is udf name
SArray
*
pDbCfg
;
// element is db full name
SArray
*
pIndex
;
// element is index name
SArray
*
pIndex
;
// element is index name
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pUser
;
// element is SUserAuthInfo
bool
qNodeRequired
;
// valid qnode
bool
qNodeRequired
;
// valid qnode
}
SCatalogReq
;
}
SCatalogReq
;
typedef
struct
SMetaData
{
typedef
struct
SMetaData
{
SArray
*
pTableMeta
;
// SArray<STableMeta*>
SArray
*
pDbVgroup
;
// SArray<SArray<SVgroupInfo>*>
SArray
*
pDbVgroup
;
// SArray<SArray<SVgroupInfo>*>
SArray
*
pDbCfg
;
// SArray<SDbCfgInfo>
SArray
*
pDbInfo
;
// SArray<SDbInfo>
SArray
*
pTableMeta
;
// SArray<STableMeta*>
SArray
*
pTableHash
;
// SArray<SVgroupInfo>
SArray
*
pTableHash
;
// SArray<SVgroupInfo>
SArray
*
pUdfList
;
// SArray<SFuncInfo>
SArray
*
pUdfList
;
// SArray<SFuncInfo>
SArray
*
pDbCfg
;
// SArray<SDbCfgInfo>
SArray
*
pIndex
;
// SArray<SIndexInfo>
SArray
*
pIndex
;
// SArray<SIndexInfo>
SArray
*
pUser
;
// SArray<bool>
SArray
*
pUser
;
// SArray<bool>
SArray
*
pQnodeList
;
// SArray<SQueryNodeAddr>
SArray
*
pQnodeList
;
// SArray<SQueryNodeAddr>
...
@@ -269,6 +277,8 @@ int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const
...
@@ -269,6 +277,8 @@ int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
);
int32_t
catalogUpdateUserAuthInfo
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
);
int32_t
catalogUpdateVgEpSet
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
epSet
);
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
void
*
pTrans
,
const
SEpSet
*
pMgmtEps
,
uint64_t
reqId
);
int32_t
ctgdLaunchAsyncCall
(
SCatalog
*
pCtg
,
void
*
pTrans
,
const
SEpSet
*
pMgmtEps
,
uint64_t
reqId
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
14426025
...
@@ -49,19 +49,21 @@ enum {
...
@@ -49,19 +49,21 @@ enum {
};
};
enum
{
enum
{
CTG_ACT_UPDATE_VG
=
0
,
CTG_OP_UPDATE_VGROUP
=
0
,
CTG_ACT_UPDATE_TBL
,
CTG_OP_UPDATE_TB_META
,
CTG_ACT_REMOVE_DB
,
CTG_OP_DROP_DB_CACHE
,
CTG_ACT_REMOVE_STB
,
CTG_OP_DROP_STB_META
,
CTG_ACT_REMOVE_TBL
,
CTG_OP_DROP_TB_META
,
CTG_ACT_UPDATE_USER
,
CTG_OP_UPDATE_USER
,
CTG_ACT_MAX
CTG_OP_UPDATE_VG_EPSET
,
CTG_OP_MAX
};
};
typedef
enum
{
typedef
enum
{
CTG_TASK_GET_QNODE
=
0
,
CTG_TASK_GET_QNODE
=
0
,
CTG_TASK_GET_DB_VGROUP
,
CTG_TASK_GET_DB_VGROUP
,
CTG_TASK_GET_DB_CFG
,
CTG_TASK_GET_DB_CFG
,
CTG_TASK_GET_DB_INFO
,
CTG_TASK_GET_TB_META
,
CTG_TASK_GET_TB_META
,
CTG_TASK_GET_TB_HASH
,
CTG_TASK_GET_TB_HASH
,
CTG_TASK_GET_INDEX
,
CTG_TASK_GET_INDEX
,
...
@@ -98,6 +100,10 @@ typedef struct SCtgDbCfgCtx {
...
@@ -98,6 +100,10 @@ typedef struct SCtgDbCfgCtx {
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
}
SCtgDbCfgCtx
;
}
SCtgDbCfgCtx
;
typedef
struct
SCtgDbInfoCtx
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
}
SCtgDbInfoCtx
;
typedef
struct
SCtgTbHashCtx
{
typedef
struct
SCtgTbHashCtx
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
SName
*
pName
;
SName
*
pName
;
...
@@ -182,6 +188,7 @@ typedef struct SCtgJob {
...
@@ -182,6 +188,7 @@ typedef struct SCtgJob {
int32_t
dbCfgNum
;
int32_t
dbCfgNum
;
int32_t
indexNum
;
int32_t
indexNum
;
int32_t
userNum
;
int32_t
userNum
;
int32_t
dbInfoNum
;
}
SCtgJob
;
}
SCtgJob
;
typedef
struct
SCtgMsgCtx
{
typedef
struct
SCtgMsgCtx
{
...
@@ -285,16 +292,22 @@ typedef struct SCtgUpdateUserMsg {
...
@@ -285,16 +292,22 @@ typedef struct SCtgUpdateUserMsg {
SGetUserAuthRsp
userAuth
;
SGetUserAuthRsp
userAuth
;
}
SCtgUpdateUserMsg
;
}
SCtgUpdateUserMsg
;
typedef
struct
SCtgUpdateEpsetMsg
{
SCatalog
*
pCtg
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
int32_t
vgId
;
SEpSet
epSet
;
}
SCtgUpdateEpsetMsg
;
typedef
struct
SCtg
MetaAc
tion
{
typedef
struct
SCtg
CacheOpera
tion
{
int32_t
act
;
int32_t
opId
;
void
*
data
;
void
*
data
;
bool
syncReq
;
bool
syncReq
;
uint64_t
seqId
;
uint64_t
seqId
;
}
SCtg
MetaAc
tion
;
}
SCtg
CacheOpera
tion
;
typedef
struct
SCtgQNode
{
typedef
struct
SCtgQNode
{
SCtg
MetaAction
action
;
SCtg
CacheOperation
op
;
struct
SCtgQNode
*
next
;
struct
SCtgQNode
*
next
;
}
SCtgQNode
;
}
SCtgQNode
;
...
@@ -321,13 +334,13 @@ typedef struct SCatalogMgmt {
...
@@ -321,13 +334,13 @@ typedef struct SCatalogMgmt {
}
SCatalogMgmt
;
}
SCatalogMgmt
;
typedef
uint32_t
(
*
tableNameHashFp
)(
const
char
*
,
uint32_t
);
typedef
uint32_t
(
*
tableNameHashFp
)(
const
char
*
,
uint32_t
);
typedef
int32_t
(
*
ctg
ActFunc
)(
SCtgMetaAc
tion
*
);
typedef
int32_t
(
*
ctg
OpFunc
)(
SCtgCacheOpera
tion
*
);
typedef
struct
SCtg
Ac
tion
{
typedef
struct
SCtg
Opera
tion
{
int32_t
act
Id
;
int32_t
op
Id
;
char
name
[
32
];
char
name
[
32
];
ctg
Act
Func
func
;
ctg
Op
Func
func
;
}
SCtg
Ac
tion
;
}
SCtg
Opera
tion
;
#define CTG_QUEUE_ADD() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
#define CTG_QUEUE_ADD() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
#define CTG_QUEUE_SUB() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
#define CTG_QUEUE_SUB() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
...
@@ -435,12 +448,13 @@ int32_t ctgdShowCacheInfo(void);
...
@@ -435,12 +448,13 @@ int32_t ctgdShowCacheInfo(void);
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
);
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
);
int32_t
ctgGetTbMetaFromCache
(
CTG_PARAMS
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgGetTbMetaFromCache
(
CTG_PARAMS
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
);
int32_t
ctgActUpdateVg
(
SCtgMetaAction
*
action
);
int32_t
ctgOpUpdateVgroup
(
SCtgCacheOperation
*
action
);
int32_t
ctgActUpdateTb
(
SCtgMetaAction
*
action
);
int32_t
ctgOpUpdateTbMeta
(
SCtgCacheOperation
*
action
);
int32_t
ctgActRemoveDB
(
SCtgMetaAction
*
action
);
int32_t
ctgOpDropDbCache
(
SCtgCacheOperation
*
action
);
int32_t
ctgActRemoveStb
(
SCtgMetaAction
*
action
);
int32_t
ctgOpDropStbMeta
(
SCtgCacheOperation
*
action
);
int32_t
ctgActRemoveTb
(
SCtgMetaAction
*
action
);
int32_t
ctgOpDropTbMeta
(
SCtgCacheOperation
*
action
);
int32_t
ctgActUpdateUser
(
SCtgMetaAction
*
action
);
int32_t
ctgOpUpdateUser
(
SCtgCacheOperation
*
action
);
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
ctgReleaseVgInfo
(
SCtgDBCache
*
dbCache
);
...
@@ -449,12 +463,13 @@ int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32
...
@@ -449,12 +463,13 @@ int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32
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
,
const
SName
*
pTableName
,
int32_t
*
sver
,
int32_t
*
tver
,
int32_t
*
tbType
,
uint64_t
*
suid
,
char
*
stbName
);
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
);
int32_t
ctgChkAuthFromCache
(
SCatalog
*
pCtg
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
bool
*
inCache
,
bool
*
pass
);
int32_t
ctgPutRmDBToQueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
);
int32_t
ctgDropDbCacheEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
);
int32_t
ctgPutRmStbToQueue
(
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
);
int32_t
ctgPutRmTbToQueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
);
int32_t
ctgDropTbMetaEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
);
int32_t
ctgPutUpdateVgToQueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
);
int32_t
ctgUpdateVgroupEnqueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
);
int32_t
ctgPutUpdateTbToQueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
);
int32_t
ctgUpdateTbMetaEnqueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
);
int32_t
ctgPutUpdateUserToQueue
(
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
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
);
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
14426025
...
@@ -41,9 +41,9 @@ int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq
...
@@ -41,9 +41,9 @@ int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq
tNameGetFullDbName
(
pTableName
,
dbFName
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
if
(
TSDB_SUPER_TABLE
==
tblMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
==
tblMeta
->
tableType
)
{
CTG_ERR_JRET
(
ctg
PutRmStbToQ
ueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
tblMeta
->
suid
,
syncReq
));
CTG_ERR_JRET
(
ctg
DropStbMetaEnq
ueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
tblMeta
->
suid
,
syncReq
));
}
else
{
}
else
{
CTG_ERR_JRET
(
ctg
PutRmTbToQ
ueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
syncReq
));
CTG_ERR_JRET
(
ctg
DropTbMetaEnq
ueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
syncReq
));
}
}
_return:
_return:
...
@@ -72,7 +72,7 @@ int32_t ctgGetDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, con
...
@@ -72,7 +72,7 @@ int32_t ctgGetDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, con
CTG_ERR_JRET
(
ctgCloneVgInfo
(
DbOut
.
dbVgroup
,
pInfo
));
CTG_ERR_JRET
(
ctgCloneVgInfo
(
DbOut
.
dbVgroup
,
pInfo
));
CTG_ERR_RET
(
ctg
PutUpdateVgToQ
ueue
(
pCtg
,
dbFName
,
DbOut
.
dbId
,
DbOut
.
dbVgroup
,
false
));
CTG_ERR_RET
(
ctg
UpdateVgroupEnq
ueue
(
pCtg
,
dbFName
,
DbOut
.
dbId
,
DbOut
.
dbVgroup
,
false
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -108,13 +108,13 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
...
@@ -108,13 +108,13 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
if
(
code
)
{
if
(
code
)
{
if
(
CTG_DB_NOT_EXIST
(
code
)
&&
(
NULL
!=
dbCache
))
{
if
(
CTG_DB_NOT_EXIST
(
code
)
&&
(
NULL
!=
dbCache
))
{
ctgDebug
(
"db no longer exist, dbFName:%s, dbId:%"
PRIx64
,
input
.
db
,
input
.
dbId
);
ctgDebug
(
"db no longer exist, dbFName:%s, dbId:%"
PRIx64
,
input
.
db
,
input
.
dbId
);
ctg
PutRmDBToQ
ueue
(
pCtg
,
input
.
db
,
input
.
dbId
);
ctg
DropDbCacheEnq
ueue
(
pCtg
,
input
.
db
,
input
.
dbId
);
}
}
CTG_ERR_RET
(
code
);
CTG_ERR_RET
(
code
);
}
}
CTG_ERR_RET
(
ctg
PutUpdateVgToQ
ueue
(
pCtg
,
dbFName
,
DbOut
.
dbId
,
DbOut
.
dbVgroup
,
true
));
CTG_ERR_RET
(
ctg
UpdateVgroupEnq
ueue
(
pCtg
,
dbFName
,
DbOut
.
dbId
,
DbOut
.
dbVgroup
,
true
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -201,7 +201,7 @@ int32_t ctgRefreshTbMeta(CTG_PARAMS, SCtgTbMetaCtx* ctx, STableMetaOutput **pOut
...
@@ -201,7 +201,7 @@ int32_t ctgRefreshTbMeta(CTG_PARAMS, SCtgTbMetaCtx* ctx, STableMetaOutput **pOut
CTG_ERR_JRET
(
ctgCloneMetaOutput
(
output
,
pOutput
));
CTG_ERR_JRET
(
ctgCloneMetaOutput
(
output
,
pOutput
));
}
}
CTG_ERR_JRET
(
ctg
PutUpdateTbToQ
ueue
(
pCtg
,
output
,
syncReq
));
CTG_ERR_JRET
(
ctg
UpdateTbMetaEnq
ueue
(
pCtg
,
output
,
syncReq
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -298,9 +298,9 @@ _return:
...
@@ -298,9 +298,9 @@ _return:
}
}
if
(
TSDB_SUPER_TABLE
==
ctx
->
tbInfo
.
tbType
)
{
if
(
TSDB_SUPER_TABLE
==
ctx
->
tbInfo
.
tbType
)
{
ctg
PutRmStbToQ
ueue
(
pCtg
,
dbFName
,
ctx
->
tbInfo
.
dbId
,
ctx
->
pName
->
tname
,
ctx
->
tbInfo
.
suid
,
false
);
ctg
DropStbMetaEnq
ueue
(
pCtg
,
dbFName
,
ctx
->
tbInfo
.
dbId
,
ctx
->
pName
->
tname
,
ctx
->
tbInfo
.
suid
,
false
);
}
else
{
}
else
{
ctg
PutRmTbToQ
ueue
(
pCtg
,
dbFName
,
ctx
->
tbInfo
.
dbId
,
ctx
->
pName
->
tname
,
false
);
ctg
DropTbMetaEnq
ueue
(
pCtg
,
dbFName
,
ctx
->
tbInfo
.
dbId
,
ctx
->
pName
->
tname
,
false
);
}
}
}
}
...
@@ -348,7 +348,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const c
...
@@ -348,7 +348,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const c
_return:
_return:
ctg
PutUpdateUserToQ
ueue
(
pCtg
,
&
authRsp
,
false
);
ctg
UpdateUserEnq
ueue
(
pCtg
,
&
authRsp
,
false
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -670,7 +670,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId
...
@@ -670,7 +670,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
code
=
ctg
PutUpdateVgToQ
ueue
(
pCtg
,
dbFName
,
dbId
,
dbInfo
,
false
);
code
=
ctg
UpdateVgroupEnq
ueue
(
pCtg
,
dbFName
,
dbId
,
dbInfo
,
false
);
_return:
_return:
...
@@ -691,7 +691,7 @@ int32_t catalogRemoveDB(SCatalog* pCtg, const char* dbFName, uint64_t dbId) {
...
@@ -691,7 +691,7 @@ int32_t catalogRemoveDB(SCatalog* pCtg, const char* dbFName, uint64_t dbId) {
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
CTG_ERR_JRET
(
ctg
PutRmDBToQ
ueue
(
pCtg
,
dbFName
,
dbId
));
CTG_ERR_JRET
(
ctg
DropDbCacheEnq
ueue
(
pCtg
,
dbFName
,
dbId
));
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
...
@@ -701,7 +701,19 @@ _return:
...
@@ -701,7 +701,19 @@ _return:
}
}
int32_t
catalogUpdateVgEpSet
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
epSet
)
{
int32_t
catalogUpdateVgEpSet
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
epSet
)
{
return
0
;
CTG_API_ENTER
();
int32_t
code
=
0
;
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
epSet
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
CTG_ERR_JRET
(
ctgUpdateVgEpsetEnqueue
(
pCtg
,
(
char
*
)
dbFName
,
vgId
,
epSet
));
_return:
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
int32_t
catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
...
@@ -738,7 +750,7 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId,
...
@@ -738,7 +750,7 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId,
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
CTG_ERR_JRET
(
ctg
PutRmStbToQ
ueue
(
pCtg
,
dbFName
,
dbId
,
stbName
,
suid
,
true
));
CTG_ERR_JRET
(
ctg
DropStbMetaEnq
ueue
(
pCtg
,
dbFName
,
dbId
,
stbName
,
suid
,
true
));
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
...
@@ -791,7 +803,7 @@ int32_t catalogUpdateSTableMeta(SCatalog* pCtg, STableMetaRsp *rspMsg) {
...
@@ -791,7 +803,7 @@ int32_t catalogUpdateSTableMeta(SCatalog* pCtg, STableMetaRsp *rspMsg) {
CTG_ERR_JRET
(
queryCreateTableMetaFromMsg
(
rspMsg
,
true
,
&
output
->
tbMeta
));
CTG_ERR_JRET
(
queryCreateTableMetaFromMsg
(
rspMsg
,
true
,
&
output
->
tbMeta
));
CTG_ERR_JRET
(
ctg
PutUpdateTbToQ
ueue
(
pCtg
,
output
,
false
));
CTG_ERR_JRET
(
ctg
UpdateTbMetaEnq
ueue
(
pCtg
,
output
,
false
));
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
...
@@ -1152,7 +1164,7 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) {
...
@@ -1152,7 +1164,7 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) {
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctg
PutUpdateUserToQ
ueue
(
pCtg
,
pAuth
,
false
));
CTG_API_LEAVE
(
ctg
UpdateUserEnq
ueue
(
pCtg
,
pAuth
,
false
));
}
}
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
14426025
...
@@ -95,6 +95,30 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
...
@@ -95,6 +95,30 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgInitGetDbInfoTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
char
*
dbFName
)
{
SCtgTask
task
=
{
0
};
task
.
type
=
CTG_TASK_GET_DB_INFO
;
task
.
taskId
=
taskIdx
;
task
.
pJob
=
pJob
;
task
.
taskCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgDbInfoCtx
));
if
(
NULL
==
task
.
taskCtx
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SCtgDbInfoCtx
*
ctx
=
task
.
taskCtx
;
memcpy
(
ctx
->
dbFName
,
dbFName
,
sizeof
(
ctx
->
dbFName
));
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:%"
PRIx64
" task %d type %d initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgInitGetTbHashTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
SName
*
name
)
{
int32_t
ctgInitGetTbHashTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
SName
*
name
)
{
SCtgTask
task
=
{
0
};
SCtgTask
task
=
{
0
};
...
@@ -219,8 +243,9 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -219,8 +243,9 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
int32_t
dbCfgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbCfg
);
int32_t
dbCfgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbCfg
);
int32_t
indexNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pIndex
);
int32_t
indexNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pIndex
);
int32_t
userNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pUser
);
int32_t
userNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pUser
);
int32_t
dbInfoNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbInfo
);
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dbCfgNum
+
indexNum
+
userNum
;
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dbCfgNum
+
indexNum
+
userNum
+
dbInfoNum
;
if
(
taskNum
<=
0
)
{
if
(
taskNum
<=
0
)
{
ctgError
(
"empty input for job, taskNum:%d"
,
taskNum
);
ctgError
(
"empty input for job, taskNum:%d"
,
taskNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
@@ -249,6 +274,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -249,6 +274,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
pJob
->
dbCfgNum
=
dbCfgNum
;
pJob
->
dbCfgNum
=
dbCfgNum
;
pJob
->
indexNum
=
indexNum
;
pJob
->
indexNum
=
indexNum
;
pJob
->
userNum
=
userNum
;
pJob
->
userNum
=
userNum
;
pJob
->
dbInfoNum
=
dbInfoNum
;
pJob
->
pTasks
=
taosArrayInit
(
taskNum
,
sizeof
(
SCtgTask
));
pJob
->
pTasks
=
taosArrayInit
(
taskNum
,
sizeof
(
SCtgTask
));
...
@@ -268,6 +294,11 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -268,6 +294,11 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
CTG_ERR_JRET
(
ctgInitGetDbCfgTask
(
pJob
,
taskIdx
++
,
dbFName
));
CTG_ERR_JRET
(
ctgInitGetDbCfgTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
}
for
(
int32_t
i
=
0
;
i
<
dbInfoNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbInfo
,
i
);
CTG_ERR_JRET
(
ctgInitGetDbInfoTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
for
(
int32_t
i
=
0
;
i
<
tbMetaNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tbMetaNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
CTG_ERR_JRET
(
ctgInitGetTbMetaTask
(
pJob
,
taskIdx
++
,
name
));
CTG_ERR_JRET
(
ctgInitGetTbMetaTask
(
pJob
,
taskIdx
++
,
name
));
...
@@ -395,6 +426,20 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
...
@@ -395,6 +426,20 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgDumpDbInfoRes
(
SCtgTask
*
pTask
)
{
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pDbInfo
)
{
pJob
->
jobRes
.
pDbInfo
=
taosArrayInit
(
pJob
->
dbInfoNum
,
sizeof
(
SDbInfo
));
if
(
NULL
==
pJob
->
jobRes
.
pDbInfo
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
taosArrayPush
(
pJob
->
jobRes
.
pDbInfo
,
pTask
->
res
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgDumpUdfRes
(
SCtgTask
*
pTask
)
{
int32_t
ctgDumpUdfRes
(
SCtgTask
*
pTask
)
{
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgJob
*
pJob
=
pTask
->
pJob
;
if
(
NULL
==
pJob
->
jobRes
.
pUdfList
)
{
if
(
NULL
==
pJob
->
jobRes
.
pUdfList
)
{
...
@@ -620,7 +665,7 @@ int32_t ctgHandleGetDbVgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pM
...
@@ -620,7 +665,7 @@ int32_t ctgHandleGetDbVgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pM
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
pOut
->
dbVgroup
->
vgHash
,
(
SArray
**
)
&
pTask
->
res
));
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
pOut
->
dbVgroup
->
vgHash
,
(
SArray
**
)
&
pTask
->
res
));
CTG_ERR_JRET
(
ctg
PutUpdateVgToQ
ueue
(
pCtg
,
ctx
->
dbFName
,
pOut
->
dbId
,
pOut
->
dbVgroup
,
false
));
CTG_ERR_JRET
(
ctg
UpdateVgroupEnq
ueue
(
pCtg
,
ctx
->
dbFName
,
pOut
->
dbId
,
pOut
->
dbVgroup
,
false
));
pOut
->
dbVgroup
=
NULL
;
pOut
->
dbVgroup
=
NULL
;
break
;
break
;
...
@@ -659,7 +704,7 @@ int32_t ctgHandleGetTbHashRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
...
@@ -659,7 +704,7 @@ int32_t ctgHandleGetTbHashRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
pOut
->
dbVgroup
,
ctx
->
pName
,
(
SVgroupInfo
*
)
pTask
->
res
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
pOut
->
dbVgroup
,
ctx
->
pName
,
(
SVgroupInfo
*
)
pTask
->
res
));
CTG_ERR_JRET
(
ctg
PutUpdateVgToQ
ueue
(
pCtg
,
ctx
->
dbFName
,
pOut
->
dbId
,
pOut
->
dbVgroup
,
false
));
CTG_ERR_JRET
(
ctg
UpdateVgroupEnq
ueue
(
pCtg
,
ctx
->
dbFName
,
pOut
->
dbId
,
pOut
->
dbVgroup
,
false
));
pOut
->
dbVgroup
=
NULL
;
pOut
->
dbVgroup
=
NULL
;
break
;
break
;
...
@@ -691,6 +736,11 @@ _return:
...
@@ -691,6 +736,11 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgHandleGetDbInfoRsp
(
SCtgTask
*
pTask
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
CTG_RET
(
TSDB_CODE_APP_ERROR
);
}
int32_t
ctgHandleGetQnodeRsp
(
SCtgTask
*
pTask
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
ctgHandleGetQnodeRsp
(
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
));
...
@@ -769,7 +819,7 @@ _return:
...
@@ -769,7 +819,7 @@ _return:
}
}
}
}
ctg
PutUpdateUserToQ
ueue
(
pCtg
,
pOut
,
false
);
ctg
UpdateUserEnq
ueue
(
pCtg
,
pOut
,
false
);
taosMemoryFreeClear
(
pTask
->
msgCtx
.
out
);
taosMemoryFreeClear
(
pTask
->
msgCtx
.
out
);
ctgHandleTaskEnd
(
pTask
,
code
);
ctgHandleTaskEnd
(
pTask
,
code
);
...
@@ -933,6 +983,41 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) {
...
@@ -933,6 +983,41 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgLaunchGetDbInfoTask
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
void
*
pTrans
=
pTask
->
pJob
->
pTrans
;
const
SEpSet
*
pMgmtEps
=
&
pTask
->
pJob
->
pMgmtEps
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDbInfoCtx
*
pCtx
=
(
SCtgDbInfoCtx
*
)
pTask
->
taskCtx
;
pTask
->
res
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbInfo
));
if
(
NULL
==
pTask
->
res
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SDbInfo
*
pInfo
=
(
SDbInfo
*
)
pTask
->
res
;
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
pCtx
->
dbFName
,
&
dbCache
));
if
(
NULL
!=
dbCache
)
{
pInfo
->
vgVer
=
dbCache
->
vgInfo
->
vgVersion
;
pInfo
->
dbId
=
dbCache
->
dbId
;
pInfo
->
tbNum
=
dbCache
->
vgInfo
->
numOfTable
;
}
else
{
pInfo
->
vgVer
=
CTG_DEFAULT_INVALID_VERSION
;
}
CTG_ERR_JRET
(
ctgHandleTaskEnd
(
pTask
,
0
));
_return:
if
(
dbCache
)
{
ctgReleaseVgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
CTG_RET
(
code
);
}
int32_t
ctgLaunchGetIndexTask
(
SCtgTask
*
pTask
)
{
int32_t
ctgLaunchGetIndexTask
(
SCtgTask
*
pTask
)
{
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
void
*
pTrans
=
pTask
->
pJob
->
pTrans
;
void
*
pTrans
=
pTask
->
pJob
->
pTrans
;
...
@@ -992,6 +1077,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
...
@@ -992,6 +1077,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
{
ctgLaunchGetQnodeTask
,
ctgHandleGetQnodeRsp
,
ctgDumpQnodeRes
},
{
ctgLaunchGetQnodeTask
,
ctgHandleGetQnodeRsp
,
ctgDumpQnodeRes
},
{
ctgLaunchGetDbVgTask
,
ctgHandleGetDbVgRsp
,
ctgDumpDbVgRes
},
{
ctgLaunchGetDbVgTask
,
ctgHandleGetDbVgRsp
,
ctgDumpDbVgRes
},
{
ctgLaunchGetDbCfgTask
,
ctgHandleGetDbCfgRsp
,
ctgDumpDbCfgRes
},
{
ctgLaunchGetDbCfgTask
,
ctgHandleGetDbCfgRsp
,
ctgDumpDbCfgRes
},
{
ctgLaunchGetDbInfoTask
,
ctgHandleGetDbInfoRsp
,
ctgDumpDbInfoRes
},
{
ctgLaunchGetTbMetaTask
,
ctgHandleGetTbMetaRsp
,
ctgDumpTbMetaRes
},
{
ctgLaunchGetTbMetaTask
,
ctgHandleGetTbMetaRsp
,
ctgDumpTbMetaRes
},
{
ctgLaunchGetTbHashTask
,
ctgHandleGetTbHashRsp
,
ctgDumpTbHashRes
},
{
ctgLaunchGetTbHashTask
,
ctgHandleGetTbHashRsp
,
ctgDumpTbHashRes
},
{
ctgLaunchGetIndexTask
,
ctgHandleGetIndexRsp
,
ctgDumpIndexRes
},
{
ctgLaunchGetIndexTask
,
ctgHandleGetIndexRsp
,
ctgDumpIndexRes
},
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
14426025
...
@@ -19,37 +19,43 @@
...
@@ -19,37 +19,43 @@
#include "catalogInt.h"
#include "catalogInt.h"
#include "systable.h"
#include "systable.h"
SCtg
Action
gCtgAction
[
CTG_ACT
_MAX
]
=
{
SCtg
Operation
gCtgCacheOperation
[
CTG_OP
_MAX
]
=
{
{
{
CTG_
ACT_UPDATE_VG
,
CTG_
OP_UPDATE_VGROUP
,
"update vgInfo"
,
"update vgInfo"
,
ctg
ActUpdateVg
ctg
OpUpdateVgroup
},
},
{
{
CTG_
ACT_UPDATE_TBL
,
CTG_
OP_UPDATE_TB_META
,
"update tbMeta"
,
"update tbMeta"
,
ctg
ActUpdateTb
ctg
OpUpdateTbMeta
},
},
{
{
CTG_
ACT_REMOVE_DB
,
CTG_
OP_DROP_DB_CACHE
,
"
remove
DB"
,
"
drop
DB"
,
ctg
ActRemoveDB
ctg
OpDropDbCache
},
},
{
{
CTG_
ACT_REMOVE_STB
,
CTG_
OP_DROP_STB_META
,
"
remove
stbMeta"
,
"
drop
stbMeta"
,
ctg
ActRemoveStb
ctg
OpDropStbMeta
},
},
{
{
CTG_
ACT_REMOVE_TBL
,
CTG_
OP_DROP_TB_META
,
"
remove
tbMeta"
,
"
drop
tbMeta"
,
ctg
ActRemoveTb
ctg
OpDropTbMeta
},
},
{
{
CTG_
ACT
_UPDATE_USER
,
CTG_
OP
_UPDATE_USER
,
"update user"
,
"update user"
,
ctgActUpdateUser
ctgOpUpdateUser
},
{
CTG_OP_UPDATE_VG_EPSET
,
"update epset"
,
ctgOpUpdateEpset
}
}
};
};
...
@@ -405,7 +411,7 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *
...
@@ -405,7 +411,7 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *
}
}
int32_t
ctg
Get
TbTypeFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tableName
,
int32_t
*
tbType
)
{
int32_t
ctg
Read
TbTypeFromCache
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
const
char
*
tableName
,
int32_t
*
tbType
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
if
(
NULL
==
pCtg
->
dbCache
)
{
ctgWarn
(
"empty db cache, dbFName:%s, tbName:%s"
,
dbFName
,
tableName
);
ctgWarn
(
"empty db cache, dbFName:%s, tbName:%s"
,
dbFName
,
tableName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -491,7 +497,7 @@ _return:
...
@@ -491,7 +497,7 @@ _return:
}
}
void
ctgWait
Action
(
SCtgMetaAc
tion
*
action
)
{
void
ctgWait
OpDone
(
SCtgCacheOpera
tion
*
action
)
{
while
(
true
)
{
while
(
true
)
{
tsem_wait
(
&
gCtgMgmt
.
queue
.
rspSem
);
tsem_wait
(
&
gCtgMgmt
.
queue
.
rspSem
);
...
@@ -509,7 +515,7 @@ void ctgWaitAction(SCtgMetaAction *action) {
...
@@ -509,7 +515,7 @@ void ctgWaitAction(SCtgMetaAction *action) {
}
}
}
}
void
ctg
PopAction
(
SCtgMetaAction
**
action
)
{
void
ctg
Dequeue
(
SCtgCacheOperation
**
op
)
{
SCtgQNode
*
orig
=
gCtgMgmt
.
queue
.
head
;
SCtgQNode
*
orig
=
gCtgMgmt
.
queue
.
head
;
SCtgQNode
*
node
=
gCtgMgmt
.
queue
.
head
->
next
;
SCtgQNode
*
node
=
gCtgMgmt
.
queue
.
head
->
next
;
...
@@ -519,20 +525,20 @@ void ctgPopAction(SCtgMetaAction **action) {
...
@@ -519,20 +525,20 @@ void ctgPopAction(SCtgMetaAction **action) {
taosMemoryFreeClear
(
orig
);
taosMemoryFreeClear
(
orig
);
*
action
=
&
node
->
action
;
*
op
=
&
node
->
op
;
}
}
int32_t
ctg
PushAction
(
SCatalog
*
pCtg
,
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
Enqueue
(
SCatalog
*
pCtg
,
SCtgCacheOperation
*
opera
tion
)
{
SCtgQNode
*
node
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgQNode
));
SCtgQNode
*
node
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgQNode
));
if
(
NULL
==
node
)
{
if
(
NULL
==
node
)
{
qError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgQNode
));
qError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgQNode
));
CTG_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
ac
tion
->
seqId
=
atomic_add_fetch_64
(
&
gCtgMgmt
.
queue
.
seqId
,
1
);
opera
tion
->
seqId
=
atomic_add_fetch_64
(
&
gCtgMgmt
.
queue
.
seqId
,
1
);
node
->
action
=
*
ac
tion
;
node
->
op
=
*
opera
tion
;
CTG_LOCK
(
CTG_WRITE
,
&
gCtgMgmt
.
queue
.
qlock
);
CTG_LOCK
(
CTG_WRITE
,
&
gCtgMgmt
.
queue
.
qlock
);
gCtgMgmt
.
queue
.
tail
->
next
=
node
;
gCtgMgmt
.
queue
.
tail
->
next
=
node
;
...
@@ -544,19 +550,19 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) {
...
@@ -544,19 +550,19 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) {
tsem_post
(
&
gCtgMgmt
.
queue
.
reqSem
);
tsem_post
(
&
gCtgMgmt
.
queue
.
reqSem
);
ctgDebug
(
"action [%s] added into queue"
,
gCtg
Action
[
action
->
act
].
name
);
ctgDebug
(
"action [%s] added into queue"
,
gCtg
CacheOperation
[
operation
->
opId
].
name
);
if
(
ac
tion
->
syncReq
)
{
if
(
opera
tion
->
syncReq
)
{
ctgWait
Action
(
ac
tion
);
ctgWait
OpDone
(
opera
tion
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctg
PutRmDBToQ
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
)
{
int32_t
ctg
DropDbCacheEnq
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_DB
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP_DROP_DB_CACHE
};
SCtgRemoveDBMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveDBMsg
));
SCtgRemoveDBMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveDBMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveDBMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveDBMsg
));
...
@@ -574,7 +580,7 @@ int32_t ctgPutRmDBToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) {
...
@@ -574,7 +580,7 @@ int32_t ctgPutRmDBToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) {
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctg
PushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctg
Enqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -585,9 +591,9 @@ _return:
...
@@ -585,9 +591,9 @@ _return:
}
}
int32_t
ctg
PutRmStbToQ
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
stbName
,
uint64_t
suid
,
bool
syncReq
)
{
int32_t
ctg
DropStbMetaEnq
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
stbName
,
uint64_t
suid
,
bool
syncReq
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_STB
,
.
syncReq
=
syncReq
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP_DROP_STB_META
,
.
syncReq
=
syncReq
};
SCtgRemoveStbMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveStbMsg
));
SCtgRemoveStbMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveStbMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveStbMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveStbMsg
));
...
@@ -602,7 +608,7 @@ int32_t ctgPutRmStbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, co
...
@@ -602,7 +608,7 @@ int32_t ctgPutRmStbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, co
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctg
PushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctg
Enqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -614,9 +620,9 @@ _return:
...
@@ -614,9 +620,9 @@ _return:
int32_t
ctg
PutRmTbToQ
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
)
{
int32_t
ctg
DropTbMetaEnq
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
const
char
*
tbName
,
bool
syncReq
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT_REMOVE_TBL
,
.
syncReq
=
syncReq
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP_DROP_TB_META
,
.
syncReq
=
syncReq
};
SCtgRemoveTblMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveTblMsg
));
SCtgRemoveTblMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgRemoveTblMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveTblMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgRemoveTblMsg
));
...
@@ -630,7 +636,7 @@ int32_t ctgPutRmTbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, con
...
@@ -630,7 +636,7 @@ int32_t ctgPutRmTbToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, con
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctg
PushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctg
Enqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -640,9 +646,9 @@ _return:
...
@@ -640,9 +646,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctg
PutUpdateVgToQ
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
)
{
int32_t
ctg
UpdateVgroupEnq
ueue
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
int64_t
dbId
,
SDBVgInfo
*
dbInfo
,
bool
syncReq
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT_UPDATE_VG
,
.
syncReq
=
syncReq
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP_UPDATE_VGROUP
,
.
syncReq
=
syncReq
};
SCtgUpdateVgMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateVgMsg
));
SCtgUpdateVgMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateVgMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateVgMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateVgMsg
));
...
@@ -662,7 +668,7 @@ int32_t ctgPutUpdateVgToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId,
...
@@ -662,7 +668,7 @@ int32_t ctgPutUpdateVgToQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId,
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctg
PushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctg
Enqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -673,9 +679,9 @@ _return:
...
@@ -673,9 +679,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctg
PutUpdateTbToQ
ueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
)
{
int32_t
ctg
UpdateTbMetaEnq
ueue
(
SCatalog
*
pCtg
,
STableMetaOutput
*
output
,
bool
syncReq
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT_UPDATE_TBL
,
.
syncReq
=
syncReq
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP_UPDATE_TB_META
,
.
syncReq
=
syncReq
};
SCtgUpdateTblMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTblMsg
));
SCtgUpdateTblMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTblMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateTblMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateTblMsg
));
...
@@ -692,7 +698,34 @@ int32_t ctgPutUpdateTbToQueue(SCatalog* pCtg, STableMetaOutput *output, bool syn
...
@@ -692,7 +698,34 @@ int32_t ctgPutUpdateTbToQueue(SCatalog* pCtg, STableMetaOutput *output, bool syn
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctgPushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctgEnqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
int32_t
ctgUpdateVgEpsetEnqueue
(
SCatalog
*
pCtg
,
char
*
dbFName
,
int32_t
vgId
,
SEpSet
*
pEpSet
)
{
int32_t
code
=
0
;
SCtgCacheOperation
operation
=
{.
opId
=
CTG_OP_UPDATE_VG_EPSET
};
SCtgUpdateEpsetMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateEpsetMsg
));
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateEpsetMsg
));
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
msg
->
pCtg
=
pCtg
;
strcpy
(
msg
->
dbFName
,
dbFName
);
msg
->
vgId
=
vgId
;
msg
->
epSet
=
*
pEpSet
;
operation
.
data
=
msg
;
CTG_ERR_JRET
(
ctgEnqueue
(
pCtg
,
&
operation
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -703,9 +736,11 @@ _return:
...
@@ -703,9 +736,11 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgPutUpdateUserToQueue
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
,
bool
syncReq
)
{
int32_t
ctgUpdateUserEnqueue
(
SCatalog
*
pCtg
,
SGetUserAuthRsp
*
pAuth
,
bool
syncReq
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtg
MetaAction
action
=
{.
act
=
CTG_ACT
_UPDATE_USER
,
.
syncReq
=
syncReq
};
SCtg
CacheOperation
action
=
{.
opId
=
CTG_OP
_UPDATE_USER
,
.
syncReq
=
syncReq
};
SCtgUpdateUserMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateUserMsg
));
SCtgUpdateUserMsg
*
msg
=
taosMemoryMalloc
(
sizeof
(
SCtgUpdateUserMsg
));
if
(
NULL
==
msg
)
{
if
(
NULL
==
msg
)
{
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateUserMsg
));
ctgError
(
"malloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgUpdateUserMsg
));
...
@@ -717,7 +752,7 @@ int32_t ctgPutUpdateUserToQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syn
...
@@ -717,7 +752,7 @@ int32_t ctgPutUpdateUserToQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syn
action
.
data
=
msg
;
action
.
data
=
msg
;
CTG_ERR_JRET
(
ctg
PushAction
(
pCtg
,
&
action
));
CTG_ERR_JRET
(
ctg
Enqueue
(
pCtg
,
&
action
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1219,7 +1254,7 @@ int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool sync
...
@@ -1219,7 +1254,7 @@ int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool sync
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgCloneMetaOutput
(
pOut
,
&
pOutput
));
CTG_ERR_RET
(
ctgCloneMetaOutput
(
pOut
,
&
pOutput
));
CTG_ERR_JRET
(
ctg
PutUpdateTbToQ
ueue
(
pCtg
,
pOutput
,
syncReq
));
CTG_ERR_JRET
(
ctg
UpdateTbMetaEnq
ueue
(
pCtg
,
pOutput
,
syncReq
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1230,9 +1265,9 @@ _return:
...
@@ -1230,9 +1265,9 @@ _return:
}
}
int32_t
ctg
ActUpdateVg
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpUpdateVgroup
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgUpdateVgMsg
*
msg
=
ac
tion
->
data
;
SCtgUpdateVgMsg
*
msg
=
opera
tion
->
data
;
CTG_ERR_JRET
(
ctgWriteDBVgInfoToCache
(
msg
->
pCtg
,
msg
->
dbFName
,
msg
->
dbId
,
&
msg
->
dbInfo
));
CTG_ERR_JRET
(
ctgWriteDBVgInfoToCache
(
msg
->
pCtg
,
msg
->
dbFName
,
msg
->
dbId
,
&
msg
->
dbInfo
));
...
@@ -1244,9 +1279,9 @@ _return:
...
@@ -1244,9 +1279,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctg
ActRemoveDB
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpDropDbCache
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgRemoveDBMsg
*
msg
=
ac
tion
->
data
;
SCtgRemoveDBMsg
*
msg
=
opera
tion
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
...
@@ -1270,9 +1305,9 @@ _return:
...
@@ -1270,9 +1305,9 @@ _return:
}
}
int32_t
ctg
ActUpdateTb
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpUpdateTbMeta
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgUpdateTblMsg
*
msg
=
ac
tion
->
data
;
SCtgUpdateTblMsg
*
msg
=
opera
tion
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
STableMetaOutput
*
output
=
msg
->
output
;
STableMetaOutput
*
output
=
msg
->
output
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
...
@@ -1316,9 +1351,9 @@ _return:
...
@@ -1316,9 +1351,9 @@ _return:
}
}
int32_t
ctg
ActRemoveStb
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpDropStbMeta
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgRemoveStbMsg
*
msg
=
ac
tion
->
data
;
SCtgRemoveStbMsg
*
msg
=
opera
tion
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
...
@@ -1362,9 +1397,9 @@ _return:
...
@@ -1362,9 +1397,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctg
ActRemoveTb
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpDropTbMeta
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgRemoveTblMsg
*
msg
=
ac
tion
->
data
;
SCtgRemoveTblMsg
*
msg
=
opera
tion
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
...
@@ -1397,9 +1432,9 @@ _return:
...
@@ -1397,9 +1432,9 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctg
ActUpdateUser
(
SCtgMetaAction
*
ac
tion
)
{
int32_t
ctg
OpUpdateUser
(
SCtgCacheOperation
*
opera
tion
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgUpdateUserMsg
*
msg
=
ac
tion
->
data
;
SCtgUpdateUserMsg
*
msg
=
opera
tion
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
if
(
NULL
==
pCtg
->
userCache
)
{
if
(
NULL
==
pCtg
->
userCache
)
{
...
@@ -1460,14 +1495,60 @@ _return:
...
@@ -1460,14 +1495,60 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
void
ctgUpdateThreadFuncUnexpectedStopped
(
void
)
{
int32_t
ctgOpUpdateEpset
(
SCtgCacheOperation
*
operation
)
{
int32_t
code
=
0
;
SCtgUpdateEpsetMsg
*
msg
=
operation
->
data
;
SCatalog
*
pCtg
=
msg
->
pCtg
;
SCtgDBCache
*
dbCache
=
NULL
;
CTG_ERR_RET
(
ctgAcquireDBCache
(
pCtg
,
msg
->
dbFName
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not exist, ignore epset update"
,
msg
->
dbFName
);
goto
_return
;
}
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgWAcquireVgInfo
(
pCtg
,
dbCache
));
if
(
NULL
==
dbCache
->
vgInfo
)
{
ctgWReleaseVgInfo
(
dbCache
);
ctgDebug
(
"vgroup in db %s not cached, ignore epset update"
,
msg
->
dbFName
);
goto
_return
;
}
SVgroupInfo
*
pInfo
=
taosHashGet
(
dbCache
->
vgInfo
->
vgHash
,
&
msg
->
vgId
,
sizeof
(
msg
->
vgId
));
if
(
NULL
==
pInfo
)
{
ctgWReleaseVgInfo
(
dbCache
);
ctgDebug
(
"no vgroup %d in db %s, ignore epset update"
,
msg
->
vgId
,
msg
->
dbFName
);
goto
_return
;
}
pInfo
->
epSet
=
msg
->
epSet
;
ctgDebug
(
"epset in vgroup %d updated, dbFName:%s"
,
pInfo
->
vgId
,
msg
->
dbFName
);
ctgWReleaseVgInfo
(
dbCache
);
_return:
if
(
dbCache
)
{
ctgReleaseDBCache
(
msg
->
pCtg
,
dbCache
);
}
taosMemoryFreeClear
(
msg
);
CTG_RET
(
code
);
}
void
ctgUpdateThreadUnexpectedStopped
(
void
)
{
if
(
CTG_IS_LOCKED
(
&
gCtgMgmt
.
lock
)
>
0
)
CTG_UNLOCK
(
CTG_READ
,
&
gCtgMgmt
.
lock
);
if
(
CTG_IS_LOCKED
(
&
gCtgMgmt
.
lock
)
>
0
)
CTG_UNLOCK
(
CTG_READ
,
&
gCtgMgmt
.
lock
);
}
}
void
*
ctgUpdateThreadFunc
(
void
*
param
)
{
void
*
ctgUpdateThreadFunc
(
void
*
param
)
{
setThreadName
(
"catalog"
);
setThreadName
(
"catalog"
);
#ifdef WINDOWS
#ifdef WINDOWS
atexit
(
ctgUpdateThread
Func
UnexpectedStopped
);
atexit
(
ctgUpdateThreadUnexpectedStopped
);
#endif
#endif
qInfo
(
"catalog update thread started"
);
qInfo
(
"catalog update thread started"
);
...
@@ -1483,17 +1564,17 @@ void* ctgUpdateThreadFunc(void* param) {
...
@@ -1483,17 +1564,17 @@ void* ctgUpdateThreadFunc(void* param) {
break
;
break
;
}
}
SCtg
MetaAction
*
ac
tion
=
NULL
;
SCtg
CacheOperation
*
opera
tion
=
NULL
;
ctg
PopAction
(
&
ac
tion
);
ctg
Dequeue
(
&
opera
tion
);
SCatalog
*
pCtg
=
((
SCtgUpdateMsgHeader
*
)
ac
tion
->
data
)
->
pCtg
;
SCatalog
*
pCtg
=
((
SCtgUpdateMsgHeader
*
)
opera
tion
->
data
)
->
pCtg
;
ctgDebug
(
"process [%s]
action"
,
gCtgAction
[
action
->
act
].
name
);
ctgDebug
(
"process [%s]
operation"
,
gCtgCacheOperation
[
operation
->
opId
].
name
);
(
*
gCtg
Action
[
action
->
act
].
func
)(
ac
tion
);
(
*
gCtg
CacheOperation
[
operation
->
opId
].
func
)(
opera
tion
);
gCtgMgmt
.
queue
.
seqDone
=
ac
tion
->
seqId
;
gCtgMgmt
.
queue
.
seqDone
=
opera
tion
->
seqId
;
if
(
ac
tion
->
syncReq
)
{
if
(
opera
tion
->
syncReq
)
{
tsem_post
(
&
gCtgMgmt
.
queue
.
rspSem
);
tsem_post
(
&
gCtgMgmt
.
queue
.
rspSem
);
}
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
14426025
...
@@ -42,6 +42,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
...
@@ -42,6 +42,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
}
}
taosArrayDestroy
(
pData
->
pDbCfg
);
taosArrayDestroy
(
pData
->
pDbCfg
);
pData
->
pDbCfg
=
NULL
;
pData
->
pDbCfg
=
NULL
;
taosArrayDestroy
(
pData
->
pDbInfo
);
pData
->
pDbInfo
=
NULL
;
taosArrayDestroy
(
pData
->
pIndex
);
taosArrayDestroy
(
pData
->
pIndex
);
pData
->
pIndex
=
NULL
;
pData
->
pIndex
=
NULL
;
...
@@ -293,9 +296,12 @@ void ctgFreeTask(SCtgTask* pTask) {
...
@@ -293,9 +296,12 @@ void ctgFreeTask(SCtgTask* pTask) {
}
}
case
CTG_TASK_GET_DB_CFG
:
{
case
CTG_TASK_GET_DB_CFG
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
if
(
pTask
->
res
)
{
taosMemoryFreeClear
(
pTask
->
res
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
}
case
CTG_TASK_GET_DB_INFO
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
break
;
}
}
case
CTG_TASK_GET_TB_HASH
:
{
case
CTG_TASK_GET_TB_HASH
:
{
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
14426025
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
namespace
{
namespace
{
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgdGetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctg
ActUpdateTb
(
SCtgMetaAc
tion
*
action
);
extern
"C"
int32_t
ctg
OpUpdateTbMeta
(
SCtgCacheOpera
tion
*
action
);
extern
"C"
int32_t
ctgdEnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctgdEnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
);
extern
"C"
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
);
...
@@ -888,9 +888,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
...
@@ -888,9 +888,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
int32_t
n
=
0
;
int32_t
n
=
0
;
STableMetaOutput
*
output
=
NULL
;
STableMetaOutput
*
output
=
NULL
;
SCtg
MetaAction
ac
tion
=
{
0
};
SCtg
CacheOperation
opera
tion
=
{
0
};
action
.
act
=
CTG_ACT_UPDATE_TBL
;
operation
.
opId
=
CTG_OP_UPDATE_TB_META
;
while
(
!
ctgTestStop
)
{
while
(
!
ctgTestStop
)
{
output
=
(
STableMetaOutput
*
)
taosMemoryMalloc
(
sizeof
(
STableMetaOutput
));
output
=
(
STableMetaOutput
*
)
taosMemoryMalloc
(
sizeof
(
STableMetaOutput
));
...
@@ -899,9 +899,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
...
@@ -899,9 +899,9 @@ void *ctgTestSetCtableMetaThread(void *param) {
SCtgUpdateTblMsg
*
msg
=
(
SCtgUpdateTblMsg
*
)
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTblMsg
));
SCtgUpdateTblMsg
*
msg
=
(
SCtgUpdateTblMsg
*
)
taosMemoryMalloc
(
sizeof
(
SCtgUpdateTblMsg
));
msg
->
pCtg
=
pCtg
;
msg
->
pCtg
=
pCtg
;
msg
->
output
=
output
;
msg
->
output
=
output
;
ac
tion
.
data
=
msg
;
opera
tion
.
data
=
msg
;
code
=
ctg
ActUpdateTb
(
&
ac
tion
);
code
=
ctg
OpUpdateTbMeta
(
&
opera
tion
);
if
(
code
)
{
if
(
code
)
{
assert
(
0
);
assert
(
0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录