Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
47a75227
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47a75227
编写于
6月 28, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/feat/tsdb_refact' into feat/tsdb_refact
# Conflicts: # source/dnode/vnode/src/vnd/vnodeSvr.c
上级
4a59e130
3ba5d8e9
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
230 addition
and
533 deletion
+230
-533
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+11
-13
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+102
-416
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+2
-8
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+114
-87
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+0
-8
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-1
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
47a75227
...
@@ -236,14 +236,14 @@ int32_t tsdbReadBlockSMA(SDataFReader *pReader, SBlockSMA *pBlkSMA);
...
@@ -236,14 +236,14 @@ int32_t tsdbReadBlockSMA(SDataFReader *pReader, SBlockSMA *pBlkSMA);
// SDelFWriter
// SDelFWriter
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
);
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
);
int32_t
tsdbDelFWriterClose
(
SDelFWriter
*
pWriter
,
int8_t
sync
);
int32_t
tsdbDelFWriterClose
(
SDelFWriter
*
pWriter
,
int8_t
sync
);
int32_t
tsdbWriteDelData
(
SDelFWriter
*
pWriter
,
S
MapData
*
pDelDataMap
,
uint8_t
**
ppBuf
,
SDelIdx
*
pDelIdx
);
int32_t
tsdbWriteDelData
(
SDelFWriter
*
pWriter
,
S
Array
*
aDelData
,
uint8_t
**
ppBuf
,
SDelIdx
*
pDelIdx
);
int32_t
tsdbWriteDelIdx
(
SDelFWriter
*
pWriter
,
S
MapData
*
pDelIdxMap
,
uint8_t
**
ppBuf
);
int32_t
tsdbWriteDelIdx
(
SDelFWriter
*
pWriter
,
S
Array
*
aDelIdx
,
uint8_t
**
ppBuf
);
int32_t
tsdbUpdateDelFileHdr
(
SDelFWriter
*
pWriter
,
uint8_t
**
ppBuf
);
int32_t
tsdbUpdateDelFileHdr
(
SDelFWriter
*
pWriter
);
// SDelFReader
// SDelFReader
int32_t
tsdbDelFReaderOpen
(
SDelFReader
**
ppReader
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
,
uint8_t
**
ppBuf
);
int32_t
tsdbDelFReaderOpen
(
SDelFReader
**
ppReader
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
,
uint8_t
**
ppBuf
);
int32_t
tsdbDelFReaderClose
(
SDelFReader
*
pReader
);
int32_t
tsdbDelFReaderClose
(
SDelFReader
*
pReader
);
int32_t
tsdbReadDelData
(
SDelFReader
*
pReader
,
SDelIdx
*
pDelIdx
,
S
MapData
*
pDelDataMap
,
uint8_t
**
ppBuf
);
int32_t
tsdbReadDelData
(
SDelFReader
*
pReader
,
SDelIdx
*
pDelIdx
,
S
Array
*
aDelData
,
uint8_t
**
ppBuf
);
int32_t
tsdbReadDelIdx
(
SDelFReader
*
pReader
,
S
MapData
*
pDelIdxMap
,
uint8_t
**
ppBuf
);
int32_t
tsdbReadDelIdx
(
SDelFReader
*
pReader
,
S
Array
*
aDelIdx
,
uint8_t
**
ppBuf
);
// tsdbCache
// tsdbCache
int32_t
tsdbOpenCache
(
STsdb
*
pTsdb
);
int32_t
tsdbOpenCache
(
STsdb
*
pTsdb
);
...
@@ -464,20 +464,12 @@ struct SDelData {
...
@@ -464,20 +464,12 @@ struct SDelData {
struct
SDelIdx
{
struct
SDelIdx
{
tb_uid_t
suid
;
tb_uid_t
suid
;
tb_uid_t
uid
;
tb_uid_t
uid
;
TSKEY
minKey
;
TSKEY
maxKey
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
offset
;
int64_t
offset
;
int64_t
size
;
int64_t
size
;
};
};
struct
SDelFile
{
struct
SDelFile
{
int64_t
commitID
;
int64_t
commitID
;
TSKEY
minKey
;
TSKEY
maxKey
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
size
;
int64_t
size
;
int64_t
offset
;
int64_t
offset
;
};
};
...
@@ -561,6 +553,12 @@ struct STsdbFS {
...
@@ -561,6 +553,12 @@ struct STsdbFS {
STsdbFSState
*
nState
;
STsdbFSState
*
nState
;
};
};
struct
SDelFWriter
{
STsdb
*
pTsdb
;
SDelFile
fDel
;
TdFilePtr
pWriteH
;
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
47a75227
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
47a75227
...
@@ -283,10 +283,7 @@ void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) {
...
@@ -283,10 +283,7 @@ void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) {
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelFile
->
minKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
commitID
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelFile
->
maxKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
minVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
maxVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
size
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
size
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelFile
->
offset
);
...
@@ -296,10 +293,7 @@ int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile) {
...
@@ -296,10 +293,7 @@ int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile) {
int32_t
tGetDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
int32_t
tGetDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
int32_t
n
=
0
;
int32_t
n
=
0
;
n
+=
tGetI64
(
p
+
n
,
&
pDelFile
->
minKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
commitID
);
n
+=
tGetI64
(
p
+
n
,
&
pDelFile
->
maxKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
minVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
maxVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
size
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
size
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelFile
->
offset
);
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
47a75227
...
@@ -18,43 +18,45 @@
...
@@ -18,43 +18,45 @@
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
// SDelFWriter ====================================================
// SDelFWriter ====================================================
struct
SDelFWriter
{
STsdb
*
pTsdb
;
SDelFile
*
pFile
;
TdFilePtr
pWriteH
;
};
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
)
{
int32_t
tsdbDelFWriterOpen
(
SDelFWriter
**
ppWriter
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
char
*
fname
=
NULL
;
// TODO
char
fname
[
TSDB_FILENAME_LEN
];
char
hdr
[
TSDB_FHDR_SIZE
]
=
{
0
};
SDelFWriter
*
pDelFWriter
;
SDelFWriter
*
pDelFWriter
;
int64_t
n
;
// alloc
pDelFWriter
=
(
SDelFWriter
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pDelFWriter
));
pDelFWriter
=
(
SDelFWriter
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pDelFWriter
));
if
(
pDelFWriter
==
NULL
)
{
if
(
pDelFWriter
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
pDelFWriter
->
pTsdb
=
pTsdb
;
pDelFWriter
->
pTsdb
=
pTsdb
;
pDelFWriter
->
pFile
=
pFile
;
pDelFWriter
->
fDel
=
*
pFile
;
tsdbDelFileName
(
pTsdb
,
pFile
,
fname
);
pDelFWriter
->
pWriteH
=
taosOpenFile
(
fname
,
TD_FILE_WRITE
|
TD_FILE_CREATE
);
pDelFWriter
->
pWriteH
=
taosOpenFile
(
fname
,
TD_FILE_WRITE
|
TD_FILE_CREATE
);
if
(
pDelFWriter
->
pWriteH
==
NULL
)
{
if
(
pDelFWriter
->
pWriteH
==
NULL
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
}
if
(
taosLSeekFile
(
pDelFWriter
->
pWriteH
,
TSDB_FHDR_SIZE
,
SEEK_SET
)
<
0
)
{
// update header
n
=
taosWriteFile
(
pDelFWriter
->
pWriteH
,
&
hdr
,
TSDB_FHDR_SIZE
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
}
pDelFWriter
->
pFile
->
size
=
TSDB_FHDR_SIZE
;
pDelFWriter
->
fDel
.
size
=
TSDB_FHDR_SIZE
;
pDelFWriter
->
pFile
->
offset
=
0
;
pDelFWriter
->
fDel
.
size
=
0
;
*
ppWriter
=
pDelFWriter
;
return
code
;
return
code
;
_err:
_err:
tsdbError
(
"vgId:%d failed to open del file writer since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d failed to open del file writer since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
tstrerror
(
code
));
*
ppWriter
=
NULL
;
return
code
;
return
code
;
}
}
...
@@ -80,28 +82,33 @@ _err:
...
@@ -80,28 +82,33 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbWriteDelData
(
SDelFWriter
*
pWriter
,
SMapData
*
pDelDataMap
,
uint8_t
**
ppBuf
,
SDelIdx
*
pDelIdx
)
{
int32_t
tsdbWriteDelData
(
SDelFWriter
*
pWriter
,
SArray
*
aDelData
,
uint8_t
**
ppBuf
,
SDelIdx
*
pDelIdx
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
uint8_t
*
pBuf
=
NULL
;
uint8_t
*
pBuf
=
NULL
;
int64_t
size
=
0
;
int64_t
size
;
int64_t
n
=
0
;
int64_t
n
;
SBlockDataHdr
hdr
=
{.
delimiter
=
TSDB_FILE_DLMT
,
.
suid
=
pDelIdx
->
suid
,
.
uid
=
pDelIdx
->
uid
};
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
// prepare
// prepare
size
+=
tPutU32
(
NULL
,
TSDB_FILE_DLMT
);
size
=
sizeof
(
hdr
);
size
+=
tPutI64
(
NULL
,
pDelIdx
->
suid
);
for
(
int32_t
iDelData
=
0
;
iDelData
<
taosArrayGetSize
(
aDelData
);
iDelData
++
)
{
size
+=
tPutI64
(
NULL
,
pDelIdx
->
uid
);
size
+=
tPutDelData
(
NULL
,
taosArrayGet
(
aDelData
,
iDelData
));
size
=
size
+
tPutMapData
(
NULL
,
pDelDataMap
)
+
sizeof
(
TSCKSUM
);
}
size
+=
sizeof
(
TSCKSUM
);
// alloc
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
code
=
tsdbRealloc
(
ppBuf
,
size
);
code
=
tsdbRealloc
(
ppBuf
,
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// build
// build
n
+=
tPutU32
(
*
ppBuf
+
n
,
TSDB_FILE_DLMT
);
n
=
0
;
n
+=
tPutI64
(
*
ppBuf
+
n
,
pDelIdx
->
suid
);
*
(
SBlockDataHdr
*
)(
*
ppBuf
)
=
hdr
;
n
+=
tPutI64
(
*
ppBuf
+
n
,
pDelIdx
->
uid
);
n
+=
sizeof
(
hdr
);
n
+=
tPutMapData
(
*
ppBuf
+
n
,
pDelDataMap
);
for
(
int32_t
iDelData
=
0
;
iDelData
<
taosArrayGetSize
(
aDelData
);
iDelData
++
)
{
size
+=
tPutDelData
(
*
ppBuf
+
n
,
taosArrayGet
(
aDelData
,
iDelData
));
}
taosCalcChecksumAppend
(
0
,
*
ppBuf
,
size
);
taosCalcChecksumAppend
(
0
,
*
ppBuf
,
size
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
...
@@ -116,10 +123,9 @@ int32_t tsdbWriteDelData(SDelFWriter *pWriter, SMapData *pDelDataMap, uint8_t **
...
@@ -116,10 +123,9 @@ int32_t tsdbWriteDelData(SDelFWriter *pWriter, SMapData *pDelDataMap, uint8_t **
ASSERT
(
n
==
size
);
ASSERT
(
n
==
size
);
// update
// update
pDelIdx
->
offset
=
pWriter
->
pFile
->
size
;
pDelIdx
->
offset
=
pWriter
->
fDel
.
size
;
pDelIdx
->
size
=
size
;
pDelIdx
->
size
=
size
;
pWriter
->
pFile
->
offset
=
pWriter
->
pFile
->
size
;
pWriter
->
fDel
.
size
+=
size
;
pWriter
->
pFile
->
size
+=
size
;
tsdbFree
(
pBuf
);
tsdbFree
(
pBuf
);
return
code
;
return
code
;
...
@@ -130,24 +136,33 @@ _err:
...
@@ -130,24 +136,33 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbWriteDelIdx
(
SDelFWriter
*
pWriter
,
S
MapData
*
pDelIdxMap
,
uint8_t
**
ppBuf
)
{
int32_t
tsdbWriteDelIdx
(
SDelFWriter
*
pWriter
,
S
Array
*
aDelIdx
,
uint8_t
**
ppBuf
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int64_t
size
=
0
;
int64_t
size
;
int64_t
n
=
0
;
int64_t
n
;
uint8_t
*
pBuf
=
NULL
;
uint8_t
*
pBuf
=
NULL
;
SDelIdx
*
pDelIdx
;
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
// prepare
// prepare
size
=
0
;
size
+=
tPutU32
(
NULL
,
TSDB_FILE_DLMT
);
size
+=
tPutU32
(
NULL
,
TSDB_FILE_DLMT
);
size
=
size
+
tPutMapData
(
NULL
,
pDelIdxMap
)
+
sizeof
(
TSCKSUM
);
for
(
int32_t
iDelIdx
=
0
;
iDelIdx
<
taosArrayGetSize
(
aDelIdx
);
iDelIdx
++
)
{
size
+=
tPutDelIdx
(
NULL
,
taosArrayGet
(
aDelIdx
,
iDelIdx
));
}
size
+=
sizeof
(
TSCKSUM
);
// alloc
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
code
=
tsdbRealloc
(
ppBuf
,
size
);
code
=
tsdbRealloc
(
ppBuf
,
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// build
// build
n
=
0
;
n
+=
tPutU32
(
*
ppBuf
+
n
,
TSDB_FILE_DLMT
);
n
+=
tPutU32
(
*
ppBuf
+
n
,
TSDB_FILE_DLMT
);
n
+=
tPutMapData
(
*
ppBuf
+
n
,
pDelIdxMap
);
for
(
int32_t
iDelIdx
=
0
;
iDelIdx
<
taosArrayGetSize
(
aDelIdx
);
iDelIdx
++
)
{
n
+=
tPutDelIdx
(
*
ppBuf
+
n
,
taosArrayGet
(
aDelIdx
,
iDelIdx
));
}
taosCalcChecksumAppend
(
0
,
*
ppBuf
,
size
);
taosCalcChecksumAppend
(
0
,
*
ppBuf
,
size
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
...
@@ -159,11 +174,9 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SMapData *pDelIdxMap, uint8_t **pp
...
@@ -159,11 +174,9 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SMapData *pDelIdxMap, uint8_t **pp
goto
_err
;
goto
_err
;
}
}
ASSERT
(
n
==
size
);
// update
// update
pWriter
->
pFile
->
offset
=
pWriter
->
pFile
->
size
;
pWriter
->
fDel
.
offset
=
pWriter
->
fDel
.
size
;
pWriter
->
pFile
->
size
+=
size
;
pWriter
->
fDel
.
size
+=
size
;
tsdbFree
(
pBuf
);
tsdbFree
(
pBuf
);
return
code
;
return
code
;
...
@@ -174,23 +187,16 @@ _err:
...
@@ -174,23 +187,16 @@ _err:
return
code
;
return
code
;
}
}
int32_t
tsdbUpdateDelFileHdr
(
SDelFWriter
*
pWriter
,
uint8_t
**
ppBuf
)
{
int32_t
tsdbUpdateDelFileHdr
(
SDelFWriter
*
pWriter
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
uint8_t
*
pBuf
=
NULL
;
char
hdr
[
TSDB_FHDR_SIZE
];
int64_t
size
=
TSDB_FHDR_SIZE
;
int64_t
size
=
TSDB_FHDR_SIZE
;
int64_t
n
;
int64_t
n
;
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
code
=
tsdbRealloc
(
ppBuf
,
size
);
if
(
code
)
goto
_err
;
// build
// build
memset
(
*
ppBuf
,
0
,
size
);
memset
(
hdr
,
0
,
size
);
n
=
tPutDelFile
(
*
ppBuf
,
pWriter
->
pFile
);
tPutDelFile
(
hdr
,
&
pWriter
->
fDel
);
taosCalcChecksumAppend
(
0
,
*
ppBuf
,
size
);
taosCalcChecksumAppend
(
0
,
hdr
,
size
);
ASSERT
(
n
<=
size
-
sizeof
(
TSCKSUM
));
// seek
// seek
if
(
taosLSeekFile
(
pWriter
->
pWriteH
,
0
,
SEEK_SET
)
<
0
)
{
if
(
taosLSeekFile
(
pWriter
->
pWriteH
,
0
,
SEEK_SET
)
<
0
)
{
...
@@ -199,30 +205,29 @@ int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter, uint8_t **ppBuf) {
...
@@ -199,30 +205,29 @@ int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter, uint8_t **ppBuf) {
}
}
// write
// write
if
(
taosWriteFile
(
pWriter
->
pWriteH
,
*
ppBuf
,
size
)
<
size
)
{
n
=
taosWriteFile
(
pWriter
->
pWriteH
,
hdr
,
size
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
}
tsdbFree
(
pBuf
);
return
code
;
return
code
;
_err:
_err:
tsdbError
(
"vgId:%d update del file hdr failed since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d update del file hdr failed since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbFree
(
pBuf
);
return
code
;
return
code
;
}
}
// SDelFReader ====================================================
// SDelFReader ====================================================
struct
SDelFReader
{
struct
SDelFReader
{
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SDelFile
*
pFile
;
SDelFile
fDel
;
TdFilePtr
pReadH
;
TdFilePtr
pReadH
;
};
};
int32_t
tsdbDelFReaderOpen
(
SDelFReader
**
ppReader
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
,
uint8_t
**
ppBuf
)
{
int32_t
tsdbDelFReaderOpen
(
SDelFReader
**
ppReader
,
SDelFile
*
pFile
,
STsdb
*
pTsdb
,
uint8_t
**
ppBuf
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
char
*
fname
=
NULL
;
// todo
char
fname
[
TSDB_FILENAME_LEN
];
SDelFReader
*
pDelFReader
;
SDelFReader
*
pDelFReader
;
int64_t
n
;
int64_t
n
;
...
@@ -235,7 +240,9 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
...
@@ -235,7 +240,9 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
// open impl
// open impl
pDelFReader
->
pTsdb
=
pTsdb
;
pDelFReader
->
pTsdb
=
pTsdb
;
pDelFReader
->
pFile
=
pFile
;
pDelFReader
->
fDel
=
*
pFile
;
tsdbDelFileName
(
pTsdb
,
pFile
,
fname
);
pDelFReader
->
pReadH
=
taosOpenFile
(
fname
,
TD_FILE_READ
);
pDelFReader
->
pReadH
=
taosOpenFile
(
fname
,
TD_FILE_READ
);
if
(
pDelFReader
==
NULL
)
{
if
(
pDelFReader
==
NULL
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -243,6 +250,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
...
@@ -243,6 +250,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
goto
_err
;
goto
_err
;
}
}
#if 0
// load and check hdr if buffer is given
// load and check hdr if buffer is given
if (ppBuf) {
if (ppBuf) {
code = tsdbRealloc(ppBuf, TSDB_FHDR_SIZE);
code = tsdbRealloc(ppBuf, TSDB_FHDR_SIZE);
...
@@ -266,6 +274,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
...
@@ -266,6 +274,7 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
// TODO: check the content
// TODO: check the content
}
}
#endif
_exit:
_exit:
*
ppReader
=
pDelFReader
;
*
ppReader
=
pDelFReader
;
...
@@ -292,66 +301,75 @@ _exit:
...
@@ -292,66 +301,75 @@ _exit:
return
code
;
return
code
;
}
}
int32_t
tsdbReadDelData
(
SDelFReader
*
pReader
,
SDelIdx
*
pDelIdx
,
SMapData
*
pDelDataMap
,
uint8_t
**
ppBuf
)
{
int32_t
tsdbReadDelData
(
SDelFReader
*
pReader
,
SDelIdx
*
pDelIdx
,
SArray
*
aDelData
,
uint8_t
**
ppBuf
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int64_t
n
;
int64_t
offset
=
pDelIdx
->
offset
;
uint32_t
delimiter
;
int64_t
size
=
pDelIdx
->
size
;
tb_uid_t
suid
;
int64_t
n
;
tb_uid_t
uid
;
uint8_t
*
pBuf
=
NULL
;
SBlockDataHdr
*
pHdr
;
SDelData
*
pDelData
=
&
(
SDelData
){
0
};
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
// seek
// seek
if
(
taosLSeekFile
(
pReader
->
pReadH
,
pDelIdx
->
offset
,
SEEK_SET
)
<
0
)
{
if
(
taosLSeekFile
(
pReader
->
pReadH
,
offset
,
SEEK_SET
)
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
}
// alloc
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pDelDataMap
->
pBuf
;
code
=
tsdbRealloc
(
ppBuf
,
size
);
code
=
tsdbRealloc
(
ppBuf
,
pDelIdx
->
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
// read
// read
n
=
taosReadFile
(
pReader
->
pReadH
,
*
ppBuf
,
pDelIdx
->
size
);
n
=
taosReadFile
(
pReader
->
pReadH
,
*
ppBuf
,
size
);
if
(
n
<
0
)
{
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
goto
_err
;
}
else
if
(
n
<
pDelIdx
->
size
)
{
}
else
if
(
n
<
size
)
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
goto
_err
;
}
}
// check
// check
if
(
!
taosCheckChecksumWhole
(
*
ppBuf
,
pDelIdx
->
size
))
{
if
(
!
taosCheckChecksumWhole
(
*
ppBuf
,
size
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
goto
_err
;
}
}
// // decode
// // decode
n
=
0
;
n
=
0
;
n
+=
tGetU32
(
*
ppBuf
+
n
,
&
delimiter
);
pHdr
=
(
SBlockDataHdr
*
)(
*
ppBuf
+
n
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
ASSERT
(
pHdr
->
delimiter
==
TSDB_FILE_DLMT
);
n
+=
tGetI64
(
*
ppBuf
+
n
,
&
suid
);
ASSERT
(
pHdr
->
suid
==
pDelIdx
->
suid
);
ASSERT
(
suid
==
pDelIdx
->
suid
);
ASSERT
(
pHdr
->
uid
==
pDelIdx
->
uid
);
n
+=
tGetI64
(
*
ppBuf
+
n
,
&
uid
);
n
+=
sizeof
(
*
pHdr
);
ASSERT
(
uid
==
pDelIdx
->
uid
);
while
(
n
<
size
-
sizeof
(
TSCKSUM
))
{
n
+=
tGetMapData
(
*
ppBuf
+
n
,
pDelDataMap
);
n
+=
tGetDelData
(
*
ppBuf
+
n
,
pDelData
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
pDelIdx
->
size
);
}
ASSERT
(
n
==
size
-
sizeof
(
TSCKSUM
));
tsdbFree
(
pBuf
);
return
code
;
return
code
;
_err:
_err:
tsdbError
(
"vgId:%d read del data failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbError
(
"vgId:%d read del data failed since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
tsdbFree
(
pBuf
);
return
code
;
return
code
;
}
}
int32_t
tsdbReadDelIdx
(
SDelFReader
*
pReader
,
S
MapData
*
pDelIdxMap
,
uint8_t
**
ppBuf
)
{
int32_t
tsdbReadDelIdx
(
SDelFReader
*
pReader
,
S
Array
*
aDelIdx
,
uint8_t
**
ppBuf
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
n
;
int32_t
n
;
int64_t
offset
=
pReader
->
pFile
->
offset
;
int64_t
offset
=
pReader
->
fDel
.
offset
;
int64_t
size
=
pReader
->
pFile
->
size
-
offset
;
int64_t
size
=
pReader
->
fDel
.
size
-
offset
;
uint32_t
delimiter
;
uint32_t
delimiter
;
uint8_t
*
pBuf
=
NULL
;
SDelIdx
*
pDelIdx
=
&
(
SDelIdx
){};
ASSERT
(
ppBuf
&&
*
ppBuf
)
;
if
(
!
ppBuf
)
ppBuf
=
&
pBuf
;
// seek
// seek
if
(
taosLSeekFile
(
pReader
->
pReadH
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
taosLSeekFile
(
pReader
->
pReadH
,
offset
,
SEEK_SET
)
<
0
)
{
...
@@ -360,7 +378,6 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SMapData *pDelIdxMap, uint8_t **ppB
...
@@ -360,7 +378,6 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SMapData *pDelIdxMap, uint8_t **ppB
}
}
// alloc
// alloc
if
(
!
ppBuf
)
ppBuf
=
&
pDelIdxMap
->
pBuf
;
code
=
tsdbRealloc
(
ppBuf
,
size
);
code
=
tsdbRealloc
(
ppBuf
,
size
);
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
...
@@ -384,8 +401,18 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SMapData *pDelIdxMap, uint8_t **ppB
...
@@ -384,8 +401,18 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SMapData *pDelIdxMap, uint8_t **ppB
n
=
0
;
n
=
0
;
n
+=
tGetU32
(
*
ppBuf
+
n
,
&
delimiter
);
n
+=
tGetU32
(
*
ppBuf
+
n
,
&
delimiter
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
ASSERT
(
delimiter
==
TSDB_FILE_DLMT
);
n
+=
tGetMapData
(
*
ppBuf
+
n
,
pDelIdxMap
);
ASSERT
(
n
+
sizeof
(
TSCKSUM
)
==
size
);
taosArrayClear
(
aDelIdx
);
while
(
n
<
size
-
sizeof
(
TSCKSUM
))
{
n
+=
tGetDelIdx
(
*
ppBuf
+
n
,
pDelIdx
);
if
(
taosArrayPush
(
aDelIdx
,
pDelIdx
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
}
ASSERT
(
n
==
size
-
sizeof
(
TSCKSUM
));
return
code
;
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
47a75227
...
@@ -571,10 +571,6 @@ int32_t tPutDelIdx(uint8_t *p, void *ph) {
...
@@ -571,10 +571,6 @@ int32_t tPutDelIdx(uint8_t *p, void *ph) {
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
suid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
suid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
uid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
uid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
minKey
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pDelIdx
->
maxKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
minVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
maxVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
size
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pDelIdx
->
size
);
...
@@ -587,10 +583,6 @@ int32_t tGetDelIdx(uint8_t *p, void *ph) {
...
@@ -587,10 +583,6 @@ int32_t tGetDelIdx(uint8_t *p, void *ph) {
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
suid
);
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
suid
);
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
uid
);
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
uid
);
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
minKey
);
n
+=
tGetI64
(
p
+
n
,
&
pDelIdx
->
maxKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
minVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
maxVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
size
);
n
+=
tGetI64v
(
p
+
n
,
&
pDelIdx
->
size
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
47a75227
...
@@ -315,7 +315,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
...
@@ -315,7 +315,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
t
=
ntohl
(
*
(
int32_t
*
)
pReq
);
int32_t
t
=
ntohl
(
*
(
int32_t
*
)
pReq
);
v
Debug
(
"vgId:%d, recv ttl msg, time:%d"
,
pVnode
->
config
.
vgId
,
t
);
v
Error
(
"rec ttl time:%d"
,
t
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
t
,
tbUids
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
t
,
tbUids
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
goto
end
;
goto
end
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录