Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
321f7b27
T
TDengine
项目概览
慢慢CG
/
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看板
提交
321f7b27
编写于
8月 05, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bug in hash
上级
175dfb56
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
103 deletion
+8
-103
src/util/src/hash.c
src/util/src/hash.c
+1
-12
src/util/src/tcache.c
src/util/src/tcache.c
+1
-85
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+6
-6
未找到文件。
src/util/src/hash.c
浏览文件 @
321f7b27
...
@@ -329,17 +329,6 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
...
@@ -329,17 +329,6 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
return
taosHashRemoveWithData
(
pHashObj
,
key
,
keyLen
,
NULL
,
0
);
return
taosHashRemoveWithData
(
pHashObj
,
key
,
keyLen
,
NULL
,
0
);
}
}
static
FORCE_INLINE
void
doPopNextFromEntryList
(
SHashEntry
*
pe
,
SHashNode
*
pNode
)
{
SHashNode
*
pNext
=
pNode
->
next
;
if
(
pNext
!=
NULL
)
{
pNode
->
next
=
pNext
->
next
;
}
else
{
pNode
->
next
=
NULL
;
}
pe
->
num
-=
1
;
}
int32_t
taosHashRemoveWithData
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
dsize
)
{
int32_t
taosHashRemoveWithData
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
dsize
)
{
if
(
pHashObj
==
NULL
||
pHashObj
->
size
<=
0
)
{
if
(
pHashObj
==
NULL
||
pHashObj
->
size
<=
0
)
{
return
-
1
;
return
-
1
;
...
@@ -457,7 +446,7 @@ int32_t taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), voi
...
@@ -457,7 +446,7 @@ int32_t taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), voi
taosWLockLatch
(
&
pEntry
->
latch
);
taosWLockLatch
(
&
pEntry
->
latch
);
}
}
// todo remove first node
// todo remove
the
first node
SHashNode
*
pNode
=
NULL
;
SHashNode
*
pNode
=
NULL
;
while
((
pNode
=
pEntry
->
next
)
!=
NULL
)
{
while
((
pNode
=
pEntry
->
next
)
!=
NULL
)
{
if
(
fp
&&
(
!
fp
(
param
,
pNode
->
data
)))
{
if
(
fp
&&
(
!
fp
(
param
,
pNode
->
data
)))
{
...
...
src/util/src/tcache.c
浏览文件 @
321f7b27
...
@@ -116,16 +116,6 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
...
@@ -116,16 +116,6 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
free
(
pNode
);
free
(
pNode
);
}
}
/**
* move the old node into trash
* @param pCacheObj
* @param pNode
*/
static
FORCE_INLINE
void
taosCacheMoveToTrash
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
)
{
taosHashRemove
(
pCacheObj
->
pHashTable
,
pNode
->
key
,
pNode
->
keySize
);
taosAddToTrash
(
pCacheObj
,
pNode
);
}
static
FORCE_INLINE
void
doRemoveElemInTrashcan
(
SCacheObj
*
pCacheObj
,
STrashElem
*
pElem
)
{
static
FORCE_INLINE
void
doRemoveElemInTrashcan
(
SCacheObj
*
pCacheObj
,
STrashElem
*
pElem
)
{
if
(
pElem
->
pData
->
signature
!=
(
uint64_t
)
pElem
->
pData
)
{
if
(
pElem
->
pData
->
signature
!=
(
uint64_t
)
pElem
->
pData
)
{
uError
(
"key:sig:0x%"
PRIx64
" %p data has been released, ignore"
,
pElem
->
pData
->
signature
,
pElem
->
pData
);
uError
(
"key:sig:0x%"
PRIx64
" %p data has been released, ignore"
,
pElem
->
pData
->
signature
,
pElem
->
pData
);
...
@@ -152,52 +142,6 @@ static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem
...
@@ -152,52 +142,6 @@ static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem
free
(
pElem
->
pData
);
free
(
pElem
->
pData
);
free
(
pElem
);
free
(
pElem
);
}
}
/**
* update data in cache
* @param pCacheObj
* @param pNode
* @param key
* @param keyLen
* @param pData
* @param dataSize
* @return
*/
static
UNUSED_FUNC
SCacheDataNode
*
taosUpdateCacheImpl
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
,
SCacheDataNode
*
pNewNode
,
const
char
*
key
,
int32_t
keyLen
)
{
// only a node is not referenced by any other object, in-place update it
if
(
T_REF_VAL_GET
(
pNode
)
>
0
)
{
taosCacheMoveToTrash
(
pCacheObj
,
pNode
);
}
T_REF_INC
(
pNewNode
);
// addedTime new element to hashtable
taosHashPut
(
pCacheObj
->
pHashTable
,
key
,
keyLen
,
&
pNewNode
,
sizeof
(
void
*
));
return
pNewNode
;
}
/**
* addedTime data into hash table
* @param key
* @param pData
* @param size
* @param pCacheObj
* @param keyLen
* @param pNode
* @return
*/
static
FORCE_INLINE
SCacheDataNode
*
taosAddToCacheImpl
(
SCacheObj
*
pCacheObj
,
const
char
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dataSize
,
uint64_t
duration
)
{
SCacheDataNode
*
pNode
=
taosCreateCacheNode
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
if
(
pNode
==
NULL
)
{
return
NULL
;
}
T_REF_INC
(
pNode
);
taosHashPut
(
pCacheObj
->
pHashTable
,
key
,
keyLen
,
&
pNode
,
sizeof
(
void
*
));
return
pNode
;
}
/**
/**
* do cleanup the taos cache
* do cleanup the taos cache
...
@@ -318,8 +262,8 @@ static void incRefFn(void* ptNode) {
...
@@ -318,8 +262,8 @@ static void incRefFn(void* ptNode) {
assert
(
ptNode
!=
NULL
);
assert
(
ptNode
!=
NULL
);
SCacheDataNode
**
p
=
(
SCacheDataNode
**
)
ptNode
;
SCacheDataNode
**
p
=
(
SCacheDataNode
**
)
ptNode
;
assert
(
T_REF_VAL_GET
(
*
p
)
>=
0
);
assert
(
T_REF_VAL_GET
(
*
p
)
>=
0
);
int32_t
ret
=
T_REF_INC
(
*
p
);
int32_t
ret
=
T_REF_INC
(
*
p
);
assert
(
ret
>
0
);
assert
(
ret
>
0
);
}
}
...
@@ -344,34 +288,6 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
...
@@ -344,34 +288,6 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
return
pData
;
return
pData
;
}
}
//void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime) {
// if (pCacheObj == NULL || taosHashGetSize(pCacheObj->pHashTable) == 0) {
// return NULL;
// }
//
// __cache_rd_lock(pCacheObj);
//
// SCacheDataNode **ptNode = (SCacheDataNode **)taosHashGet(pCacheObj->pHashTable, key, keyLen);
// if (ptNode != NULL) {
// T_REF_INC(*ptNode);
// (*ptNode)->expireTime = expireTime; // taosGetTimestampMs() + (*ptNode)->lifespan;
// }
//
// __cache_unlock(pCacheObj);
//
// if (ptNode != NULL) {
// atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1);
// uDebug("cache:%s, key:%p, %p expireTime is updated in cache, refcnt:%d", pCacheObj->name, key,
// (*ptNode)->data, T_REF_VAL_GET(*ptNode));
// } else {
// atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1);
// uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key);
// }
//
// atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1);
// return (ptNode != NULL) ? (*ptNode)->data : NULL;
//}
void
*
taosCacheAcquireByData
(
SCacheObj
*
pCacheObj
,
void
*
data
)
{
void
*
taosCacheAcquireByData
(
SCacheObj
*
pCacheObj
,
void
*
data
)
{
if
(
pCacheObj
==
NULL
||
data
==
NULL
)
return
NULL
;
if
(
pCacheObj
==
NULL
||
data
==
NULL
)
return
NULL
;
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
321f7b27
...
@@ -259,20 +259,20 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
...
@@ -259,20 +259,20 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
//TODO handle malloc failure
//TODO handle malloc failure
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
memset
(
pRet
->
rsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
memset
(
pRet
->
rsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
)
;
freeHandle
=
true
;
}
else
{
// result is not ready, return immediately
}
else
{
// result is not ready, return immediately
if
(
!
buildRes
)
{
if
(
!
buildRes
)
{
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
return
TSDB_CODE_QRY_NOT_READY
;
return
TSDB_CODE_QRY_NOT_READY
;
}
}
void
**
dup
=
handle
;
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
handle
,
&
freeHandle
);
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
handle
,
&
freeHandle
);
}
// not added into task queue, the query must be completed already, free qhandle immediately
// if qhandle is not added into task queue, the query must be completed already or paused with error ,
if
(
freeHandle
)
{
// free qhandle immediately
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
dup
,
true
);
if
(
freeHandle
)
{
}
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
}
}
return
code
;
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录