Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
117bc90d
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看板
提交
117bc90d
编写于
8月 18, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more snapshot
上级
a4e4f4cc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
52 deletion
+48
-52
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+47
-52
未找到文件。
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
117bc90d
...
...
@@ -368,6 +368,7 @@ struct SSma {
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
enum
{
SNAP_DATA_CFG
=
0
,
SNAP_DATA_META
=
1
,
SNAP_DATA_TSDB
=
2
,
SNAP_DATA_DEL
=
3
,
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
117bc90d
...
...
@@ -354,6 +354,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) {
*
ppData
=
NULL
;
#if 0
// read data file
if (!pReader->dataDone) {
code = tsdbSnapReadData(pReader, ppData);
...
...
@@ -367,6 +368,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) {
}
}
}
#endif
// read del file
if
(
!
pReader
->
delDone
)
{
...
...
@@ -956,6 +958,7 @@ _err:
tstrerror(code));
return code;
}
#endif
static
int32_t
tsdbSnapWriteDel
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
...
...
@@ -966,7 +969,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
// reader
if
(
pDelFile
)
{
code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb
, NULL
);
code
=
tsdbDelFReaderOpen
(
&
pWriter
->
pDelFReader
,
pDelFile
,
pTsdb
);
if
(
code
)
goto
_err
;
code
=
tsdbReadDelIdx
(
pWriter
->
pDelFReader
,
pWriter
->
aDelIdxR
);
...
...
@@ -983,60 +986,57 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
TABLEID
id
=
*
(
TABLEID
*
)(
pData
+
sizeof
(
SSnapDataHdr
));
while
(
true
)
{
SDelIdx* pDelIdx = NULL;
int64_t n = sizeof(SSnapDataHdr) + sizeof(TABLEID);
SDelData delData;
SDelIdx delIdx;
int8_t toBreak = 0;
if
(
pWriter
->
iDelIdx
>=
taosArrayGetSize
(
pWriter
->
aDelIdxR
))
break
;
if
(
tTABLEIDCmprFn
(
taosArrayGet
(
pWriter
->
aDelIdxR
,
pWriter
->
iDelIdx
),
&
id
)
>=
0
)
break
;
if (pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdxR)) {
pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
}
SDelIdx
*
pDelIdx
=
(
SDelIdx
*
)
taosArrayGet
(
pWriter
->
aDelIdxR
,
pWriter
->
iDelIdx
);
if (pDelIdx) {
int32_t c = tTABLEIDCmprFn(&id, pDelIdx);
if (c < 0) {
goto _new_del;
} else {
code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
if (code) goto _err;
code
=
tsdbReadDelData
(
pWriter
->
pDelFReader
,
pDelIdx
,
pWriter
->
aDelData
);
if
(
code
)
goto
_err
;
pWriter->iDelIdx++;
if (c == 0) {
toBreak = 1;
delIdx = (SDelIdx){.suid = id.suid, .uid = id.uid};
goto _merge_del;
} else {
delIdx = (SDelIdx){.suid = pDelIdx->suid, .uid = pDelIdx->uid};
goto _write_del;
}
}
SDelIdx
delIdx
=
*
pDelIdx
;
code
=
tsdbWriteDelData
(
pWriter
->
pDelFWriter
,
pWriter
->
aDelData
,
&
delIdx
);
if
(
code
)
goto
_err
;
if
(
taosArrayPush
(
pWriter
->
aDelIdxW
,
&
delIdx
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
_new_del:
toBreak = 1;
delIdx = (SDelIdx){.suid = id.suid, .uid = id.uid};
taosArrayClear(pWriter->aDelData);
pWriter
->
iDelIdx
++
;
}
_merge_del:
while (n < nData) {
n += tGetDelData(pData + n, &delData);
if (taosArrayPush(pWriter->aDelData, &delData) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
}
if
(
pWriter
->
iDelIdx
<
taosArrayGetSize
(
pWriter
->
aDelIdxR
)
&&
tTABLEIDCmprFn
(
taosArrayGet
(
pWriter
->
aDelIdxR
,
pWriter
->
iDelIdx
),
&
id
)
==
0
)
{
SDelIdx
*
pDelIdx
=
(
SDelIdx
*
)
taosArrayGet
(
pWriter
->
aDelIdxR
,
pWriter
->
iDelIdx
);
_write_del:
code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
code
=
tsdbReadDelData
(
pWriter
->
pDelFReader
,
pDelIdx
,
pWriter
->
aDelData
);
if
(
code
)
goto
_err
;
if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) {
pWriter
->
iDelIdx
++
;
}
else
{
taosArrayClear
(
pWriter
->
aDelData
);
}
int64_t
n
=
sizeof
(
SSnapDataHdr
)
+
sizeof
(
TABLEID
);
while
(
n
<
nData
)
{
SDelData
delData
;
n
+=
tGetDelData
(
pData
+
n
,
&
delData
);
if
(
taosArrayPush
(
pWriter
->
aDelData
,
&
delData
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
}
if (toBreak) break;
SDelIdx
delIdx
=
{.
suid
=
id
.
suid
,
.
uid
=
id
.
uid
};
code
=
tsdbWriteDelData
(
pWriter
->
pDelFWriter
,
pWriter
->
aDelData
,
&
delIdx
);
if
(
code
)
goto
_err
;
if
(
taosArrayPush
(
pWriter
->
aDelIdxW
,
&
delIdx
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
_exit:
...
...
@@ -1047,9 +1047,7 @@ _err:
tstrerror
(
code
));
return
code
;
}
#endif
#if 0
static
int32_t
tsdbSnapWriteDelEnd
(
STsdbSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pWriter
->
pTsdb
;
...
...
@@ -1062,7 +1060,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
code
=
tsdbReadDelData
(
pWriter
->
pDelFReader
,
pDelIdx
,
pWriter
->
aDelData
);
if
(
code
)
goto
_err
;
SDelIdx delIdx =
(SDelIdx){.suid = pDelIdx->suid, .uid = pDelIdx->uid}
;
SDelIdx
delIdx
=
*
pDelIdx
;
code
=
tsdbWriteDelData
(
pWriter
->
pDelFWriter
,
pWriter
->
aDelData
,
&
delIdx
);
if
(
code
)
goto
_err
;
...
...
@@ -1095,11 +1093,9 @@ _err:
tstrerror
(
code
));
return
code
;
}
#endif
int32_t
tsdbSnapWriterOpen
(
STsdb
*
pTsdb
,
int64_t
sver
,
int64_t
ever
,
STsdbSnapWriter
**
ppWriter
)
{
int32_t
code
=
0
;
#if 0
int32_t
code
=
0
;
STsdbSnapWriter
*
pWriter
=
NULL
;
// alloc
...
...
@@ -1168,7 +1164,6 @@ _err:
tsdbError
(
"vgId:%d, tsdb snapshot writer open for %s failed since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
pTsdb
->
path
,
tstrerror
(
code
));
*
ppWriter
=
NULL
;
#endif
return
code
;
}
...
...
@@ -1210,10 +1205,10 @@ _err:
}
int32_t
tsdbSnapWrite
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
#if 0
int32_t
code
=
0
;
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
#if 0
// ts data
if (pHdr->type == SNAP_DATA_TSDB) {
code = tsdbSnapWriteData(pWriter, pData, nData);
...
...
@@ -1226,6 +1221,7 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
if (code) goto _err;
}
}
#endif
// del data
if
(
pHdr
->
type
==
SNAP_DATA_DEL
)
{
...
...
@@ -1241,6 +1237,5 @@ _exit:
_err:
tsdbError
(
"vgId:%d, tsdb snapshot write for %s failed since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
pWriter
->
pTsdb
->
path
,
tstrerror
(
code
));
#endif
return
code
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录