Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
0a0852ad
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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,发现更多精彩内容 >>
提交
0a0852ad
编写于
10月 30, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug #660
上级
d4bcce0d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
26 deletion
+55
-26
src/os/linux/inc/os.h
src/os/linux/inc/os.h
+5
-0
src/system/src/vnodeQueryImpl.c
src/system/src/vnodeQueryImpl.c
+5
-5
src/system/src/vnodeQueryProcess.c
src/system/src/vnodeQueryProcess.c
+44
-20
src/util/src/tcache.c
src/util/src/tcache.c
+1
-1
未找到文件。
src/os/linux/inc/os.h
浏览文件 @
0a0852ad
...
...
@@ -60,8 +60,13 @@
#define __sync_val_compare_and_swap_64 __sync_val_compare_and_swap
#define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap
#define __sync_add_and_fetch_64 __sync_add_and_fetch
#define __sync_add_and_fetch_32 __sync_add_and_fetch
#define __sync_sub_and_fetch_64 __sync_sub_and_fetch
#define __sync_sub_and_fetch_32 __sync_sub_and_fetch
int32_t
__sync_val_load_32
(
int32_t
*
ptr
);
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
);
...
...
src/system/src/vnodeQueryImpl.c
浏览文件 @
0a0852ad
...
...
@@ -810,14 +810,14 @@ SCacheBlock *getCacheDataBlock(SMeterObj *pMeterObj, SQuery *pQuery, int32_t slo
SCacheBlock
*
pBlock
=
pCacheInfo
->
cacheBlocks
[
slot
];
if
(
pBlock
==
NULL
)
{
dError
(
"QInfo:%p NULL Block In Cache, available block:%d, last block:%d, accessed null block:%d, pBlockId:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pCacheInfo
->
numOfBlocks
,
pCacheInfo
->
currentSlot
,
slot
,
pQuery
->
blockId
);
GET_QINFO_ADDR
(
pQuery
),
pCacheInfo
->
numOfBlocks
,
pCacheInfo
->
currentSlot
,
slot
,
pQuery
->
blockId
);
return
NULL
;
}
if
(
pMeterObj
!=
pBlock
->
pMeterObj
||
pBlock
->
blockId
>
pQuery
->
blockId
||
pBlock
->
numOfPoints
<=
0
)
{
dWarn
(
"QInfo:%p vid:%d sid:%d id:%s, cache block is overwritten, slot:%d blockId:%d qBlockId:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pMeterObj
->
vnode
,
pMeterObj
->
sid
,
pMeterObj
->
meterId
,
pQuery
->
slot
,
pBlock
->
blockId
,
pQuery
->
blockId
);
if
(
pMeterObj
!=
pBlock
->
pMeterObj
||
pBlock
->
blockId
>
pQuery
->
blockId
)
{
dWarn
(
"QInfo:%p vid:%d sid:%d id:%s, cache block is overwritten, slot:%d blockId:%d qBlockId:%d
, meterObj:%p, blockMeterObj:%p
"
,
GET_QINFO_ADDR
(
pQuery
),
pMeterObj
->
vnode
,
pMeterObj
->
sid
,
pMeterObj
->
meterId
,
pQuery
->
slot
,
pBlock
->
blockId
,
pQuery
->
blockId
,
pMeterObj
,
pBlock
->
pMeterObj
);
return
NULL
;
}
...
...
src/system/src/vnodeQueryProcess.c
浏览文件 @
0a0852ad
...
...
@@ -27,6 +27,12 @@
#include "vnodeQueryImpl.h"
#define ALL_CACHE_BLOCKS_CHECKED(q) \
((q)->slot == (q)->currentSlot && QUERY_IS_ASC_QUERY(q) || (q)->slot == (q)->firstSlot && (!QUERY_IS_ASC_QUERY(q)))
#define FORWARD_CACHE_BLOCK_CHECK_SLOT(slot, step, maxblocks) (slot) = ((slot) + (step) + (maxblocks)) % (maxblocks);
static
bool
doCheckWithPrevQueryRange
(
SQInfo
*
pQInfo
,
TSKEY
nextKey
,
SMeterDataInfo
*
pMeterInfo
)
{
SMeterQuerySupportObj
*
pSupporter
=
pQInfo
->
pMeterQuerySupporter
;
SQuery
*
pQuery
=
&
pQInfo
->
query
;
...
...
@@ -49,6 +55,22 @@ static bool doCheckWithPrevQueryRange(SQInfo *pQInfo, TSKEY nextKey, SMeterDataI
return
true
;
}
/**
* The start position of the first check cache block is located before starting the loop.
* And the start position for next cache blocks needs to be decided before checking each cache block.
*/
static
void
setStartPositionForCacheBlock
(
SQuery
*
pQuery
,
SCacheBlock
*
pBlock
,
bool
*
firstCheckSlot
)
{
if
(
!
(
*
firstCheckSlot
))
{
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
pQuery
->
pos
=
0
;
}
else
{
pQuery
->
pos
=
pBlock
->
numOfPoints
-
1
;
}
}
else
{
(
*
firstCheckSlot
)
=
false
;
}
}
static
SMeterDataInfo
*
queryOnMultiDataCache
(
SQInfo
*
pQInfo
,
SMeterDataInfo
*
pMeterInfo
)
{
SQuery
*
pQuery
=
&
pQInfo
->
query
;
SMeterQuerySupportObj
*
pSupporter
=
pQInfo
->
pMeterQuerySupporter
;
...
...
@@ -147,24 +169,39 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
continue
;
}
bool
firstCheckSlot
=
true
;
SCacheInfo
*
pCacheInfo
=
(
SCacheInfo
*
)
pMeterObj
->
pCache
;
for
(
int32_t
i
=
0
;
i
<
pCacheInfo
->
maxBlocks
;
++
i
)
{
pBlock
=
getCacheDataBlock
(
pMeterObj
,
pQuery
,
pQuery
->
slot
);
// cache block may be flushed to disk, so it is not available, ignore it and try next
if
(
pBlock
==
NULL
)
{
pQuery
->
slot
=
(
pQuery
->
slot
+
step
+
pCacheInfo
->
maxBlocks
)
%
pCacheInfo
->
maxBlocks
;
/*
* 1. pBlock == NULL. The cache block may be flushed to disk, so it is not available, skip and try next
*
* 2. pBlock->numOfPoints == 0. There is a empty block, which is caused by allocate-and-write data into cache
* procedure. The block has been allocated but data has not been put into yet. If the block is the last
* block(newly allocated block), abort query. Otherwise, skip it and go on.
*/
if
((
pBlock
==
NULL
)
||
(
pBlock
->
numOfPoints
==
0
))
{
if
(
ALL_CACHE_BLOCKS_CHECKED
(
pQuery
))
{
break
;
}
FORWARD_CACHE_BLOCK_CHECK_SLOT
(
pQuery
->
slot
,
step
,
pCacheInfo
->
maxBlocks
);
continue
;
}
setStartPositionForCacheBlock
(
pQuery
,
pBlock
,
&
firstCheckSlot
);
TSKEY
*
primaryKeys
=
(
TSKEY
*
)
pBlock
->
offset
[
0
];
// in handling file data block, this query condition is checked during fetching candidate file blocks
// in handling file data block, the timestamp range validation is done during fetching candidate file blocks
if
((
primaryKeys
[
pQuery
->
pos
]
>
pSupporter
->
rawEKey
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
primaryKeys
[
pQuery
->
pos
]
<
pSupporter
->
rawEKey
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
break
;
}
/
* only record the key on last block */
/
/ only record the key on last block
SET_CACHE_BLOCK_FLAG
(
pRuntimeEnv
->
blockStatus
);
SBlockInfo
binfo
=
getBlockBasicInfo
(
pBlock
,
BLK_CACHE_BLOCK
);
...
...
@@ -176,24 +213,11 @@ static SMeterDataInfo *queryOnMultiDataCache(SQInfo *pQInfo, SMeterDataInfo *pMe
queryOnBlock
(
pSupporter
,
primaryKeys
,
pRuntimeEnv
->
blockStatus
,
(
char
*
)
pBlock
,
&
binfo
,
&
pMeterInfo
[
k
],
NULL
,
searchFn
);
// todo refactor
if
((
pQuery
->
slot
==
pQuery
->
currentSlot
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
pQuery
->
slot
==
pQuery
->
firstSlot
&&
!
QUERY_IS_ASC_QUERY
(
pQuery
)))
{
if
(
ALL_CACHE_BLOCKS_CHECKED
(
pQuery
))
{
break
;
}
// try next cache block
pQuery
->
slot
=
(
pQuery
->
slot
+
step
+
pCacheInfo
->
maxBlocks
)
%
pCacheInfo
->
maxBlocks
;
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
pQuery
->
pos
=
0
;
}
else
{
// backwards traverse encounter the cache invalid, abort scan cache.
SCacheBlock
*
pNextBlock
=
getCacheDataBlock
(
pMeterObj
,
pQuery
,
pQuery
->
slot
);
if
(
pNextBlock
==
NULL
)
{
break
;
// todo fix
}
else
{
pQuery
->
pos
=
pNextBlock
->
numOfPoints
-
1
;
}
}
FORWARD_CACHE_BLOCK_CHECK_SLOT
(
pQuery
->
slot
,
step
,
pCacheInfo
->
maxBlocks
);
}
}
}
...
...
src/util/src/tcache.c
浏览文件 @
0a0852ad
...
...
@@ -614,7 +614,7 @@ static FORCE_INLINE void taosDecRef(SDataNode *pNode) {
}
if
(
pNode
->
refCount
>
0
)
{
__sync_
add_and_fetch_32
(
&
pNode
->
refCount
,
-
1
);
__sync_
sub_and_fetch_32
(
&
pNode
->
refCount
,
1
);
pTrace
(
"key:%s is released by app.refcnt:%d"
,
pNode
->
key
,
pNode
->
refCount
);
}
else
{
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录