Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b024db90
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b024db90
编写于
1月 24, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/bugfix/3.0_memleak' into feature/qnode
上级
7d700361
4d1ba65c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
94 addition
and
19 deletion
+94
-19
include/common/tmsg.h
include/common/tmsg.h
+2
-2
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+89
-15
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
b024db90
...
...
@@ -147,7 +147,7 @@ typedef struct {
}
SBuildTableMetaInput
;
typedef
struct
{
char
db
[
TSDB_
TABLE
_FNAME_LEN
];
char
db
[
TSDB_
DB
_FNAME_LEN
];
int32_t
vgVersion
;
}
SBuildUseDBInput
;
...
...
@@ -746,7 +746,7 @@ typedef struct {
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
uid
;
uint64_t
uid
;
int32_t
vgVersion
;
int32_t
vgNum
;
int8_t
hashMethod
;
...
...
include/libs/catalog/catalog.h
浏览文件 @
b024db90
...
...
@@ -59,6 +59,7 @@ typedef struct SSTableMetaVersion {
}
SSTableMetaVersion
;
typedef
struct
SDbVgVersion
{
char
dbName
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int32_t
vgVersion
;
}
SDbVgVersion
;
...
...
include/libs/qcom/query.h
浏览文件 @
b024db90
...
...
@@ -82,7 +82,7 @@ typedef struct STableMeta {
typedef
struct
SDBVgroupInfo
{
SRWLatch
lock
;
int64_t
dbId
;
uint64_t
dbId
;
int32_t
vgVersion
;
int8_t
hashMethod
;
SHashObj
*
vgInfo
;
//key:vgId, value:SVgroupInfo
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
b024db90
...
...
@@ -737,7 +737,7 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm
}
int32_t
ctgValidateAnd
RemoveDb
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
)
{
int32_t
ctgValidateAnd
FreeDbInfo
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
)
{
SDBVgroupInfo
*
oldInfo
=
(
SDBVgroupInfo
*
)
taosHashAcquire
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
));
if
(
oldInfo
)
{
CTG_LOCK
(
CTG_WRITE
,
&
oldInfo
->
lock
);
...
...
@@ -763,6 +763,48 @@ int32_t ctgValidateAndRemoveDb(struct SCatalog* pCatalog, const char* dbName, SD
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgValidateAndRemoveDbInfo
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
*
target
)
{
SDBVgroupInfo
*
info
=
(
SDBVgroupInfo
*
)
taosHashAcquire
(
pCatalog
->
dbCache
.
cache
,
target
->
dbName
,
strlen
(
target
->
dbName
));
if
(
info
)
{
CTG_LOCK
(
CTG_WRITE
,
&
info
->
lock
);
if
(
info
->
dbId
!=
target
->
dbId
)
{
ctgInfo
(
"db id already updated, db:%s, dbId:%"
PRIx64
", targetId:%"
PRIx64
,
target
->
dbName
,
info
->
dbId
,
target
->
dbId
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
return
TSDB_CODE_SUCCESS
;
}
if
(
info
->
vgVersion
>
target
->
vgVersion
)
{
ctgInfo
(
"db vgVersion already updated, db:%s, version:%d, targetVer:%d"
,
target
->
dbName
,
info
->
vgVersion
,
target
->
vgVersion
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
return
TSDB_CODE_SUCCESS
;
}
if
(
info
->
vgInfo
)
{
ctgInfo
(
"cleanup db vgInfo, db:%s"
,
target
->
dbName
);
taosHashCleanup
(
info
->
vgInfo
);
info
->
vgInfo
=
NULL
;
}
if
(
taosHashRemove
(
pCatalog
->
dbCache
.
cache
,
target
->
dbName
,
strlen
(
target
->
dbName
)))
{
ctgError
(
"taosHashRemove from dbCache failed, db:%s"
,
target
->
dbName
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgRenewTableMetaImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
if
(
NULL
==
pCatalog
||
NULL
==
pTransporter
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
...
@@ -1134,19 +1176,6 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
if
(
dbInfo
->
vgVersion
<
0
)
{
ctgWarn
(
"db vgVersion less than 0, dbName:%s, vgVersion:%d"
,
dbName
,
dbInfo
->
vgVersion
);
if
(
pCatalog
->
dbCache
.
cache
)
{
CTG_ERR_JRET
(
ctgValidateAndRemoveDb
(
pCatalog
,
dbName
,
dbInfo
));
CTG_ERR_JRET
(
taosHashRemove
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
)));
}
ctgWarn
(
"db removed from cache, db:%s"
,
dbName
);
goto
_return
;
}
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxDBCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
cache
)
{
...
...
@@ -1158,9 +1187,53 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB
taosHashCleanup
(
cache
);
}
}
else
{
CTG_ERR_JRET
(
ctgValidateAndRemoveDb
(
pCatalog
,
dbName
,
dbInfo
));
CTG_ERR_JRET
(
ctgValidateAndFreeDbInfo
(
pCatalog
,
dbName
,
dbInfo
));
}
bool
newAdded
=
false
;
if
(
taosHashPutExt
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
),
dbInfo
,
sizeof
(
*
dbInfo
),
&
newAdded
)
!=
0
)
{
ctgError
(
"taosHashPutExt db vgroup to cache failed, db:%s"
,
dbName
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
dbInfo
->
vgInfo
=
NULL
;
SDbVgVersion
vgVersion
=
{.
dbId
=
dbInfo
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
};
if
(
newAdded
)
{
CTG_ERR_JRET
(
ctgMetaRentAdd
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
dbInfo
->
dbId
,
sizeof
(
SDbVgVersion
)));
}
else
{
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
dbInfo
->
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionCompare
));
}
ctgDebug
(
"dbName:%s vgroup updated, vgVersion:%d"
,
dbName
,
dbInfo
->
vgVersion
);
_return:
if
(
dbInfo
&&
dbInfo
->
vgInfo
)
{
taosHashCleanup
(
dbInfo
->
vgInfo
);
dbInfo
->
vgInfo
=
NULL
;
}
CTG_RET
(
code
);
}
int32_t
catalogRemoveDBVgroup
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
*
dbInfo
)
{
int32_t
code
=
0
;
if
(
NULL
==
pCatalog
||
NULL
==
dbInfo
)
{
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
if
(
pCatalog
->
dbCache
.
cache
)
{
CTG_ERR_JRET
(
ctgValidateAndRemoveDbInfo
(
pCatalog
,
dbInfo
));
CTG_ERR_JRET
(
taosHashRemove
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
)));
}
ctgWarn
(
"db removed from cache, db:%s"
,
dbName
);
bool
newAdded
=
false
;
if
(
taosHashPutExt
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
),
dbInfo
,
sizeof
(
*
dbInfo
),
&
newAdded
)
!=
0
)
{
ctgError
(
"taosHashPutExt db vgroup to cache failed, db:%s"
,
dbName
);
...
...
@@ -1189,6 +1262,7 @@ _return:
CTG_RET
(
code
);
}
int32_t
catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
return
ctgGetTableMeta
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
false
,
pTableMeta
,
-
1
);
}
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
b024db90
...
...
@@ -59,7 +59,7 @@ int32_t ctgTestTagNum = 1;
int32_t
ctgTestSVersion
=
1
;
int32_t
ctgTestTVersion
=
1
;
int32_t
ctgTestSuid
=
2
;
int64_t
ctgTestDbId
=
33
;
u
int64_t
ctgTestDbId
=
33
;
uint64_t
ctgTestClusterId
=
0x1
;
char
*
ctgTestDbname
=
"1.db1"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录