Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
e9c0e7d2
T
TDengine
项目概览
qq_50753323
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e9c0e7d2
编写于
9月 04, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]
上级
d28decc9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
15 deletion
+14
-15
src/util/src/tcache.c
src/util/src/tcache.c
+14
-15
未找到文件。
src/util/src/tcache.c
浏览文件 @
e9c0e7d2
...
...
@@ -90,7 +90,6 @@ static void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force);
static
FORCE_INLINE
void
taosCacheReleaseNode
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
)
{
if
(
pNode
->
signature
!=
(
uint64_t
)
pNode
)
{
uError
(
"key:%s, %p data is invalid, or has been released"
,
pNode
->
key
,
pNode
);
assert
(
0
);
return
;
}
...
...
@@ -98,7 +97,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t
size
=
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
);
assert
(
size
>
0
);
u
Error
(
"cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%"
PRId64
"bytes"
,
u
Debug
(
"cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%"
PRId64
"bytes"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
pNode
->
size
,
size
-
1
,
pCacheObj
->
totalSize
);
if
(
pCacheObj
->
freeFp
)
{
...
...
@@ -275,10 +274,10 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
if
(
pData
!=
NULL
)
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
hitCount
,
1
);
u
Error
(
"cache:%s, key:%p, %p is retrieved from cache, refcnt:%d"
,
pCacheObj
->
name
,
key
,
pData
,
T_REF_VAL_GET
(
*
ptNode
));
u
Debug
(
"cache:%s, key:%p, %p is retrieved from cache, refcnt:%d"
,
pCacheObj
->
name
,
key
,
pData
,
T_REF_VAL_GET
(
*
ptNode
));
}
else
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
missCount
,
1
);
u
Error
(
"cache:%s, key:%p, not in cache, retrieved failed"
,
pCacheObj
->
name
,
key
);
u
Debug
(
"cache:%s, key:%p, not in cache, retrieved failed"
,
pCacheObj
->
name
,
key
);
}
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
totalAccess
,
1
);
...
...
@@ -292,12 +291,12 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) {
SCacheDataNode
*
ptNode
=
(
SCacheDataNode
*
)((
char
*
)
data
-
offset
);
if
(
ptNode
->
signature
!=
(
uint64_t
)
ptNode
)
{
uError
(
"
key: %p the data from cache is invalid"
,
ptNode
);
uError
(
"
cache:%s, key: %p the data from cache is invalid"
,
pCacheObj
->
name
,
ptNode
);
return
NULL
;
}
int32_t
ref
=
T_REF_INC
(
ptNode
);
u
Error
(
"cache:%s, data: %p acquired by data in cache, refcnt:%d"
,
pCacheObj
->
name
,
ptNode
->
data
,
ref
);
u
Debug
(
"cache:%s, data: %p acquired by data in cache, refcnt:%d"
,
pCacheObj
->
name
,
ptNode
->
data
,
ref
);
// the data if referenced by at least one object, so the reference count must be greater than the value of 2.
assert
(
ref
>=
2
);
...
...
@@ -311,7 +310,7 @@ void *taosCacheTransfer(SCacheObj *pCacheObj, void **data) {
SCacheDataNode
*
ptNode
=
(
SCacheDataNode
*
)((
char
*
)(
*
data
)
-
offset
);
if
(
ptNode
->
signature
!=
(
uint64_t
)
ptNode
)
{
uError
(
"
key: %p the data from cache is invalid"
,
ptNode
);
uError
(
"
cache:%s, key: %p the data from cache is invalid"
,
pCacheObj
->
name
,
ptNode
);
return
NULL
;
}
...
...
@@ -345,7 +344,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
if
(
pCacheObj
->
extendLifespan
&&
(
!
inTrashCan
)
&&
(
!
_remove
))
{
atomic_store_64
(
&
pNode
->
expireTime
,
pNode
->
lifespan
+
taosGetTimestampMs
());
u
Error
(
"cache:%s data:%p extend expire time: %"
PRId64
,
pCacheObj
->
name
,
pNode
->
data
,
pNode
->
expireTime
);
u
Debug
(
"cache:%s data:%p extend expire time: %"
PRId64
,
pCacheObj
->
name
,
pNode
->
data
,
pNode
->
expireTime
);
}
if
(
_remove
)
{
...
...
@@ -354,7 +353,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
char
*
d
=
pNode
->
data
;
int32_t
ref
=
T_REF_VAL_GET
(
pNode
);
uError
(
"cache:%s, key:%p, %p is released, refcnt:%d, in
trash
:%d"
,
pCacheObj
->
name
,
key
,
d
,
ref
-
1
,
inTrashCan
);
uError
(
"cache:%s, key:%p, %p is released, refcnt:%d, in
trashcan
:%d"
,
pCacheObj
->
name
,
key
,
d
,
ref
-
1
,
inTrashCan
);
/*
* If it is not referenced by other users, remove it immediately. Otherwise move this node to trashcan wait for all users
...
...
@@ -432,7 +431,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
char
*
p
=
pNode
->
data
;
int32_t
ref
=
T_REF_DEC
(
pNode
);
u
Error
(
"cache:%s, key:%p, %p released, refcnt:%d, data in trashcan:%d"
,
pCacheObj
->
name
,
key
,
p
,
ref
,
inTrashCan
);
u
Debug
(
"cache:%s, key:%p, %p released, refcnt:%d, data in trashcan:%d"
,
pCacheObj
->
name
,
key
,
p
,
ref
,
inTrashCan
);
}
}
...
...
@@ -524,7 +523,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
pCacheObj
->
numOfElemsInTrash
++
;
__cache_unlock
(
pCacheObj
);
u
Error
(
"cache:%s key:%p, %p move to trash, numOfElem in trash:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
u
Debug
(
"cache:%s key:%p, %p move to trash, numOfElem in trash:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
pCacheObj
->
numOfElemsInTrash
);
}
...
...
@@ -533,7 +532,7 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
if
(
pCacheObj
->
numOfElemsInTrash
==
0
)
{
if
(
pCacheObj
->
pTrash
!=
NULL
)
{
uError
(
"
key:inconsistency data in cache, numOfElem in trash:%d"
,
pCacheObj
->
numOfElemsInTrash
);
uError
(
"
cache:%s, key:inconsistency data in cache, numOfElem in trash:%d"
,
pCacheObj
->
name
,
pCacheObj
->
numOfElemsInTrash
);
}
pCacheObj
->
pTrash
=
NULL
;
...
...
@@ -550,7 +549,7 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
}
if
(
force
||
(
T_REF_VAL_GET
(
pElem
->
pData
)
==
0
))
{
uError
(
"
key:%p, %p removed from trash. numOfElem in trash:%d"
,
pElem
->
pData
->
key
,
pElem
->
pData
->
data
,
uError
(
"
cache:%s, key:%p, %p removed from trash. numOfElem in trash:%d"
,
pCacheObj
->
name
,
pElem
->
pData
->
key
,
pElem
->
pData
->
data
,
pCacheObj
->
numOfElemsInTrash
-
1
);
STrashElem
*
p
=
pElem
;
...
...
@@ -611,7 +610,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
void
*
taosCacheTimedRefresh
(
void
*
handle
)
{
SCacheObj
*
pCacheObj
=
handle
;
if
(
pCacheObj
==
NULL
)
{
u
Error
(
"object is destroyed. no refresh retry"
);
u
Debug
(
"object is destroyed. no refresh retry"
);
return
NULL
;
}
...
...
@@ -624,7 +623,7 @@ void* taosCacheTimedRefresh(void *handle) {
// check if current cache object will be deleted every 500ms.
if
(
pCacheObj
->
deleting
)
{
u
Error
(
"%s refresh threads quit"
,
pCacheObj
->
name
);
u
Debug
(
"%s refresh threads quit"
,
pCacheObj
->
name
);
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录