Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
55159a7c
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看板
提交
55159a7c
编写于
12月 22, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): update the mutex.
上级
98722174
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
16 deletion
+28
-16
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+28
-16
未找到文件。
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
55159a7c
...
...
@@ -54,6 +54,7 @@ struct SMetaCache {
// query cache
struct
STagFilterResCache
{
TdThreadMutex
lock
;
SHashObj
*
pTableEntry
;
SLRUCache
*
pUidResCache
;
uint64_t
keyBuf
[
3
];
...
...
@@ -140,6 +141,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
}
taosHashSetFreeFp
(
pCache
->
sTagFilterResCache
.
pTableEntry
,
freeCacheEntryFp
);
taosThreadMutexInit
(
&
pCache
->
sTagFilterResCache
.
lock
,
NULL
);
pMeta
->
pCache
=
pCache
;
return
code
;
...
...
@@ -159,6 +162,8 @@ void metaCacheClose(SMeta* pMeta) {
taosHashCleanup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
);
taosLRUCacheCleanup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
);
taosThreadMutexDestroy
(
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
);
taosMemoryFree
(
pMeta
->
pCache
);
pMeta
->
pCache
=
NULL
;
}
...
...
@@ -426,6 +431,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
SLRUCache
*
pCache
=
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
;
uint64_t
*
pBuf
=
pMeta
->
pCache
->
sTagFilterResCache
.
keyBuf
;
SHashObj
*
pTableMap
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
uint32_t
times
=
0
;
...
...
@@ -433,12 +439,12 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
pBuf
[
0
]
=
suid
;
memcpy
(
&
pBuf
[
1
],
pKey
,
keyLen
);
metaRLock
(
pMeta
);
taosThreadMutexLock
(
pLock
);
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
);
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
pBuf
,
len
);
if
(
pHandle
==
NULL
)
{
metaULock
(
pMeta
);
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -457,11 +463,11 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
// unlock meta
metaULock
(
pMeta
);
taosThreadMutexUnlock
(
pLock
);
// check if scanning all items are necessary or not
if
(
times
>=
5000
&&
TD_DLIST_NELES
(
&
(
*
pEntry
)
->
list
)
>
10
)
{
metaWLock
(
pMeta
);
taosThreadMutexLock
(
pLock
);
SArray
*
pInvalidRes
=
taosArrayInit
(
64
,
POINTER_BYTES
);
...
...
@@ -492,7 +498,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
atomic_store_32
(
&
(
*
pEntry
)
->
qTimes
,
0
);
// reset the query times
taosArrayDestroy
(
pInvalidRes
);
metaULock
(
pMeta
);
taosThreadMutexUnlock
(
pLock
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -526,8 +532,9 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
SLRUCache
*
pCache
=
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
;
SHashObj
*
pTableEntry
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
metaWLock
(
pMeta
);
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
)
{
...
...
@@ -550,7 +557,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
taosLRUCacheInsert
(
pCache
,
pBuf
,
sizeof
(
uint64_t
)
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
metaULock
(
pMeta
);
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" list cache added into cache, total:%d, tables:%d"
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
(
int32_t
)
taosLRUCacheGetUsage
(
pCache
),
taosHashGetSize
(
pTableEntry
));
...
...
@@ -560,15 +567,19 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
int32_t
metaUidCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
)
{
int32_t
keyLen
=
sizeof
(
uint64_t
)
*
3
;
uint64_t
p
[
3
]
=
{
0
};
p
[
0
]
=
suid
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
||
listNEles
(
&
(
*
pEntry
)
->
list
)
==
0
)
{
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
keyLen
=
sizeof
(
uint64_t
)
*
3
;
uint64_t
p
[
3
]
=
{
0
};
p
[
0
]
=
suid
;
SListIter
iter
=
{
0
};
tdListInitIter
(
&
(
*
pEntry
)
->
list
,
&
iter
,
TD_LIST_FORWARD
);
...
...
@@ -581,5 +592,6 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
(
*
pEntry
)
->
qTimes
=
0
;
tdListEmpty
(
&
(
*
pEntry
)
->
list
);
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录