Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf02ac72
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cf02ac72
编写于
6月 21, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(tsdb): extract tomb data in stt files.
上级
f49f9604
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
140 addition
and
48 deletion
+140
-48
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+82
-41
source/dnode/vnode/src/tsdb/tsdbRead2.c
source/dnode/vnode/src/tsdb/tsdbRead2.c
+56
-6
tests/system-test/1-insert/delete_stable.py
tests/system-test/1-insert/delete_stable.py
+1
-1
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
cf02ac72
...
@@ -706,6 +706,7 @@ typedef struct SSttBlockLoadInfo {
...
@@ -706,6 +706,7 @@ typedef struct SSttBlockLoadInfo {
void
*
pBlockArray
;
void
*
pBlockArray
;
SArray
*
aSttBlk
;
SArray
*
aSttBlk
;
SArray
*
pTombBlockArray
;
// tomb block array list
int32_t
blockIndex
[
2
];
// to denote the loaded block in the corresponding position.
int32_t
blockIndex
[
2
];
// to denote the loaded block in the corresponding position.
int32_t
currentLoadBlockIndex
;
int32_t
currentLoadBlockIndex
;
int32_t
loadBlocks
;
int32_t
loadBlocks
;
...
...
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
cf02ac72
...
@@ -269,6 +269,83 @@ int32_t tLDataIterOpen(struct SLDataIter *pIter, SDataFReader *pReader, int32_t
...
@@ -269,6 +269,83 @@ int32_t tLDataIterOpen(struct SLDataIter *pIter, SDataFReader *pReader, int32_t
return
0
;
return
0
;
}
}
static
int32_t
loadSttBlockInfo
(
SLDataIter
*
pIter
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
uint64_t
suid
)
{
TSttBlkArray
*
pArray
=
pBlockLoadInfo
->
pBlockArray
;
if
(
TARRAY2_SIZE
(
pArray
)
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
SSttBlk
*
pStart
=
&
pArray
->
data
[
0
];
SSttBlk
*
pEnd
=
&
pArray
->
data
[
TARRAY2_SIZE
(
pArray
)
-
1
];
// all identical
if
(
pStart
->
suid
==
pEnd
->
suid
)
{
if
(
pStart
->
suid
!=
suid
)
{
// no qualified stt block existed
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
pIter
->
iSttBlk
=
-
1
;
return
TSDB_CODE_SUCCESS
;
}
else
{
// all blocks are qualified
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
taosArrayAddBatch
(
pBlockLoadInfo
->
aSttBlk
,
pArray
->
data
,
pArray
->
size
);
}
}
else
{
SArray
*
pTmp
=
taosArrayInit
(
TARRAY2_SIZE
(
pArray
),
sizeof
(
SSttBlk
));
for
(
int32_t
i
=
0
;
i
<
TARRAY2_SIZE
(
pArray
);
++
i
)
{
SSttBlk
*
p
=
&
pArray
->
data
[
i
];
if
(
p
->
suid
<
suid
)
{
continue
;
}
if
(
p
->
suid
==
suid
)
{
taosArrayPush
(
pTmp
,
p
);
}
else
if
(
p
->
suid
>
suid
)
{
break
;
}
}
taosArrayDestroy
(
pBlockLoadInfo
->
aSttBlk
);
pBlockLoadInfo
->
aSttBlk
=
pTmp
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
loadSttTombBlockData
(
SSttFileReader
*
pSttFileReader
,
uint64_t
suid
,
SSttBlockLoadInfo
*
pLoadInfo
)
{
if
(
pLoadInfo
->
pTombBlockArray
==
NULL
)
{
pLoadInfo
->
pTombBlockArray
=
taosArrayInit
(
4
,
POINTER_BYTES
);
}
const
TTombBlkArray
*
pBlkArray
=
NULL
;
int32_t
code
=
tsdbSttFileReadTombBlk
(
pSttFileReader
,
&
pBlkArray
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
for
(
int32_t
j
=
0
;
j
<
pBlkArray
->
size
;
++
j
)
{
STombBlk
*
pTombBlk
=
&
pBlkArray
->
data
[
j
];
if
(
pTombBlk
->
maxTbid
.
suid
<
suid
)
{
continue
;
// todo use binary search instead
}
if
(
pTombBlk
->
minTbid
.
suid
>
suid
)
{
break
;
}
STombBlock
*
pTombBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
STombBlock
));
code
=
tsdbSttFileReadTombBlock
(
pSttFileReader
,
pTombBlk
,
pTombBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle error
}
void
*
p
=
taosArrayPush
(
pLoadInfo
->
pTombBlockArray
,
&
pTombBlock
);
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
tLDataIterOpen2
(
struct
SLDataIter
*
pIter
,
SSttFileReader
*
pReader
,
int32_t
iStt
,
int8_t
backward
,
uint64_t
suid
,
int32_t
tLDataIterOpen2
(
struct
SLDataIter
*
pIter
,
SSttFileReader
*
pReader
,
int32_t
iStt
,
int8_t
backward
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
)
{
const
char
*
idStr
,
bool
strictTimeRange
)
{
...
@@ -290,51 +367,15 @@ int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pReader, int32
...
@@ -290,51 +367,15 @@ int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pReader, int32
pBlockLoadInfo
->
sttBlockLoaded
=
true
;
pBlockLoadInfo
->
sttBlockLoaded
=
true
;
code
=
tsdbSttFileReadSttBlk
(
pIter
->
pReader
,
(
const
TSttBlkArray
**
)
&
pBlockLoadInfo
->
pBlockArray
);
code
=
tsdbSttFileReadSttBlk
(
pIter
->
pReader
,
(
const
TSttBlkArray
**
)
&
pBlockLoadInfo
->
pBlockArray
);
if
(
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
// only apply to the child tables, ordinary tables will not incur this filter procedure.
code
=
loadSttBlockInfo
(
pIter
,
pBlockLoadInfo
,
suid
);
TSttBlkArray
*
pArray
=
pBlockLoadInfo
->
pBlockArray
;
size_t
size
=
pArray
->
size
;
if
(
size
>=
1
)
{
code
=
loadSttTombBlockData
(
pReader
,
suid
,
pBlockLoadInfo
);
SSttBlk
*
pStart
=
&
pArray
->
data
[
0
];
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SSttBlk
*
pEnd
=
&
pArray
->
data
[
size
-
1
];
return
code
;
// all identical
if
(
pStart
->
suid
==
pEnd
->
suid
)
{
if
(
pStart
->
suid
!=
suid
)
{
// no qualified stt block existed
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
pIter
->
iSttBlk
=
-
1
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
tsdbDebug
(
"load the last file info completed, elapsed time:%.2fms, %s"
,
el
,
idStr
);
return
code
;
}
else
{
// all blocks are qualified
taosArrayClear
(
pBlockLoadInfo
->
aSttBlk
);
taosArrayAddBatch
(
pBlockLoadInfo
->
aSttBlk
,
pArray
->
data
,
pArray
->
size
);
}
}
else
{
SArray
*
pTmp
=
taosArrayInit
(
size
,
sizeof
(
SSttBlk
));
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSttBlk
*
p
=
&
pArray
->
data
[
i
];
uint64_t
s
=
p
->
suid
;
if
(
s
<
suid
)
{
continue
;
}
if
(
s
==
suid
)
{
taosArrayPush
(
pTmp
,
p
);
}
else
if
(
s
>
suid
)
{
break
;
}
}
taosArrayDestroy
(
pBlockLoadInfo
->
aSttBlk
);
pBlockLoadInfo
->
aSttBlk
=
pTmp
;
}
}
}
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead2.c
浏览文件 @
cf02ac72
...
@@ -2766,6 +2766,51 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
...
@@ -2766,6 +2766,51 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum
return
true
;
return
true
;
}
}
static
int32_t
loadTomRecordInfoFromSttFiles
(
SSttBlockLoadInfo
*
pBlockLoadInfo
,
uint64_t
suid
,
STableBlockScanInfo
*
pBlockScanInfo
,
uint64_t
maxVer
)
{
int32_t
size
=
taosArrayGetSize
(
pBlockLoadInfo
->
pTombBlockArray
);
if
(
size
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
uint64_t
uid
=
pBlockScanInfo
->
uid
;
if
(
pBlockScanInfo
->
pDelData
==
NULL
)
{
pBlockScanInfo
->
pDelData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
}
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
STombBlock
*
pBlock
=
taosArrayGetP
(
pBlockLoadInfo
->
pTombBlockArray
,
i
);
STombRecord
record
=
{
0
};
for
(
int32_t
j
=
0
;
j
<
pBlock
->
suid
->
size
;
++
j
)
{
int32_t
code
=
tTombBlockGet
(
pBlock
,
j
,
&
record
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle error
}
if
(
record
.
suid
<
suid
)
{
continue
;
}
// todo use binary search instead here
if
(
record
.
uid
<
uid
)
{
continue
;
}
if
(
record
.
uid
>
uid
)
{
break
;
}
if
(
record
.
version
<=
maxVer
)
{
SDelData
delData
=
{.
version
=
record
.
version
,
.
sKey
=
record
.
skey
,
.
eKey
=
record
.
ekey
};
taosArrayPush
(
pBlockScanInfo
->
pDelData
,
&
delData
);
}
}
}
return
TSDB_CODE_SUCCESS
;
}
static
bool
initLastBlockReader
(
SLastBlockReader
*
pLBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
)
{
static
bool
initLastBlockReader
(
SLastBlockReader
*
pLBlockReader
,
STableBlockScanInfo
*
pScanInfo
,
STsdbReader
*
pReader
)
{
// the last block reader has been initialized for this table.
// the last block reader has been initialized for this table.
if
(
pLBlockReader
->
uid
==
pScanInfo
->
uid
)
{
if
(
pLBlockReader
->
uid
==
pScanInfo
->
uid
)
{
...
@@ -2776,7 +2821,6 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
...
@@ -2776,7 +2821,6 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
tMergeTreeClose
(
&
pLBlockReader
->
mergeTree
);
tMergeTreeClose
(
&
pLBlockReader
->
mergeTree
);
}
}
initMemDataIterator
(
pScanInfo
,
pReader
);
pLBlockReader
->
uid
=
pScanInfo
->
uid
;
pLBlockReader
->
uid
=
pScanInfo
->
uid
;
STimeWindow
w
=
pLBlockReader
->
window
;
STimeWindow
w
=
pLBlockReader
->
window
;
...
@@ -2788,14 +2832,20 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
...
@@ -2788,14 +2832,20 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
tsdbDebug
(
"init last block reader, window:%"
PRId64
"-%"
PRId64
", uid:%"
PRIu64
", %s"
,
w
.
skey
,
w
.
ekey
,
tsdbDebug
(
"init last block reader, window:%"
PRId64
"-%"
PRId64
", uid:%"
PRIu64
", %s"
,
w
.
skey
,
w
.
ekey
,
pScanInfo
->
uid
,
pReader
->
idStr
);
pScanInfo
->
uid
,
pReader
->
idStr
);
int32_t
code
=
tMergeTreeOpen2
(
&
pLBlockReader
->
mergeTree
,
(
pLBlockReader
->
order
==
TSDB_ORDER_DESC
),
int32_t
code
=
pReader
->
pTsdb
,
pReader
->
suid
,
pScanInfo
->
uid
,
&
w
,
&
pLBlockReader
->
verRange
,
tMergeTreeOpen2
(
&
pLBlockReader
->
mergeTree
,
(
pLBlockReader
->
order
==
TSDB_ORDER_DESC
),
pReader
->
pTsdb
,
pLBlockReader
->
pInfo
,
false
,
pReader
->
idStr
,
false
,
pReader
->
status
.
pLDataIter
,
pReader
->
suid
,
pScanInfo
->
uid
,
&
w
,
&
pLBlockReader
->
verRange
,
pLBlockReader
->
pInfo
,
false
,
pReader
->
status
.
pCurrentFileset
);
pReader
->
idStr
,
false
,
pReader
->
status
.
pLDataIter
,
pReader
->
status
.
pCurrentFileset
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
false
;
}
code
=
loadTomRecordInfoFromSttFiles
(
pLBlockReader
->
pInfo
,
pReader
->
suid
,
pScanInfo
,
pReader
->
verRange
.
maxVer
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
false
;
return
false
;
}
}
initMemDataIterator
(
pScanInfo
,
pReader
);
return
nextRowFromLastBlocks
(
pLBlockReader
,
pScanInfo
,
&
pReader
->
verRange
);
return
nextRowFromLastBlocks
(
pLBlockReader
,
pScanInfo
,
&
pReader
->
verRange
);
}
}
...
@@ -3212,8 +3262,8 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum, SAr
...
@@ -3212,8 +3262,8 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum, SAr
STFileObj
*
pTombFileObj
=
pReader
->
status
.
pCurrentFileset
->
farr
[
3
];
STFileObj
*
pTombFileObj
=
pReader
->
status
.
pCurrentFileset
->
farr
[
3
];
if
(
pTombFileObj
!=
NULL
)
{
if
(
pTombFileObj
!=
NULL
)
{
const
TTombBlkArray
*
pBlkArray
=
NULL
;
const
TTombBlkArray
*
pBlkArray
=
NULL
;
int32_t
code
=
tsdbDataFileReadTombBlk
(
pReader
->
pFileReader
,
&
pBlkArray
);
int32_t
code
=
tsdbDataFileReadTombBlk
(
pReader
->
pFileReader
,
&
pBlkArray
);
int32_t
i
=
0
,
j
=
0
;
int32_t
i
=
0
,
j
=
0
;
// todo find the correct start position.
// todo find the correct start position.
...
...
tests/system-test/1-insert/delete_stable.py
浏览文件 @
cf02ac72
...
@@ -27,7 +27,7 @@ class TDTestCase:
...
@@ -27,7 +27,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
()
,
True
)
self
.
dbname
=
'db_test'
self
.
dbname
=
'db_test'
self
.
ns_dbname
=
'ns_test'
self
.
ns_dbname
=
'ns_test'
self
.
us_dbname
=
'us_test'
self
.
us_dbname
=
'us_test'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录