Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
416d4ac6
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看板
提交
416d4ac6
编写于
9月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
ff9f56e0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
88 addition
and
45 deletion
+88
-45
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+33
-41
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+55
-4
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
416d4ac6
...
...
@@ -551,13 +551,12 @@ _err:
return
code
;
}
static
int32_t
tsdbCommitDataBlock
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bData
;
SDataBlk
dataBlk
;
int32_t
tsdbWriteDataBlock
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SMapData
*
mDataBlk
,
int8_t
cmprAlg
)
{
int32_t
code
=
0
;
ASSERT
(
pBlockData
->
nRow
>
0
)
;
if
(
pBlockData
->
nRow
==
0
)
return
code
;
SDataBlk
dataBlk
;
tDataBlkReset
(
&
dataBlk
);
// info
...
...
@@ -585,13 +584,12 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter) {
// write
dataBlk
.
nSubBlock
++
;
code
=
tsdbWriteBlockData
(
pCommitter
->
dWriter
.
pWriter
,
pBlockData
,
&
dataBlk
.
aSubBlock
[
dataBlk
.
nSubBlock
-
1
],
((
dataBlk
.
nSubBlock
==
1
)
&&
!
dataBlk
.
hasDup
)
?
&
dataBlk
.
smaInfo
:
NULL
,
pCommitter
->
cmprAlg
,
0
);
code
=
tsdbWriteBlockData
(
pWriter
,
pBlockData
,
&
dataBlk
.
aSubBlock
[
dataBlk
.
nSubBlock
-
1
],
((
dataBlk
.
nSubBlock
==
1
)
&&
!
dataBlk
.
hasDup
)
?
&
dataBlk
.
smaInfo
:
NULL
,
cmprAlg
,
0
);
if
(
code
)
goto
_err
;
// put SDataBlk
code
=
tMapDataPutItem
(
&
pCommitter
->
dWriter
.
mBloc
k
,
&
dataBlk
,
tPutDataBlk
);
code
=
tMapDataPutItem
(
mDataBl
k
,
&
dataBlk
,
tPutDataBlk
);
if
(
code
)
goto
_err
;
// clear
...
...
@@ -600,16 +598,15 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter) {
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb commit data block failed since %s"
,
TD_VID
(
p
Commit
ter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d tsdb commit data block failed since %s"
,
TD_VID
(
p
Wri
ter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
static
int32_t
tsdbCommitLastBlock
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
SSttBlk
sstBlk
;
SBlockData
*
pBlockData
=
&
pCommitter
->
dWriter
.
bDatal
;
int32_t
tsdbWriteSttBlock
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SArray
*
aSttBlk
,
int8_t
cmprAlg
)
{
int32_t
code
=
0
;
SSttBlk
sstBlk
;
ASSERT
(
pBlockData
->
nRow
>
0
)
;
if
(
pBlockData
->
nRow
==
0
)
return
code
;
// info
sstBlk
.
suid
=
pBlockData
->
suid
;
...
...
@@ -628,11 +625,11 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
sstBlk
.
maxUid
=
pBlockData
->
uid
?
pBlockData
->
uid
:
pBlockData
->
aUid
[
pBlockData
->
nRow
-
1
];
// write
code
=
tsdbWriteBlockData
(
p
Committer
->
dWriter
.
pWriter
,
pBlockData
,
&
sstBlk
.
bInfo
,
NULL
,
pCommitter
->
cmprAlg
,
1
);
code
=
tsdbWriteBlockData
(
p
Writer
,
pBlockData
,
&
sstBlk
.
bInfo
,
NULL
,
cmprAlg
,
1
);
if
(
code
)
goto
_err
;
// push SSttBlk
if
(
taosArrayPush
(
pCommitter
->
dWriter
.
aSttBlk
,
&
sstBlk
)
==
NULL
)
{
if
(
taosArrayPush
(
aSttBlk
,
&
sstBlk
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
...
...
@@ -643,7 +640,7 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb commit last block failed since %s"
,
TD_VID
(
p
Commit
ter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d tsdb commit last block failed since %s"
,
TD_VID
(
p
Wri
ter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
...
...
@@ -1120,15 +1117,14 @@ static int32_t tsdbCommitAheadBlock(SCommitter *pCommitter, SDataBlk *pDataBlk)
}
if
(
pBlockData
->
nRow
>=
pCommitter
->
maxRow
)
{
code
=
tsdbCommitDataBlock
(
pCommitter
);
code
=
tsdbWriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBlockData
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
if
(
pBlockData
->
nRow
)
{
code
=
tsdbCommitDataBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
code
=
tsdbWriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBlockData
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
return
code
;
...
...
@@ -1189,7 +1185,7 @@ static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk)
}
if
(
pBDataW
->
nRow
>=
pCommitter
->
maxRow
)
{
code
=
tsdb
CommitDataBlock
(
pCommitter
);
code
=
tsdb
WriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBDataW
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
...
...
@@ -1206,15 +1202,13 @@ static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk)
}
if
(
pBDataW
->
nRow
>=
pCommitter
->
maxRow
)
{
code
=
tsdb
CommitDataBlock
(
pCommitter
);
code
=
tsdb
WriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBDataW
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
if
(
pBDataW
->
nRow
)
{
code
=
tsdbCommitDataBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
code
=
tsdbWriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBDataW
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
return
code
;
...
...
@@ -1302,10 +1296,8 @@ static int32_t tsdbInitLastBlockIfNeed(SCommitter *pCommitter, TABLEID id) {
SBlockData
*
pBDatal
=
&
pCommitter
->
dWriter
.
bDatal
;
if
(
pBDatal
->
suid
||
pBDatal
->
uid
)
{
if
((
pBDatal
->
suid
!=
id
.
suid
)
||
(
id
.
suid
==
0
))
{
if
(
pBDatal
->
nRow
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_exit
;
}
code
=
tsdbWriteSttBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBDatal
,
pCommitter
->
dWriter
.
aSttBlk
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_exit
;
tBlockDataReset
(
pBDatal
);
}
}
...
...
@@ -1337,7 +1329,7 @@ static int32_t tsdbAppendLastBlock(SCommitter *pCommitter) {
if
(
code
)
goto
_err
;
if
(
pBDatal
->
nRow
>=
pCommitter
->
maxRow
)
{
code
=
tsdb
CommitLastBlock
(
pCommitter
);
code
=
tsdb
WriteSttBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBDatal
,
pCommitter
->
dWriter
.
aSttBlk
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
...
...
@@ -1389,10 +1381,11 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, TABLEID id) {
if
(
pBData
->
nRow
>=
pCommitter
->
maxRow
)
{
if
(
pCommitter
->
toLastOnly
)
{
code
=
tsdb
CommitLastBlock
(
pCommitter
);
code
=
tsdb
WriteSttBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBData
,
pCommitter
->
dWriter
.
aSttBlk
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
else
{
code
=
tsdbCommitDataBlock
(
pCommitter
);
code
=
tsdbWriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBData
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
}
...
...
@@ -1400,7 +1393,7 @@ static int32_t tsdbCommitTableData(SCommitter *pCommitter, TABLEID id) {
if
(
!
pCommitter
->
toLastOnly
&&
pBData
->
nRow
)
{
if
(
pBData
->
nRow
>
pCommitter
->
minRow
)
{
code
=
tsdb
CommitDataBlock
(
pCommitter
);
code
=
tsdb
WriteDataBlock
(
pCommitter
->
dWriter
.
pWriter
,
pBData
,
&
pCommitter
->
dWriter
.
mBlock
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
}
else
{
code
=
tsdbAppendLastBlock
(
pCommitter
);
...
...
@@ -1466,10 +1459,9 @@ static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) {
code
=
tsdbMoveCommitData
(
pCommitter
,
id
);
if
(
code
)
goto
_err
;
if
(
pCommitter
->
dWriter
.
bDatal
.
nRow
>
0
)
{
code
=
tsdbCommitLastBlock
(
pCommitter
);
if
(
code
)
goto
_err
;
}
code
=
tsdbWriteSttBlock
(
pCommitter
->
dWriter
.
pWriter
,
&
pCommitter
->
dWriter
.
bDatal
,
pCommitter
->
dWriter
.
aSttBlk
,
pCommitter
->
cmprAlg
);
if
(
code
)
goto
_err
;
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
416d4ac6
...
...
@@ -1074,6 +1074,9 @@ _err:
}
#endif
extern
int32_t
tsdbWriteDataBlock
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SMapData
*
mDataBlk
,
int8_t
cmprAlg
);
extern
int32_t
tsdbWriteSttBlock
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SArray
*
aSttBlk
,
int8_t
cmprAlg
);
static
int32_t
tsdbSnapNextTableData
(
STsdbSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
...
...
@@ -1179,19 +1182,67 @@ static int32_t tsdbSnapWriteCloseFile(STsdbSnapWriter* pWriter) {
ASSERT
(
pWriter
->
dWriter
.
pWriter
);
// (todo)
// todo: end current commit table
for
(;
pWriter
->
dReader
.
iRow
<
pWriter
->
dReader
.
bData
.
nRow
;
pWriter
->
dReader
.
iRow
++
)
{
TSDBROW
row
=
tsdbRowFromBlockData
(
&
pWriter
->
dReader
.
bData
,
pWriter
->
dReader
.
iRow
);
code
=
tBlockDataAppendRow
(
&
pWriter
->
dWriter
.
bData
,
&
row
,
NULL
,
pWriter
->
dReader
.
pBlockIdx
->
uid
);
if
(
code
)
goto
_err
;
}
for
(;
pWriter
->
dReader
.
iDataBlk
<
pWriter
->
dReader
.
mDataBlk
.
nItem
;
pWriter
->
dReader
.
iDataBlk
++
)
{
SDataBlk
dataBlk
;
tMapDataGetItemByIdx
(
&
pWriter
->
dReader
.
mDataBlk
,
pWriter
->
dReader
.
iDataBlk
,
&
dataBlk
,
tGetDataBlk
);
code
=
tMapDataPutItem
(
&
pWriter
->
dWriter
.
mDataBlk
,
&
dataBlk
,
tPutDataBlk
);
if
(
code
)
goto
_err
;
}
if
(
pWriter
->
dWriter
.
mDataBlk
.
nItem
)
{
SBlockIdx
blockIdx
=
*
pWriter
->
dReader
.
pBlockIdx
;
code
=
tsdbWriteDataBlk
(
pWriter
->
dWriter
.
pWriter
,
&
pWriter
->
dWriter
.
mDataBlk
,
&
blockIdx
);
if
(
code
)
goto
_err
;
if
(
taosArrayPush
(
pWriter
->
dWriter
.
aBlockIdx
,
&
blockIdx
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
}
// copy remain table data
TABLEID
id
=
{.
suid
=
INT64_MAX
,
.
uid
=
INT64_MAX
};
code
=
tsdbSnapWriteCopyData
(
pWriter
,
&
id
);
if
(
code
)
goto
_e
xit
;
if
(
code
)
goto
_e
rr
;
if
(
pWriter
->
dWriter
.
sData
.
nRow
>
0
)
{
// TODO: write the last block
code
=
tsdbWriteSttBlock
(
pWriter
->
dWriter
.
pWriter
,
&
pWriter
->
dWriter
.
sData
,
pWriter
->
dWriter
.
aSttBlk
,
pWriter
->
cmprAlg
);
if
(
code
)
goto
_err
;
// Indices
code
=
tsdbWriteBlockIdx
(
pWriter
->
dWriter
.
pWriter
,
pWriter
->
dWriter
.
aBlockIdx
);
if
(
code
)
goto
_err
;
code
=
tsdbWriteSttBlk
(
pWriter
->
dWriter
.
pWriter
,
pWriter
->
dWriter
.
aSttBlk
);
if
(
code
)
goto
_err
;
code
=
tsdbUpdateDFileSetHeader
(
pWriter
->
dWriter
.
pWriter
);
if
(
code
)
goto
_err
;
code
=
tsdbFSUpsertFSet
(
&
pWriter
->
fs
,
&
pWriter
->
dWriter
.
pWriter
->
wSet
);
if
(
code
)
goto
_err
;
code
=
tsdbDataFWriterClose
(
&
pWriter
->
dWriter
.
pWriter
,
1
);
if
(
code
)
goto
_err
;
if
(
pWriter
->
dReader
.
pReader
)
{
code
=
tsdbDataFReaderClose
(
&
pWriter
->
dReader
.
pReader
);
if
(
code
)
goto
_err
;
}
_exit:
return
code
;
_err:
return
code
;
}
static
int32_t
tsdbSnapWriteRowData
(
STsdbSnapWriter
*
pWriter
,
int32_t
iRow
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录