Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3327beba
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3327beba
编写于
3月 01, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): record the correct last accessed key in the stt file.
上级
22e52ebb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
20 deletion
+25
-20
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+24
-19
未找到文件。
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
3327beba
...
...
@@ -404,7 +404,7 @@ void tLDataIterNextBlock(SLDataIter *pIter, const char *idStr) {
tsdbDebug
(
"try next last file block:%d from %d, trigger by uid:%"
PRIu64
", file index:%d, %s"
,
pIter
->
iSttBlk
,
oldIndex
,
pIter
->
uid
,
pIter
->
iStt
,
idStr
);
}
else
{
tsdbDebug
(
"no more last block qualified, uid:%"
PRIu64
", file index:
:
%d, %s"
,
pIter
->
uid
,
oldIndex
,
idStr
);
tsdbDebug
(
"no more last block qualified, uid:%"
PRIu64
", file index:%d, %s"
,
pIter
->
uid
,
oldIndex
,
idStr
);
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
3327beba
...
...
@@ -44,6 +44,7 @@ typedef struct SBlockIndex {
typedef
struct
STableBlockScanInfo
{
uint64_t
uid
;
TSKEY
lastKey
;
TSKEY
lastKeyInStt
;
// last accessed key in stt
SMapData
mapData
;
// block info (compressed)
SArray
*
pBlockList
;
// block data index list, SArray<SBlockIndex>
SIterInfo
iter
;
// mem buffer skip list iterator
...
...
@@ -192,7 +193,7 @@ static TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbRe
static
int32_t
doMergeRowsInFileBlocks
(
SBlockData
*
pBlockData
,
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
,
SRowMerger
*
pMerger
);
static
int32_t
doMergeRowsInLastBlock
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
int64_t
ts
,
SRowMerger
*
pMerger
,
SVersionRange
*
pVerRange
);
SRowMerger
*
pMerger
,
SVersionRange
*
pVerRange
,
const
char
*
id
);
static
int32_t
doMergeRowsInBuf
(
SIterInfo
*
pIter
,
uint64_t
uid
,
int64_t
ts
,
SArray
*
pDelList
,
SRowMerger
*
pMerger
,
STsdbReader
*
pReader
);
static
int32_t
doAppendRowFromTSRow
(
SSDataBlock
*
pBlock
,
STsdbReader
*
pReader
,
SRow
*
pTSRow
,
...
...
@@ -407,6 +408,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf
pScanInfo
->
lastKey
=
(
ekey
<
INT64_MAX
)
?
(
ekey
+
1
)
:
ekey
;
}
pScanInfo
->
lastKeyInStt
=
pScanInfo
->
lastKey
;
taosHashPut
(
pTableMap
,
&
pScanInfo
->
uid
,
sizeof
(
uint64_t
),
&
pScanInfo
,
POINTER_BYTES
);
tsdbTrace
(
"%p check table uid:%"
PRId64
" from lastKey:%"
PRId64
" %s"
,
pTsdbReader
,
pScanInfo
->
uid
,
pScanInfo
->
lastKey
,
pTsdbReader
->
idStr
);
...
...
@@ -1795,21 +1797,21 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
while
(
1
)
{
bool
hasVal
=
tMergeTreeNext
(
&
pLastBlockReader
->
mergeTree
);
if
(
!
hasVal
)
{
if
(
!
hasVal
)
{
// the next value will be the accessed key in stt
pScanInfo
->
lastKeyInStt
+=
step
;
return
false
;
}
TSDBROW
row
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
TSDBKEY
k
=
TSDBROW_KEY
(
&
row
);
if
(
hasBeenDropped
(
pScanInfo
->
delSkyline
,
&
pScanInfo
->
lastBlockDelIndex
,
&
k
,
pLastBlockReader
->
order
,
pVerRange
))
{
pScanInfo
->
lastKey
=
k
.
ts
;
}
else
{
pScanInfo
->
lastKeyInStt
=
k
.
ts
;
if
(
!
hasBeenDropped
(
pScanInfo
->
delSkyline
,
&
pScanInfo
->
lastBlockDelIndex
,
&
k
,
pLastBlockReader
->
order
,
pVerRange
))
{
// the qualifed ts may equal to k.ts, only a greater version one.
// here we need to fallback one step.
if
(
pScanInfo
->
lastKey
==
k
.
ts
)
{
pScanInfo
->
lastKey
-=
step
;
}
// if (pScanInfo->lastKey == k.ts) {
// pScanInfo->lastKey -= step;
// }
return
true
;
}
}
...
...
@@ -1949,7 +1951,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
return
code
;
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
}
if
(
minKey
==
k
.
ts
)
{
...
...
@@ -1997,7 +1999,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
return
code
;
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
}
if
(
minKey
==
key
)
{
...
...
@@ -2050,7 +2052,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
&
merge
,
&
fRow1
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
code
=
tsdbRowMergerGetRow
(
&
merge
,
&
pTSRow
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2068,7 +2070,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
return
code
;
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
// merge with block data if ts == key
if
(
tsLastBlock
==
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
])
{
...
...
@@ -2121,7 +2123,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
&
merge
,
&
fRow1
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
ts
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
code
=
tsdbRowMergerGetRow
(
&
merge
,
&
pTSRow
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2230,7 +2232,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
}
if
(
minKey
==
ik
.
ts
)
{
...
...
@@ -2321,7 +2323,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
return
code
;
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLast
,
&
merge
,
&
pReader
->
verRange
,
pReader
->
idStr
);
}
if
(
minKey
==
key
)
{
...
...
@@ -2472,9 +2474,9 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
int32_t
step
=
ASCENDING_TRAVERSE
(
pLBlockReader
->
order
)
?
1
:
-
1
;
STimeWindow
w
=
pLBlockReader
->
window
;
if
(
ASCENDING_TRAVERSE
(
pLBlockReader
->
order
))
{
w
.
skey
=
pScanInfo
->
lastKey
+
step
;
w
.
skey
=
pScanInfo
->
lastKey
InStt
;
}
else
{
w
.
ekey
=
pScanInfo
->
lastKey
+
step
;
w
.
ekey
=
pScanInfo
->
lastKey
InStt
;
}
tsdbDebug
(
"init last block reader, window:%"
PRId64
"-%"
PRId64
", uid:%"
PRIu64
", %s"
,
w
.
skey
,
w
.
ekey
,
...
...
@@ -3567,13 +3569,16 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
}
int32_t
doMergeRowsInLastBlock
(
SLastBlockReader
*
pLastBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
int64_t
ts
,
SRowMerger
*
pMerger
,
SVersionRange
*
pVerRange
)
{
SRowMerger
*
pMerger
,
SVersionRange
*
pVerRange
,
const
char
*
idStr
)
{
while
(
nextRowFromLastBlocks
(
pLastBlockReader
,
pScanInfo
,
pVerRange
))
{
int64_t
next1
=
getCurrentKeyInLastBlock
(
pLastBlockReader
);
if
(
next1
==
ts
)
{
TSDBROW
fRow1
=
tMergeTreeGetRow
(
&
pLastBlockReader
->
mergeTree
);
tsdbRowMerge
(
pMerger
,
&
fRow1
);
}
else
{
tsdbTrace
(
"uid:%"
PRIu64
" last del index:%d, del range:%d, lastKeyInStt:%"
PRId64
", %s"
,
pScanInfo
->
uid
,
pScanInfo
->
lastBlockDelIndex
,
(
int32_t
)
taosArrayGetSize
(
pScanInfo
->
delSkyline
),
pScanInfo
->
lastKeyInStt
,
idStr
);
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录