Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
175d4c55
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看板
提交
175d4c55
编写于
9月 28, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]add handle expired check
上级
0e1a4576
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
0 deletion
+26
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+1
-0
src/util/inc/tcache.h
src/util/inc/tcache.h
+4
-0
src/util/src/tcache.c
src/util/src/tcache.c
+21
-0
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
175d4c55
...
...
@@ -6986,6 +6986,7 @@ void* qOpenQueryMgmt(int32_t vgId) {
pthread_mutex_init
(
&
pQueryMgmt
->
lock
,
NULL
);
taosCacheCheckforExpire
(
pQueryMgmt
->
qinfoPool
,
600
);
qDebug
(
"vgId:%d, open querymgmt success"
,
vgId
);
return
pQueryMgmt
;
}
...
...
src/util/inc/tcache.h
浏览文件 @
175d4c55
...
...
@@ -75,6 +75,7 @@ typedef struct {
uint8_t
deleting
;
// set the deleting flag to stop refreshing ASAP.
pthread_t
refreshWorker
;
bool
extendLifespan
;
// auto extend life span when one item is accessed.
int32_t
itemExpireTime
;
// maximum live time in ms in cache for object, if -1, mean never expired.
#if defined(LINUX)
pthread_rwlock_t
lock
;
#else
...
...
@@ -169,6 +170,9 @@ void taosCacheCleanup(SCacheObj *pCacheObj);
*/
void
taosCacheRefresh
(
SCacheObj
*
pCacheObj
,
__cache_free_fn_t
fp
);
// check the query handle not released, debug purpose only
void
taosCacheCheckforExpire
(
SCacheObj
*
pCacheObj
,
int32_t
expireTimeSec
);
#ifdef __cplusplus
}
#endif
...
...
src/util/src/tcache.c
浏览文件 @
175d4c55
...
...
@@ -170,6 +170,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
pCacheObj
->
freeFp
=
fn
;
pCacheObj
->
refreshTime
=
refreshTimeInSeconds
*
1000
;
pCacheObj
->
extendLifespan
=
extendLifespan
;
pCacheObj
->
itemExpireTime
=
-
1
;
if
(
__cache_lock_init
(
pCacheObj
)
!=
0
)
{
taosHashCleanup
(
pCacheObj
->
pHashTable
);
...
...
@@ -521,6 +522,8 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
}
void
taosTrashCanEmpty
(
SCacheObj
*
pCacheObj
,
bool
force
)
{
int64_t
now
=
taosGetTimestampMs
();
__cache_wr_lock
(
pCacheObj
);
if
(
pCacheObj
->
numOfElemsInTrash
==
0
)
{
...
...
@@ -551,6 +554,12 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
doRemoveElemInTrashcan
(
pCacheObj
,
p
);
doDestroyTrashcanElem
(
pCacheObj
,
p
);
}
else
{
// any item should not live longer than the specificed expired time
assert
(
now
>=
pElem
->
pData
->
addedTime
);
if
(
pCacheObj
->
itemExpireTime
>
0
&&
((
now
-
pElem
->
pData
->
addedTime
)
>
pCacheObj
->
itemExpireTime
))
{
assert
(
0
);
}
pElem
=
pElem
->
next
;
}
}
...
...
@@ -653,3 +662,15 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_free_fn_t fp) {
int64_t
now
=
taosGetTimestampMs
();
doCacheRefresh
(
pCacheObj
,
now
,
fp
);
}
void
taosCacheCheckforExpire
(
SCacheObj
*
pCacheObj
,
int32_t
expireTimeSec
)
{
if
(
pCacheObj
==
NULL
||
expireTimeSec
<
0
)
{
return
;
}
if
(
expireTimeSec
<
pCacheObj
->
refreshTime
)
{
expireTimeSec
=
pCacheObj
->
refreshTime
*
20
;
}
pCacheObj
->
itemExpireTime
=
expireTimeSec
*
1000
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录