Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
471d853f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
471d853f
编写于
3月 29, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-238-D]<fix>(tsdb): single table del function ok
上级
4755a907
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
11 deletion
+28
-11
src/tsdb/src/tsdbTruncate.c
src/tsdb/src/tsdbTruncate.c
+28
-11
未找到文件。
src/tsdb/src/tsdbTruncate.c
浏览文件 @
471d853f
...
...
@@ -245,6 +245,7 @@ static int tsdbTruncateTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
static
int
tsdbFSetDelete
(
STruncateH
*
ptru
,
SDFileSet
*
pSet
)
{
STsdbRepo
*
pRepo
=
TSDB_TRUNCATE_REPO
(
ptru
);
SDiskID
did
=
{
0
};
SDFileSet
*
pWSet
=
TSDB_TRUNCATE_WSET
(
ptru
);
tsdbDebug
(
"vgId:%d start to truncate data in FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
TSDB_FSET_LEVEL
(
pSet
),
TSDB_FSET_ID
(
pSet
));
...
...
@@ -253,21 +254,32 @@ static int tsdbFSetDelete(STruncateH *ptru, SDFileSet *pSet) {
return
-
1
;
}
// Create new fset as
dele
ted fset
// Create new fset as
trunca
ted fset
tfsAllocDisk
(
tsdbGetFidLevel
(
pSet
->
fid
,
&
(
ptru
->
rtn
)),
&
(
did
.
level
),
&
(
did
.
id
));
if
(
did
.
level
==
TFS_UNDECIDED_LEVEL
)
{
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
tsdbError
(
"vgId:%d failed to truncate
data
in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to truncate
table
in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbTruncateFSetEnd
(
ptru
);
return
-
1
;
}
tsdbInitDFileSet
(
TSDB_TRUNCATE_WSET
(
ptru
),
did
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pSet
),
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_LATEST_FSET_VER
);
// Only .head is created, use original .data/.last/.smad/.smal
tsdbInitDFileSetEx
(
pWSet
,
pSet
);
pWSet
->
state
=
0
;
SDFile
*
pHeadFile
=
TSDB_DFILE_IN_SET
(
pWSet
,
TSDB_FILE_HEAD
);
tsdbInitDFile
(
pHeadFile
,
did
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pSet
),
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_HEAD
);
if
(
tsdbCreateDFileSet
(
TSDB_TRUNCATE_WSET
(
ptru
),
true
)
<
0
)
{
tsdbError
(
"vgId:%d failed to truncate data in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbTruncateFSetEnd
(
ptru
);
if
(
tsdbCreateDFile
(
pHeadFile
,
true
,
TSDB_FILE_HEAD
)
<
0
)
{
tsdbError
(
"vgId:%d failed to truncate table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbCloseDFile
(
pHeadFile
);
tsdbRemoveDFile
(
pHeadFile
);
return
-
1
;
}
tsdbCloseDFile
(
pHeadFile
);
if
(
tsdbOpenDFileSet
(
pWSet
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file set %d since %s"
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pWSet
),
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -628,7 +640,7 @@ int tsdbRemoveDelBlocks(STruncateH *ptru, STableTruncateH * pItem) {
}
if
(
from
!=
-
1
)
{
int
delCnt
=
from
;
int
delCnt
=
from
+
1
;
memmove
(
pItem
->
pInfo
->
blocks
,
pItem
->
pInfo
->
blocks
+
delCnt
,
(
numOfBlocks
-
delCnt
)
*
sizeof
(
SBlock
));
delAll
+=
delCnt
;
numOfBlocks
-=
delCnt
;
...
...
@@ -641,14 +653,19 @@ int tsdbRemoveDelBlocks(STruncateH *ptru, STableTruncateH * pItem) {
}
static
void
tsdbAddBlock
(
STruncateH
*
ptru
,
STableTruncateH
*
pItem
,
SBlock
*
pBlock
)
{
taosArrayPush
(
ptru
->
aSupBlk
,
(
const
void
*
)
pBlock
);
// have sub block
// append sub if have
if
(
pBlock
->
numOfSubBlocks
>
1
)
{
int64_t
offset
=
taosArrayGetSize
(
ptru
->
aSubBlk
)
*
sizeof
(
SBlock
);
SBlock
*
jBlock
=
POINTER_SHIFT
(
pItem
->
pInfo
,
pBlock
->
offset
);;
for
(
int
j
=
0
;
j
<
pBlock
->
numOfSubBlocks
;
j
++
)
{
taosArrayPush
(
ptru
->
aSubBlk
,
(
const
void
*
)
jBlock
++
);
}
// set new offset if have sub
pBlock
->
offset
=
offset
;
}
// append super
taosArrayPush
(
ptru
->
aSupBlk
,
(
const
void
*
)
pBlock
);
}
// need modify blocks
...
...
@@ -690,7 +707,7 @@ static int tsdbModifyBlocks(STruncateH *ptru, STableTruncateH *pItem) {
if
(
solve
==
BLOCK_READ
)
{
tsdbAddBlock
(
ptru
,
pItem
,
pBlock
);
continue
;
}
}
// border block need load to delete no-use data
if
(
tsdbLoadBlockData
(
pReadh
,
pBlock
,
pItem
->
pInfo
)
<
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录