Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
54282b6f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
54282b6f
编写于
4月 08, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-238]<feature>(tsdb): fixed last_row null if table no data
上级
17c0b955
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
15 deletion
+24
-15
src/tsdb/src/tsdbDelete.c
src/tsdb/src/tsdbDelete.c
+17
-15
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+7
-0
未找到文件。
src/tsdb/src/tsdbDelete.c
浏览文件 @
54282b6f
...
...
@@ -134,12 +134,12 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
tsdbStartDeleteTrans
(
pRepo
);
if
(
tsdbDeleteMeta
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to
trunca
te META data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to
dele
te META data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
if
(
tsdbDeleteTSData
(
pRepo
,
pCtlInfo
,
aUpdates
,
affectedTables
)
<
0
)
{
tsdbError
(
"vgId:%d failed to
trunca
te TS data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to
dele
te TS data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
...
...
@@ -167,7 +167,7 @@ _err:
static
void
tsdbStartDeleteTrans
(
STsdbRepo
*
pRepo
)
{
assert
(
pRepo
->
deleteState
!=
TSDB_IN_DELETE
);
tsdbInfo
(
"vgId:%d start to
trunca
te!"
,
REPO_ID
(
pRepo
));
tsdbInfo
(
"vgId:%d start to
dele
te!"
,
REPO_ID
(
pRepo
));
tsdbStartFSTxn
(
pRepo
,
0
,
0
);
pRepo
->
code
=
TSDB_CODE_SUCCESS
;
pRepo
->
deleteState
=
TSDB_IN_DELETE
;
...
...
@@ -180,7 +180,7 @@ static void tsdbEndDeleteTrans(STsdbRepo *pRepo, int eno) {
tsdbEndFSTxn
(
pRepo
);
}
pRepo
->
deleteState
=
TSDB_NO_DELETE
;
tsdbInfo
(
"vgId:%d
trunca
te over, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
tsdbInfo
(
"vgId:%d
dele
te over, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
tsem_post
(
&
(
pRepo
->
readyToCommit
));
}
...
...
@@ -189,7 +189,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
SDeleteH
deleteH
=
{
0
};
SDFileSet
*
pSet
=
NULL
;
tsdbDebug
(
"vgId:%d start to
trunca
te TS data for %d"
,
REPO_ID
(
pRepo
),
pCtlInfo
->
tids
[
0
]);
tsdbDebug
(
"vgId:%d start to
dele
te TS data for %d"
,
REPO_ID
(
pRepo
),
pCtlInfo
->
tids
[
0
]);
if
(
tsdbInitDeleteH
(
&
deleteH
,
pRepo
)
<
0
)
{
return
-
1
;
...
...
@@ -213,7 +213,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
}
if
((
pSet
->
fid
<
sFid
)
||
(
pSet
->
fid
>
eFid
))
{
tsdbDebug
(
"vgId:%d no need to
trunca
te FSET %d, sFid %d, eFid %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
sFid
,
eFid
);
tsdbDebug
(
"vgId:%d no need to
dele
te FSET %d, sFid %d, eFid %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
sFid
,
eFid
);
if
(
tsdbApplyRtnOnFSet
(
pRepo
,
pSet
,
&
(
deleteH
.
rtn
))
<
0
)
{
return
-
1
;
}
...
...
@@ -222,7 +222,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
#if 0 // TODO: How to make the decision? The test case should cover this scenario.
if (TSDB_FSET_LEVEL(pSet) == TFS_MAX_LEVEL) {
tsdbDebug("vgId:%d FSET %d on level %d, should not
trunca
te", REPO_ID(pRepo), pSet->fid, TFS_MAX_LEVEL);
tsdbDebug("vgId:%d FSET %d on level %d, should not
dele
te", REPO_ID(pRepo), pSet->fid, TFS_MAX_LEVEL);
tsdbUpdateDFileSet(REPO_FS(pRepo), pSet);
continue;
}
...
...
@@ -231,7 +231,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
trunca
te data in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to
dele
te data in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
return
-
1
;
}
}
else
{
...
...
@@ -241,7 +241,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
}
tsdbDestroyDeleteH
(
&
deleteH
);
tsdbDebug
(
"vgId:%d
trunca
te TS data over"
,
REPO_ID
(
pRepo
));
tsdbDebug
(
"vgId:%d
dele
te TS data over"
,
REPO_ID
(
pRepo
));
return
0
;
}
...
...
@@ -250,18 +250,20 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
SDiskID
did
=
{
0
};
SDFileSet
*
pWSet
=
TSDB_DELETE_WSET
(
pdh
);
tsdbDebug
(
"vgId:%d start to
trunca
te data in FSET %d on level %d id %d"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tsdbDebug
(
"vgId:%d start to
dele
te 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
,
TSDB_FSET_LEVEL
(
pSet
),
TSDB_FSET_ID
(
pSet
));
return
-
1
;
}
// Create new fset as
trunca
ted fset
// Create new fset as
dele
ted fset
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
trunca
te table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to
dele
te table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbDeleteFSetEnd
(
pdh
);
return
-
1
;
}
...
...
@@ -273,7 +275,7 @@ static int tsdbFSetDelete(SDeleteH *pdh, SDFileSet *pSet) {
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
trunca
te table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to
dele
te table in FSET %d since %s"
,
REPO_ID
(
pRepo
),
pSet
->
fid
,
tstrerror
(
terrno
));
tsdbCloseDFile
(
pHeadFile
);
tsdbRemoveDFile
(
pHeadFile
);
return
-
1
;
...
...
@@ -295,7 +297,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
trunca
te data over"
,
REPO_ID
(
pRepo
),
pSet
->
fid
);
tsdbDebug
(
"vgId:%d FSET %d
dele
te data over"
,
REPO_ID
(
pRepo
),
pSet
->
fid
);
tsdbDeleteFSetEnd
(
pdh
);
return
0
;
...
...
@@ -650,7 +652,7 @@ static int tsdbModifyBlocks(SDeleteH *pdh, STableDeleteH *pItem) {
int32_t
affectedRows
=
0
;
// Loop to
trunca
te each block data
// Loop to
dele
te each block data
for
(
int
i
=
0
;
i
<
pItem
->
pBlkIdx
->
numOfBlocks
;
++
i
)
{
SBlock
*
pBlock
=
pItem
->
pInfo
->
blocks
+
i
;
int32_t
solve
=
tsdbBlockSolve
(
pdh
,
pBlock
);
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
54282b6f
...
...
@@ -1029,6 +1029,13 @@ int32_t tsdbLoadLastCache(STsdbRepo *pRepo, STable *pTable, bool lastKey) {
}
}
if
(
cacheLastRowTableNum
>
0
&&
readh
.
pBlkIdx
==
NULL
)
{
// table no data, so reset lastKey
TSDB_WLOCK_TABLE
(
pTable
);
pTable
->
lastKey
=
TSKEY_INITIAL_VAL
;
TSDB_WUNLOCK_TABLE
(
pTable
);
}
tsdbUnLockFS
(
REPO_FS
(
pRepo
));
tsdbDestroyReadH
(
&
readh
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录