Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2d50a39b
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看板
提交
2d50a39b
编写于
4月 07, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-238]<feature>(tsdb): finished affected tables count right
上级
fd924682
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
16 deletion
+46
-16
src/tsdb/src/tsdbDelete.c
src/tsdb/src/tsdbDelete.c
+46
-16
未找到文件。
src/tsdb/src/tsdbDelete.c
浏览文件 @
2d50a39b
...
...
@@ -48,6 +48,7 @@ typedef struct {
SDataCols
*
pDCols
;
SControlDataInfo
*
pCtlInfo
;
SArray
*
aUpdates
;
SArray
*
aAffectTables
;
}
SDeleteH
;
...
...
@@ -65,7 +66,7 @@ typedef struct {
static
void
tsdbStartDeleteTrans
(
STsdbRepo
*
pRepo
);
static
void
tsdbEndDeleteTrans
(
STsdbRepo
*
pRepo
,
int
eno
);
static
int
tsdbDeleteTSData
(
STsdbRepo
*
pRepo
,
SControlDataInfo
*
pCtlInfo
,
SArray
*
pArray
);
static
int
tsdbDeleteTSData
(
STsdbRepo
*
pRepo
,
SControlDataInfo
*
pCtlInfo
,
SArray
*
pArray
,
SArray
*
pAffectTables
);
static
int
tsdbFSetDelete
(
SDeleteH
*
pdh
,
SDFileSet
*
pSet
);
static
int
tsdbInitDeleteH
(
SDeleteH
*
pdh
,
STsdbRepo
*
pRepo
);
static
void
tsdbDestroyDeleteH
(
SDeleteH
*
pdh
);
...
...
@@ -126,6 +127,9 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
return
-
1
;
}
SArray
*
aUpdates
=
taosArrayInit
(
10
,
sizeof
(
STable
*
));
SArray
*
affectedTables
=
taosArrayInit
(
10
,
sizeof
(
int32_t
));
// put tid
// start transaction
tsdbStartDeleteTrans
(
pRepo
);
...
...
@@ -134,8 +138,7 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
goto
_err
;
}
SArray
*
aUpdates
=
taosArrayInit
(
10
,
sizeof
(
STable
*
));
if
(
tsdbDeleteTSData
(
pRepo
,
pCtlInfo
,
aUpdates
)
<
0
)
{
if
(
tsdbDeleteTSData
(
pRepo
,
pCtlInfo
,
aUpdates
,
affectedTables
)
<
0
)
{
tsdbError
(
"vgId:%d failed to truncate TS data since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
...
...
@@ -145,18 +148,20 @@ static int tsdbDeleteImplCommon(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo) {
// set affected tables number
if
(
pCtlInfo
->
pRsp
)
{
pCtlInfo
->
pRsp
->
numOfTables
=
pCtlInfo
->
tnum
;
pCtlInfo
->
pRsp
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
affectedTables
)
;
}
// update last row
tsdbUpdateLastRow
(
pRepo
,
aUpdates
);
tsdbClearUpdates
(
aUpdates
);
taosArrayDestroy
(
&
affectedTables
);
return
TSDB_CODE_SUCCESS
;
_err:
pRepo
->
code
=
terrno
;
tsdbEndDeleteTrans
(
pRepo
,
terrno
);
tsdbClearUpdates
(
aUpdates
);
taosArrayDestroy
(
&
affectedTables
);
return
-
1
;
}
...
...
@@ -179,7 +184,7 @@ static void tsdbEndDeleteTrans(STsdbRepo *pRepo, int eno) {
tsem_post
(
&
(
pRepo
->
readyToCommit
));
}
static
int
tsdbDeleteTSData
(
STsdbRepo
*
pRepo
,
SControlDataInfo
*
pCtlInfo
,
SArray
*
pArray
)
{
static
int
tsdbDeleteTSData
(
STsdbRepo
*
pRepo
,
SControlDataInfo
*
pCtlInfo
,
SArray
*
pArray
,
SArray
*
pAffectTables
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
SDeleteH
deleteH
=
{
0
};
SDFileSet
*
pSet
=
NULL
;
...
...
@@ -193,6 +198,7 @@ static int tsdbDeleteTSData(STsdbRepo *pRepo, SControlDataInfo* pCtlInfo, SArray
deleteH
.
aUpdates
=
pArray
;
deleteH
.
pCtlInfo
=
pCtlInfo
;
STimeWindow
win
=
pCtlInfo
->
win
;
deleteH
.
aAffectTables
=
pAffectTables
;
int
sFid
=
TSDB_KEY_FID
(
win
.
skey
,
pCfg
->
daysPerFile
,
pCfg
->
precision
);
int
eFid
=
TSDB_KEY_FID
(
win
.
ekey
,
pCfg
->
daysPerFile
,
pCfg
->
precision
);
...
...
@@ -371,6 +377,18 @@ void tsdbAddUpdates(SArray* pArray, STable* pTable) {
taosArrayAddBatch
(
pArray
,
&
pTable
,
1
);
}
void
tsdbAddAffectTables
(
SArray
*
pArray
,
int32_t
tid
)
{
size_t
cnt
=
taosArrayGetSize
(
pArray
);
for
(
size_t
i
=
0
;
i
<
cnt
;
i
++
)
{
int32_t
tid1
=
*
(
int32_t
*
)
taosArrayGet
(
pArray
,
i
);
if
(
tid1
==
tid
)
{
// exist return
return
;
}
}
// append
taosArrayAddBatch
(
pArray
,
&
tid
,
1
);
}
// init tbl array with pRepo->meta
static
int
tsdbInitDeleteTblArray
(
SDeleteH
*
pdh
)
{
STsdbRepo
*
pRepo
=
TSDB_DELETE_REPO
(
pdh
);
...
...
@@ -499,12 +517,7 @@ static int32_t tsdbFilterDataCols(SDeleteH *pdh, SDataCols *pSrcDCols) {
++
pDstDCols
->
numOfRows
;
}
// affectedRows
if
(
pdh
->
pCtlInfo
->
pRsp
)
{
pdh
->
pCtlInfo
->
pRsp
->
affectedRows
+=
delRows
;
}
return
0
;
return
delRows
;
}
// table in delete list
...
...
@@ -565,11 +578,17 @@ int tsdbRemoveDelBlocks(SDeleteH *pdh, STableDeleteH * pItem) {
numOfBlocks
-=
delCnt
;
}
// set
value
// set
current blocks num
pItem
->
pBlkIdx
->
numOfBlocks
=
numOfBlocks
;
if
(
delRows
>
0
)
{
// affected Rows
if
(
pdh
->
pCtlInfo
->
pRsp
)
{
pdh
->
pCtlInfo
->
pRsp
->
affectedRows
+=
delRows
;
}
// affected Tables
tsdbAddAffectTables
(
pdh
->
aAffectTables
,
pItem
->
pTable
->
tableId
.
tid
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -622,6 +641,8 @@ static int tsdbModifyBlocks(SDeleteH *pdh, STableDeleteH *pItem) {
taosArrayClear
(
pdh
->
aSupBlk
);
taosArrayClear
(
pdh
->
aSubBlk
);
int32_t
affectedRows
=
0
;
// Loop to truncate each block data
for
(
int
i
=
0
;
i
<
pItem
->
pBlkIdx
->
numOfBlocks
;
++
i
)
{
SBlock
*
pBlock
=
pItem
->
pInfo
->
blocks
+
i
;
...
...
@@ -636,7 +657,7 @@ static int tsdbModifyBlocks(SDeleteH *pdh, STableDeleteH *pItem) {
return
-
1
;
}
tsdbFilterDataCols
(
pdh
,
pReadh
->
pDCols
[
0
]);
affectedRows
+=
tsdbFilterDataCols
(
pdh
,
pReadh
->
pDCols
[
0
]);
if
(
pdh
->
pDCols
->
numOfRows
<=
0
)
{
continue
;
}
...
...
@@ -669,6 +690,15 @@ static int tsdbModifyBlocks(SDeleteH *pdh, STableDeleteH *pItem) {
tsdbAddUpdates
(
pdh
->
aUpdates
,
pItem
->
pTable
);
}
if
(
affectedRows
>
0
)
{
// affectedRows
if
(
pdh
->
pCtlInfo
->
pRsp
)
{
pdh
->
pCtlInfo
->
pRsp
->
affectedRows
+=
affectedRows
;
}
// affectTables
tsdbAddAffectTables
(
pdh
->
aAffectTables
,
pItem
->
pTable
->
tableId
.
tid
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录