Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4cddf201
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看板
提交
4cddf201
编写于
4月 09, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-238]<feature><tsdb>: compatible with no sma file data version
上级
69767f17
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
20 deletion
+60
-20
src/tsdb/inc/tsdbDelete.h
src/tsdb/inc/tsdbDelete.h
+1
-0
src/tsdb/src/tsdbDelete.c
src/tsdb/src/tsdbDelete.c
+59
-20
未找到文件。
src/tsdb/inc/tsdbDelete.h
浏览文件 @
4cddf201
...
...
@@ -25,6 +25,7 @@ typedef struct {
// addition info
tsem_t
*
pSem
;
bool
memNull
;
// pRepo->mem is NULL, this is true
int32_t
affectedRows
;
SShellSubmitRspMsg
*
pRsp
;
// base ControlData
...
...
src/tsdb/src/tsdbDelete.c
浏览文件 @
4cddf201
...
...
@@ -123,7 +123,7 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
if
((
REPO_FS
(
pRepo
)
->
cstatus
->
pmf
==
NULL
)
||
(
taosArrayGetSize
(
REPO_FS
(
pRepo
)
->
cstatus
->
df
)
<=
0
))
{
pRepo
->
deleteState
=
TSDB_NO_DELETE
;
tsem_post
(
&
(
pRepo
->
readyToCommit
));
tsdbInfo
(
"vgId:%d delete over, no meta or data file"
,
REPO_ID
(
pRepo
));
tsdbInfo
(
"
:SDEL
vgId:%d delete over, no meta or data file"
,
REPO_ID
(
pRepo
));
return
-
1
;
}
...
...
@@ -134,21 +134,25 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
tsdbStartDeleteTrans
(
pRepo
);
if
(
tsdbDeleteMeta
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to delete META data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"
:SDEL
vgId:%d failed to delete META data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
tsdbError
(
":SDEL vgId:%d delete meta ok"
,
REPO_ID
(
pRepo
));
if
(
tsdbDeleteTSData
(
pRepo
,
pCtlInfo
,
aUpdates
,
affectedTables
)
<
0
)
{
tsdbError
(
"vgId:%d failed to delete TS data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"
:SDEL
vgId:%d failed to delete TS data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
tsdbInfo
(
"SDEL: vgId:%d Deleted %d row(s) from %d table(s)"
,
REPO_ID
(
pRepo
),
pCtlInfo
->
affectedRows
,
pCtlInfo
->
numOfTables
);
// end transaction
tsdbEndDeleteTrans
(
pRepo
,
TSDB_CODE_SUCCESS
);
// set affected tables number
if
(
pCtlInfo
->
pRsp
)
{
pCtlInfo
->
pRsp
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
affectedTables
);
pCtlInfo
->
pRsp
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
affectedTables
);
pCtlInfo
->
pRsp
->
affectedRows
=
pCtlInfo
->
affectedRows
;
}
// update last row
...
...
@@ -167,7 +171,7 @@ _err:
static
void
tsdbStartDeleteTrans
(
STsdbRepo
*
pRepo
)
{
assert
(
pRepo
->
deleteState
!=
TSDB_IN_DELETE
);
tsdbInfo
(
"
vgId:%d start to delete
!"
,
REPO_ID
(
pRepo
));
tsdbInfo
(
"
:SDEL vgId:%d start delete transaction
!"
,
REPO_ID
(
pRepo
));
tsdbStartFSTxn
(
pRepo
,
0
,
0
);
pRepo
->
code
=
TSDB_CODE_SUCCESS
;
pRepo
->
deleteState
=
TSDB_IN_DELETE
;
...
...
@@ -180,7 +184,7 @@ static void tsdbEndDeleteTrans(STsdbRepo *pRepo, int eno) {
tsdbEndFSTxn
(
pRepo
);
}
pRepo
->
deleteState
=
TSDB_NO_DELETE
;
tsdbInfo
(
"
vgId:%d delete over
, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
tsdbInfo
(
"
:SDEL vgId:%d end delete transaction
, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
tsem_post
(
&
(
pRepo
->
readyToCommit
));
}
...
...
@@ -189,8 +193,6 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
SDeleteH
deleteH
=
{
0
};
SDFileSet
*
pSet
=
NULL
;
tsdbDebug
(
"vgId:%d start to delete TS data for %d"
,
REPO_ID
(
pRepo
),
pCtlInfo
->
tids
[
0
]);
if
(
tsdbInitDeleteH
(
&
deleteH
,
pRepo
)
<
0
)
{
return
-
1
;
}
...
...
@@ -207,13 +209,13 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
while
((
pSet
=
tsdbFSIterNext
(
&
(
deleteH
.
fsIter
))))
{
// remove expired files
if
(
pSet
->
fid
<
deleteH
.
rtn
.
minFid
)
{
tsdbInfo
(
"vgId:%d FSET %d on level %d disk id %d expires, remove it"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tsdbInfo
(
"
:SDEL
vgId:%d FSET %d on level %d disk id %d expires, remove it"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
TSDB_FSET_LEVEL
(
pSet
),
TSDB_FSET_ID
(
pSet
));
continue
;
}
if
((
pSet
->
fid
<
sFid
)
||
(
pSet
->
fid
>
eFid
))
{
tsdbDebug
(
"vgId:%d no need to delete FSET %d, sFid %d, eFid %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
sFid
,
eFid
);
tsdbDebug
(
"
:SDEL
vgId:%d no need to delete FSET %d, sFid %d, eFid %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
sFid
,
eFid
);
if
(
tsdbApplyRtnOnFSet
(
pRepo
,
pSet
,
&
(
deleteH
.
rtn
))
<
0
)
{
return
-
1
;
}
...
...
@@ -231,7 +233,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
if
(
pCtlInfo
->
command
&
CMD_DELETE_DATA
)
{
if
(
tsdbFSetDelete
(
&
deleteH
,
pSet
)
<
0
)
{
tsdbDestroyDeleteH
(
&
deleteH
);
tsdbError
(
"vgId:%d failed to delete data in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"
:SDEL
vgId:%d failed to delete data in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
return
-
1
;
}
}
else
{
...
...
@@ -241,7 +243,27 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
}
tsdbDestroyDeleteH
(
&
deleteH
);
tsdbDebug
(
"vgId:%d delete TS data over"
,
REPO_ID
(
pRepo
));
tsdbDebug
(
":SDEL vgId:%d delete TS data over"
,
REPO_ID
(
pRepo
));
return
0
;
}
static
int
tsdbSDFileCreate
(
STsdbRepo
*
pRepo
,
SDFileSet
*
pWSet
,
SDFileSet
*
pSet
,
SDiskID
did
,
TSDB_FILE_T
ftype
)
{
SDFile
*
pSDFile
=
TSDB_DFILE_IN_SET
(
pWSet
,
ftype
);
tsdbInitDFile
(
pSDFile
,
did
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pSet
),
FS_VERSION
(
REPO_FS
(
pRepo
)),
ftype
);
struct
stat
st
;
if
(
stat
(
pSDFile
->
f
.
aname
,
&
st
)
==
0
)
{
tsdbError
(
":SDEL vgId:%d file exist no need create fid=%d name=%s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
pSDFile
->
f
.
aname
);
return
0
;
}
if
(
tsdbCreateDFile
(
pSDFile
,
true
,
ftype
)
<
0
)
{
tsdbError
(
":SDEL vgId:%d failed to delete table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbCloseDFile
(
pSDFile
);
tsdbRemoveDFile
(
pSDFile
);
return
-
1
;
}
tsdbCloseDFile
(
pSDFile
);
return
0
;
}
...
...
@@ -250,11 +272,11 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
SDiskID
did
=
{
0
};
SDFileSet
*
pWSet
=
TSDB_DELETE_WSET
(
pdh
);
tsdbDebug
(
"vgId:%d start to delete data in FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tsdbDebug
(
"
:SDEL
vgId:%d start to delete data in FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
TSDB_FSET_LEVEL
(
pSet
),
TSDB_FSET_ID
(
pSet
));
if
(
tsdbFSetInit
(
pdh
,
pSet
)
<
0
)
{
tsdbError
(
"vgId:%d fset init failed. FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tsdbError
(
"
:SDEL
vgId:%d fset init failed. FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
TSDB_FSET_LEVEL
(
pSet
),
TSDB_FSET_ID
(
pSet
));
return
-
1
;
}
...
...
@@ -263,7 +285,7 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
tfsAllocDisk
(
tsdbGetFidLevel
(
pSet
->
fid
,
&
(
pdh
->
rtn
)),
&
(
did
.
level
),
&
(
did
.
id
));
if
(
did
.
level
==
TFS_UNDECIDED_LEVEL
)
{
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
tsdbError
(
"vgId:%d failed to delete table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"
:SDEL
vgId:%d failed to delete table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbDeleteFSetEnd
(
pdh
);
return
-
1
;
}
...
...
@@ -271,20 +293,37 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
// Only .head is created, use original .data/.last/.smad/.smal
tsdbInitDFileSetEx
(
pWSet
,
pSet
);
pWSet
->
state
=
0
;
// old pset
if
(
pWSet
->
ver
==
TSDB_FSET_VER_0
)
{
tsdbDebug
(
":SDEL vgId:%d pWSet is ver0. fid=%d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
);
if
(
tsdbSDFileCreate
(
pRepo
,
pWSet
,
pSet
,
did
,
TSDB_FILE_SMAD
)
<
0
)
{
tsdbError
(
":SDEL vgId:%d failed to create sma files. fid=%d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
return
-
1
;
}
if
(
tsdbSDFileCreate
(
pRepo
,
pWSet
,
pSet
,
did
,
TSDB_FILE_SMAL
)
<
0
)
{
tsdbError
(
":SDEL vgId:%d failed to create sma files. fid=%d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
return
-
1
;
}
pWSet
->
ver
=
TSDB_FS_VER_1
;
}
// create new .head file FS_TXN_VERSION is nstatus.meta.version, so version is +=1
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
(
tsdbCreateDFile
(
pHeadFile
,
true
,
TSDB_FILE_HEAD
)
<
0
)
{
tsdbError
(
"vgId:%d failed to delete table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"
:SDEL
vgId:%d failed to delete 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
));
tsdbError
(
"
:SDEL
vgId:%d failed to open file set %d since %s"
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pWSet
),
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -297,7 +336,7 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
tsdbCloseDFileSet
(
TSDB_DELETE_WSET
(
pdh
));
tsdbUpdateDFileSet
(
REPO_FS
(
pRepo
),
TSDB_DELETE_WSET
(
pdh
));
tsdbDebug
(
"vgId:%d FSET %d delete data over"
,
REPO_ID
(
pRepo
),
pSet
->
fid
);
tsdbDebug
(
"
:SDEL
vgId:%d FSET %d delete data over"
,
REPO_ID
(
pRepo
),
pSet
->
fid
);
tsdbDeleteFSetEnd
(
pdh
);
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录