Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bf8c9f7d
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看板
提交
bf8c9f7d
编写于
9月 04, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]
上级
510be650
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
18 deletion
+18
-18
src/util/src/tcache.c
src/util/src/tcache.c
+18
-18
未找到文件。
src/util/src/tcache.c
浏览文件 @
bf8c9f7d
...
...
@@ -98,7 +98,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t
size
=
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
);
assert
(
size
>
0
);
u
Debug
(
"cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%"
PRId64
"bytes"
,
u
Error
(
"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
)
{
...
...
@@ -205,7 +205,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
int32_t
succ
=
taosHashPut
(
pCacheObj
->
pHashTable
,
key
,
keyLen
,
&
pNode1
,
sizeof
(
void
*
));
if
(
succ
==
0
)
{
atomic_add_fetch_64
(
&
pCacheObj
->
totalSize
,
pNode1
->
size
);
u
Debug
(
"cache:%s, key:%p, %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
u
Error
(
"cache:%s, key:%p, %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
", totalNum:%d totalSize:%"
PRId64
"bytes size:%"
PRId64
"bytes"
,
pCacheObj
->
name
,
key
,
pNode1
->
data
,
pNode1
->
addedTime
,
pNode1
->
expireTime
,
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
),
pCacheObj
->
totalSize
,
(
int64_t
)
dataSize
);
...
...
@@ -224,7 +224,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
taosTFree
(
p
);
}
else
{
taosAddToTrash
(
pCacheObj
,
p
);
u
Debug
(
"cache:%s, key:%p, %p exist in cache, updated old:%p"
,
pCacheObj
->
name
,
key
,
pNode1
->
data
,
p
);
u
Error
(
"cache:%s, key:%p, %p exist in cache, updated old:%p"
,
pCacheObj
->
name
,
key
,
pNode1
->
data
,
p
);
}
}
...
...
@@ -234,7 +234,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
if
(
ret
==
0
)
{
atomic_add_fetch_64
(
&
pCacheObj
->
totalSize
,
pNode1
->
size
);
u
Debug
(
"cache:%s, key:%p, %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
u
Error
(
"cache:%s, key:%p, %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
", totalNum:%d totalSize:%"
PRId64
"bytes size:%"
PRId64
"bytes"
,
pCacheObj
->
name
,
key
,
pNode1
->
data
,
pNode1
->
addedTime
,
pNode1
->
expireTime
,
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
),
pCacheObj
->
totalSize
,
(
int64_t
)
dataSize
);
...
...
@@ -275,10 +275,10 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
if
(
pData
!=
NULL
)
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
hitCount
,
1
);
u
Debug
(
"cache:%s, key:%p, %p is retrieved from cache, refcnt:%d"
,
pCacheObj
->
name
,
key
,
pData
,
T_REF_VAL_GET
(
*
ptNode
));
u
Error
(
"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
Debug
(
"cache:%s, key:%p, not in cache, retrieved failed"
,
pCacheObj
->
name
,
key
);
u
Error
(
"cache:%s, key:%p, not in cache, retrieved failed"
,
pCacheObj
->
name
,
key
);
}
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
totalAccess
,
1
);
...
...
@@ -297,7 +297,7 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) {
}
int32_t
ref
=
T_REF_INC
(
ptNode
);
u
Debug
(
"cache:%s, data: %p acquired by data in cache, refcnt:%d"
,
pCacheObj
->
name
,
ptNode
->
data
,
ref
);
u
Error
(
"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
);
...
...
@@ -345,7 +345,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
if
(
pCacheObj
->
extendLifespan
&&
(
!
inTrashCan
)
&&
(
!
_remove
))
{
atomic_store_64
(
&
pNode
->
expireTime
,
pNode
->
lifespan
+
taosGetTimestampMs
());
u
Debug
(
"cache:%s data:%p extend expire time: %"
PRId64
,
pCacheObj
->
name
,
pNode
->
data
,
pNode
->
expireTime
);
u
Error
(
"cache:%s data:%p extend expire time: %"
PRId64
,
pCacheObj
->
name
,
pNode
->
data
,
pNode
->
expireTime
);
}
if
(
_remove
)
{
...
...
@@ -354,7 +354,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
char
*
d
=
pNode
->
data
;
int32_t
ref
=
T_REF_VAL_GET
(
pNode
);
u
Debug
(
"cache:%s, key:%p, %p is released, refcnt:%d, intrash:%d"
,
pCacheObj
->
name
,
key
,
d
,
ref
-
1
,
inTrashCan
);
u
Error
(
"cache:%s, key:%p, %p is released, refcnt:%d, intrash:%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
...
...
@@ -394,13 +394,13 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
// note that the remove operation can be executed only once.
if
(
ret
==
0
)
{
if
(
p
!=
pNode
)
{
u
Debug
(
"cache:%s, key:%p, successfully removed a new entry:%p, refcnt:%d, prev entry:%p has been removed by "
u
Error
(
"cache:%s, key:%p, successfully removed a new entry:%p, refcnt:%d, prev entry:%p has been removed by "
"others already"
,
pCacheObj
->
name
,
pNode
->
key
,
p
->
data
,
T_REF_VAL_GET
(
p
),
pNode
->
data
);
assert
(
p
->
pTNodeHeader
==
NULL
);
taosAddToTrash
(
pCacheObj
,
p
);
}
else
{
u
Debug
(
"cache:%s, key:%p, %p successfully removed from hash table, refcnt:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
u
Error
(
"cache:%s, key:%p, %p successfully removed from hash table, refcnt:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
ref
);
if
(
ref
>
0
)
{
assert
(
pNode
->
pTNodeHeader
==
NULL
);
...
...
@@ -410,7 +410,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
atomic_sub_fetch_64
(
&
pCacheObj
->
totalSize
,
pNode
->
size
);
int32_t
size
=
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
);
u
Debug
(
"cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, num:%d size:%"
PRId64
"bytes"
,
u
Error
(
"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
,
pCacheObj
->
totalSize
);
if
(
pCacheObj
->
freeFp
)
{
...
...
@@ -421,7 +421,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
}
}
}
else
{
u
Debug
(
"cache:%s, key:%p, %p has been removed from hash table by other thread already, refcnt:%d"
,
u
Error
(
"cache:%s, key:%p, %p has been removed from hash table by other thread already, refcnt:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
ref
);
}
}
...
...
@@ -432,7 +432,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
char
*
p
=
pNode
->
data
;
int32_t
ref
=
T_REF_DEC
(
pNode
);
u
Debug
(
"cache:%s, key:%p, %p released, refcnt:%d, data in tran
can:%d"
,
pCacheObj
->
name
,
key
,
p
,
ref
,
inTrashCan
);
u
Error
(
"cache:%s, key:%p, %p released, refcnt:%d, data in trash
can:%d"
,
pCacheObj
->
name
,
key
,
p
,
ref
,
inTrashCan
);
}
}
...
...
@@ -524,7 +524,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
pCacheObj
->
numOfElemsInTrash
++
;
__cache_unlock
(
pCacheObj
);
u
Debug
(
"cache:%s key:%p, %p move to trash, numOfElem in trash:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
u
Error
(
"cache:%s key:%p, %p move to trash, numOfElem in trash:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
pCacheObj
->
numOfElemsInTrash
);
}
...
...
@@ -550,7 +550,7 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
}
if
(
force
||
(
T_REF_VAL_GET
(
pElem
->
pData
)
==
0
))
{
u
Debug
(
"key:%p, %p removed from trash. numOfElem in trash:%d"
,
pElem
->
pData
->
key
,
pElem
->
pData
->
data
,
u
Error
(
"key:%p, %p removed from trash. numOfElem in trash:%d"
,
pElem
->
pData
->
key
,
pElem
->
pData
->
data
,
pCacheObj
->
numOfElemsInTrash
-
1
);
STrashElem
*
p
=
pElem
;
...
...
@@ -611,7 +611,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
void
*
taosCacheTimedRefresh
(
void
*
handle
)
{
SCacheObj
*
pCacheObj
=
handle
;
if
(
pCacheObj
==
NULL
)
{
u
Debug
(
"object is destroyed. no refresh retry"
);
u
Error
(
"object is destroyed. no refresh retry"
);
return
NULL
;
}
...
...
@@ -624,7 +624,7 @@ void* taosCacheTimedRefresh(void *handle) {
// check if current cache object will be deleted every 500ms.
if
(
pCacheObj
->
deleting
)
{
u
Debug
(
"%s refresh threads quit"
,
pCacheObj
->
name
);
u
Error
(
"%s refresh threads quit"
,
pCacheObj
->
name
);
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录