Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
58374208
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
58374208
编写于
7月 13, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more vnode snapshot writer
上级
eaa0a428
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
103 addition
and
74 deletion
+103
-74
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+7
-7
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+6
-6
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+14
-14
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+37
-13
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+2
-2
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+35
-30
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
58374208
...
...
@@ -24,12 +24,12 @@ extern "C" {
// tsdbDebug ================
// clang-format off
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSD
B
FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSD
B
ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSD
B
WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSD
B
", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSD
B
", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSD
B
", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSD FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSD ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSD WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSD ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSD ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSD ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
typedef
struct
TSDBROW
TSDBROW
;
...
...
@@ -137,7 +137,7 @@ int32_t tBlockDataInit(SBlockData *pBlockData);
void
tBlockDataReset
(
SBlockData
*
pBlockData
);
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
);
void
tBlockDataClearData
(
SBlockData
*
pBlockData
);
void
tBlockDataClear
(
SBlockData
*
pBlockData
);
void
tBlockDataClear
(
SBlockData
*
pBlockData
,
int8_t
deepClear
);
int32_t
tBlockDataAddColData
(
SBlockData
*
pBlockData
,
int32_t
iColData
,
SColData
**
ppColData
);
int32_t
tBlockDataAppendRow
(
SBlockData
*
pBlockData
,
TSDBROW
*
pRow
,
STSchema
*
pTSchema
);
int32_t
tBlockDataMerge
(
SBlockData
*
pBlockData1
,
SBlockData
*
pBlockData2
,
SBlockData
*
pBlockData
);
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
58374208
...
...
@@ -476,9 +476,9 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
if
(
--
state
->
iFileSet
>=
0
)
{
pFileSet
=
(
SDFileSet
*
)
taosArrayGet
(
state
->
aDFileSet
,
state
->
iFileSet
);
}
else
{
// tBlockDataClear(&state->blockData);
// tBlockDataClear(&state->blockData
, 1
);
if
(
state
->
pBlockData
)
{
tBlockDataClear
(
state
->
pBlockData
);
tBlockDataClear
(
state
->
pBlockData
,
1
);
state
->
pBlockData
=
NULL
;
}
...
...
@@ -582,8 +582,8 @@ _err:
state
->
aBlockIdx
=
NULL
;
}
if
(
state
->
pBlockData
)
{
// tBlockDataClear(&state->blockData);
tBlockDataClear
(
state
->
pBlockData
);
// tBlockDataClear(&state->blockData
, 1
);
tBlockDataClear
(
state
->
pBlockData
,
1
);
state
->
pBlockData
=
NULL
;
}
...
...
@@ -609,8 +609,8 @@ int32_t clearNextRowFromFS(void *iter) {
state
->
aBlockIdx
=
NULL
;
}
if
(
state
->
pBlockData
)
{
// tBlockDataClear(&state->blockData);
tBlockDataClear
(
state
->
pBlockData
);
// tBlockDataClear(&state->blockData
, 1
);
tBlockDataClear
(
state
->
pBlockData
,
1
);
state
->
pBlockData
=
NULL
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
58374208
...
...
@@ -1001,10 +1001,10 @@ _exit:
static
void
tsdbCommitDataEnd
(
SCommitter
*
pCommitter
)
{
taosArrayDestroy
(
pCommitter
->
aBlockIdx
);
tMapDataClear
(
&
pCommitter
->
oBlockMap
);
tBlockDataClear
(
&
pCommitter
->
oBlockData
);
tBlockDataClear
(
&
pCommitter
->
oBlockData
,
1
);
taosArrayDestroy
(
pCommitter
->
aBlockIdxN
);
tMapDataClear
(
&
pCommitter
->
nBlockMap
);
tBlockDataClear
(
&
pCommitter
->
nBlockData
);
tBlockDataClear
(
&
pCommitter
->
nBlockData
,
1
);
tTSchemaDestroy
(
pCommitter
->
skmTable
.
pTSchema
);
tTSchemaDestroy
(
pCommitter
->
skmRow
.
pTSchema
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
58374208
...
...
@@ -979,21 +979,21 @@ int32_t tsdbReadColData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *pBl
code
=
tBlockDataCopy
(
pBlockData
,
pBlockData2
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
goto
_err
;
}
code
=
tBlockDataMerge
(
pBlockData1
,
pBlockData2
,
pBlockData
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
goto
_err
;
}
}
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
}
tFree
(
pBuf1
);
...
...
@@ -1115,29 +1115,29 @@ int32_t tsdbReadBlockData(SDataFReader *pReader, SBlockIdx *pBlockIdx, SBlock *p
for
(
iSubBlock
=
1
;
iSubBlock
<
pBlock
->
nSubBlock
;
iSubBlock
++
)
{
code
=
tsdbReadSubBlockData
(
pReader
,
pBlockIdx
,
pBlock
,
iSubBlock
,
pBlockData1
,
ppBuf1
,
ppBuf2
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
goto
_err
;
}
code
=
tBlockDataCopy
(
pBlockData
,
pBlockData2
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
goto
_err
;
}
// merge two block data
code
=
tBlockDataMerge
(
pBlockData1
,
pBlockData2
,
pBlockData
);
if
(
code
)
{
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
goto
_err
;
}
}
tBlockDataClear
(
pBlockData1
);
tBlockDataClear
(
pBlockData2
);
tBlockDataClear
(
pBlockData1
,
1
);
tBlockDataClear
(
pBlockData2
,
1
);
}
ASSERT
(
pBlock
->
nRow
==
pBlockData
->
nRow
);
...
...
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
58374208
...
...
@@ -296,8 +296,8 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
}
taosArrayDestroy
(
pReader
->
aBlockIdx
);
tMapDataClear
(
&
pReader
->
mBlock
);
tBlockDataClear
(
&
pReader
->
oBlockData
);
tBlockDataClear
(
&
pReader
->
nBlockData
);
tBlockDataClear
(
&
pReader
->
oBlockData
,
1
);
tBlockDataClear
(
&
pReader
->
nBlockData
,
1
);
if
(
pReader
->
pDelFReader
)
{
tsdbDelFReaderClose
(
&
pReader
->
pDelFReader
);
...
...
@@ -555,11 +555,21 @@ _err:
}
static
int32_t
tsdbSnapWriteData
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pWriter
->
pTsdb
;
int64_t
skey
;
// todo
int64_t
ekey
;
// todo
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pWriter
->
pTsdb
;
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
TABLEID
id
=
*
(
TABLEID
*
)(
&
pHdr
[
1
]);
int64_t
n
;
SBlockData
bData
=
{
0
};
SBlockData
*
pBlockData
=
&
bData
;
// decode
code
=
tBlockDataInit
(
pBlockData
);
if
(
code
)
goto
_err
;
n
=
tGetBlockData
(
pData
+
sizeof
(
SSnapDataHdr
)
+
sizeof
(
TABLEID
),
pBlockData
);
ASSERT
(
n
+
sizeof
(
SSnapDataHdr
)
+
sizeof
(
TABLEID
)
==
nData
);
#if 0
int32_t fid = tsdbKeyFid(skey, pWriter->minutes, pWriter->precision);
ASSERT(fid == tsdbKeyFid(ekey, pWriter->minutes, pWriter->precision));
...
...
@@ -600,7 +610,10 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
code = tsdbSnapWriteTableData(pWriter, pData, nData);
if (code) goto _err;
#endif
tsdbInfo
(
"vgId:%d vnode snapshot tsdb write data, suid:%"
PRId64
" uid:%"
PRId64
" nRow:%d"
,
TD_VID
(
pTsdb
->
pVnode
),
id
.
suid
,
id
.
suid
,
pBlockData
->
nRow
);
return
code
;
_err:
...
...
@@ -755,6 +768,12 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
pWriter
->
sver
=
sver
;
pWriter
->
ever
=
ever
;
pWriter
->
minutes
=
pTsdb
->
keepCfg
.
days
;
pWriter
->
precision
=
pTsdb
->
keepCfg
.
precision
;
pWriter
->
minRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
minRows
;
pWriter
->
maxRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
;
pWriter
->
cmprAlg
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
compression
;
*
ppWriter
=
pWriter
;
return
code
;
...
...
@@ -793,24 +812,29 @@ _err:
}
int32_t
tsdbSnapWrite
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
int8_t
type
=
pData
[
0
]
;
int32_t
code
=
0
;
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
// ts data
if
(
type
==
0
)
{
code
=
tsdbSnapWriteData
(
pWriter
,
pData
+
1
,
nData
-
1
);
if
(
pHdr
->
type
==
1
)
{
code
=
tsdbSnapWriteData
(
pWriter
,
pData
,
nData
);
if
(
code
)
goto
_err
;
goto
_exit
;
}
else
{
code
=
tsdbSnapWriteDataEnd
(
pWriter
);
if
(
code
)
goto
_err
;
if
(
pWriter
->
pDataFWriter
)
{
code
=
tsdbSnapWriteDataEnd
(
pWriter
);
if
(
code
)
goto
_err
;
}
}
// del data
if
(
type
==
1
)
{
if
(
pHdr
->
type
==
2
)
{
code
=
tsdbSnapWriteDel
(
pWriter
,
pData
+
1
,
nData
-
1
);
if
(
code
)
goto
_err
;
}
_exit:
return
code
;
_err:
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
58374208
...
...
@@ -1032,11 +1032,11 @@ void tBlockDataReset(SBlockData *pBlockData) {
taosArrayClear
(
pBlockData
->
aIdx
);
}
void
tBlockDataClear
(
SBlockData
*
pBlockData
)
{
void
tBlockDataClear
(
SBlockData
*
pBlockData
,
int8_t
deepClear
)
{
tFree
((
uint8_t
*
)
pBlockData
->
aVersion
);
tFree
((
uint8_t
*
)
pBlockData
->
aTSKEY
);
taosArrayDestroy
(
pBlockData
->
aIdx
);
taosArrayDestroyEx
(
pBlockData
->
aColData
,
tColDataClear
);
taosArrayDestroyEx
(
pBlockData
->
aColData
,
deepClear
?
tColDataClear
:
NULL
);
}
int32_t
tBlockDataSetSchema
(
SBlockData
*
pBlockData
,
STSchema
*
pTSchema
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
58374208
...
...
@@ -176,7 +176,6 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
pWriter
->
ever
=
ever
;
vInfo
(
"vgId:%d vnode snapshot writer opened"
,
TD_VID
(
pVnode
));
*
ppWriter
=
pWriter
;
return
code
;
...
...
@@ -189,15 +188,15 @@ _err:
int32_t
vnodeSnapWriterClose
(
SVSnapWriter
*
pWriter
,
int8_t
rollback
)
{
int32_t
code
=
0
;
goto
_exit
;
// TODO
if
(
rollback
)
{
code
=
vnodeSnapRollback
(
pWriter
);
if
(
code
)
goto
_err
;
}
else
{
code
=
vnodeSnapCommit
(
pWriter
);
if
(
code
)
goto
_err
;
}
//
if (rollback) {
//
code = vnodeSnapRollback(pWriter);
//
if (code) goto _err;
//
} else {
//
code = vnodeSnapCommit(pWriter);
//
if (code) goto _err;
//
}
_exit:
vInfo
(
"vgId:%d vnode snapshot writer closed, rollback:%d"
,
TD_VID
(
pWriter
->
pVnode
),
rollback
);
...
...
@@ -214,34 +213,40 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
SVnode
*
pVnode
=
pWriter
->
pVnode
;
// ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
ASSERT
(
pHdr
->
size
+
sizeof
(
SSnapDataHdr
)
==
nData
);
ASSERT
(
pHdr
->
index
==
pWriter
->
index
+
1
);
pWriter
->
index
=
pHdr
->
index
;
// if (pHdr->type == 0) {
// // meta
// if (pWriter->pMetaSnapWriter == NULL) {
// code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter);
// if (code) goto _err;
// }
vInfo
(
"vgId:%d vnode snapshot write data, index:%"
PRId64
" type:%d nData:%d"
,
TD_VID
(
pVnode
),
pHdr
->
index
,
pHdr
->
type
,
nData
);
// code = metaSnapWrite(pWriter->pMetaSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
// if (code) goto _err;
// } else {
// // tsdb
// if (pWriter->pTsdbSnapWriter == NULL) {
// code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter);
// if (code) goto _err;
// }
if
(
pHdr
->
type
==
0
)
{
// meta
// code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
// if (code) goto _err;
// }
// if (pWriter->pMetaSnapWriter == NULL) {
// code = metaSnapWriterOpen(pVnode->pMeta, pWriter->sver, pWriter->ever, &pWriter->pMetaSnapWriter);
// if (code) goto _err;
// }
// code = metaSnapWrite(pWriter->pMetaSnapWriter, pData , nData);
// if (code) goto _err;
}
else
{
// tsdb
if
(
pWriter
->
pTsdbSnapWriter
==
NULL
)
{
code
=
tsdbSnapWriterOpen
(
pVnode
->
pTsdb
,
pWriter
->
sver
,
pWriter
->
ever
,
&
pWriter
->
pTsdbSnapWriter
);
if
(
code
)
goto
_err
;
}
code
=
tsdbSnapWrite
(
pWriter
->
pTsdbSnapWriter
,
pData
,
nData
);
if
(
code
)
goto
_err
;
}
_exit:
vInfo
(
"vgId:%d vnode snapshot write data, index:%"
PRId64
" type:%d nData:%d"
,
TD_VID
(
pVnode
),
pHdr
->
index
,
pHdr
->
type
,
nData
);
return
code
;
_err:
vError
(
"vgId:%d vnode snapshot write failed since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
code
));
vError
(
"vgId:%d vnode snapshot write failed since %s, index:%"
PRId64
" type:%d nData:%d"
,
TD_VID
(
pVnode
),
tstrerror
(
code
),
pHdr
->
index
,
pHdr
->
type
,
nData
);
return
code
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录