Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
54e3a3d3
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看板
提交
54e3a3d3
编写于
9月 29, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code optimization
上级
ad2c58e8
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
90 addition
and
109 deletion
+90
-109
src/tsdb/inc/tsdbFS.h
src/tsdb/inc/tsdbFS.h
+2
-3
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+8
-9
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+1
-2
src/tsdb/inc/tsdbReadImpl.h
src/tsdb/inc/tsdbReadImpl.h
+23
-9
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+19
-18
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+0
-3
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+2
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+7
-6
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-16
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+25
-40
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+0
-1
tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
...unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
+1
-1
未找到文件。
src/tsdb/inc/tsdbFS.h
浏览文件 @
54e3a3d3
...
...
@@ -28,7 +28,8 @@ typedef enum {
}
ETsdbFsVer
;
#define TSDB_FVER_TYPE uint32_t
#define TSDB_LATEST_FVER TSDB_FS_VER_1
#define TSDB_LATEST_FVER TSDB_FS_VER_1 // latest version for DFile
#define TSDB_LATEST_SFS_VER TSDB_FS_VER_1 // latest version for 'current' file
static
FORCE_INLINE
uint32_t
tsdbGetDFSVersion
(
TSDB_FILE_T
fType
)
{
// latest version for DFile
switch
(
fType
)
{
...
...
@@ -39,8 +40,6 @@ static FORCE_INLINE uint32_t tsdbGetDFSVersion(TSDB_FILE_T fType) { // latest v
}
}
static
FORCE_INLINE
uint32_t
tsdbGetSFSVersion
()
{
return
TSDB_FS_VER_1
;
}
// latest version for current
int
tsdbRefactorFS
(
STsdbRepo
*
pRepo
);
// ================== TSDB global config
...
...
src/tsdb/inc/tsdbFile.h
浏览文件 @
54e3a3d3
...
...
@@ -52,7 +52,7 @@ typedef enum {
TSDB_FILE_META
}
TSDB_FILE_T
;
#define TSDB_FILE_MIN 3U // min
number of files in one DFileSet
#define TSDB_FILE_MIN 3U // min
valid number of files in one DFileSet(.head/.data/.last)
// =============== SMFile
typedef
struct
{
...
...
@@ -321,17 +321,10 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) {
return
TSDB_FILE_MAX
;
}
}
#define TSDB_FSET_FID(s) ((s)->fid)
#define TSDB_DFILE_IN_SET(s, t) ((s)->files + (t))
#define TSDB_FSET_LEVEL(s) TSDB_FILE_LEVEL(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_ID(s) TSDB_FILE_ID(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_SET_INIT(s) \
do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \
} \
} while (0);
#define TSDB_FSET_SET_CLOSED(s) \
do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < tsdbGetNFiles(s); ftype++) { \
...
...
@@ -344,6 +337,12 @@ static FORCE_INLINE uint8_t tsdbGetNFiles(SDFileSet* pSet) {
TSDB_FILE_FSYNC(TSDB_DFILE_IN_SET(s, ftype)); \
} \
} while (0);
#define TSDB_FSET_SET_INIT(s) \
do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \
} \
} while (0);
void
tsdbInitDFileSet
(
SDFileSet
*
pSet
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
uint8_t
fsetVer
);
void
tsdbInitDFileSetEx
(
SDFileSet
*
pSet
,
SDFileSet
*
pOSet
);
...
...
@@ -357,7 +356,7 @@ int tsdbUpdateDFileSetHeader(SDFileSet* pSet);
int
tsdbScanAndTryFixDFileSet
(
STsdbRepo
*
pRepo
,
SDFileSet
*
pSet
);
static
FORCE_INLINE
void
tsdbCloseDFileSet
(
SDFileSet
*
pSet
)
{
ASSERT
(
tsdbGetNFiles
(
pSet
)
<=
TSDB_FILE_MAX
);
ASSERT
_TSDB_FSET_NFILES_VALID
(
pSet
);
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
tsdbGetNFiles
(
pSet
);
ftype
++
)
{
tsdbCloseDFile
(
TSDB_DFILE_IN_SET
(
pSet
,
ftype
));
}
...
...
src/tsdb/inc/tsdbMeta.h
浏览文件 @
54e3a3d3
...
...
@@ -112,9 +112,8 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
if
(
ptr
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
goto
_exit
;
}
else
{
pTSchema
=
*
(
STSchema
**
)
ptr
;
}
pTSchema
=
*
(
STSchema
**
)
ptr
;
}
ASSERT
(
pTSchema
!=
NULL
);
...
...
src/tsdb/inc/tsdbReadImpl.h
浏览文件 @
54e3a3d3
...
...
@@ -71,11 +71,11 @@ typedef struct {
* blkVer; // 0 - original block, 1 - block since importing .smad/.smal
* aggrOffset; // only valid when blkVer > 0 and aggrStat > 0
*/
#define SBlockFieldsP1 \
int64_t aggrStat : 3; \
int64_t blkVer : 5; \
int64_t aggrOffset : 56; \
int32_t aggrLen
#define SBlockFieldsP1
\
u
int64_t aggrStat : 3; \
u
int64_t blkVer : 5; \
u
int64_t aggrOffset : 56; \
u
int32_t aggrLen
typedef
struct
{
SBlockFieldsP0
;
...
...
@@ -87,13 +87,12 @@ typedef struct {
}
SBlockV1
;
typedef
enum
{
TSDB_SBLK_VER_0
,
TSDB_SBLK_VER_0
=
0
,
TSDB_SBLK_VER_1
,
}
ESBlockVer
;
#define SBlockVerLatest TSDB_SBLK_VER_1
#define SBlockBase SBlockV0 // base SBlock definition
#define SBlock SBlockV1 // latest SBlock definition
// lastest SBlockInfo definition
...
...
@@ -162,9 +161,7 @@ typedef struct {
SBlockCol
cols
[];
}
SBlockData
;
typedef
struct
{
// int32_t delimiter; // For recovery usage
int32_t
numOfCols
;
// For recovery usage
// uint64_t uid; // For recovery usage
SAggrBlkCol
cols
[];
}
SAggrBlkData
;
...
...
@@ -260,4 +257,21 @@ static FORCE_INLINE int tsdbMakeRoom(void **ppBuf, size_t size) {
return
0
;
}
static
FORCE_INLINE
SBlockCol
*
tsdbGetSBlockCol
(
SBlock
*
pBlock
,
SBlockCol
**
pDestBlkCol
,
SBlockCol
*
pBlkCols
,
int
colIdx
)
{
if
(
pBlock
->
blkVer
==
SBlockVerLatest
)
{
*
pDestBlkCol
=
pBlkCols
+
colIdx
;
return
*
pDestBlkCol
;
}
if
(
pBlock
->
blkVer
==
TSDB_SBLK_VER_0
)
{
SBlockColV0
*
pBlkCol
=
(
SBlockColV0
*
)
pBlkCols
+
colIdx
;
(
*
pDestBlkCol
)
->
colId
=
pBlkCol
->
colId
;
(
*
pDestBlkCol
)
->
len
=
pBlkCol
->
len
;
(
*
pDestBlkCol
)
->
type
=
pBlkCol
->
type
;
(
*
pDestBlkCol
)
->
offset
=
pBlkCol
->
offset
;
(
*
pDestBlkCol
)
->
offsetH
=
pBlkCol
->
offsetH
;
}
return
*
pDestBlkCol
;
}
#endif
/*_TD_TSDB_READ_IMPL_H_*/
src/tsdb/src/tsdbCommit.c
浏览文件 @
54e3a3d3
...
...
@@ -1080,9 +1080,9 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
// Get # of cols not all NULL(not including key column)
int
nColsNotAllNull
=
0
;
int
aggrNum
=
0
;
int
nAggrCols
=
0
;
for
(
int
ncol
=
1
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
// ncol from 1, we skip the timestamp column
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SBlockCol
*
pBlockCol
=
pBlockData
->
cols
+
nColsNotAllNull
;
SAggrBlkCol
*
pAggrBlkCol
=
pAggrBlkData
->
cols
+
nColsNotAllNull
;
...
...
@@ -1095,17 +1095,18 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
pBlockCol
->
colId
=
pDataCol
->
colId
;
pBlockCol
->
type
=
pDataCol
->
type
;
pAggrBlkCol
->
colId
=
pDataCol
->
colId
;
if
(
tDataTypes
[
pDataCol
->
type
].
statisFunc
)
{
// (*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
// &(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
// &(pBlockCol->numOfNull));
#if 0
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
&(pBlockCol->numOfNull));
#endif
(
*
tDataTypes
[
pDataCol
->
type
].
statisFunc
)(
pDataCol
->
pData
,
rowsToWrite
,
&
(
pAggrBlkCol
->
min
),
&
(
pAggrBlkCol
->
max
),
&
(
pAggrBlkCol
->
sum
),
&
(
pAggrBlkCol
->
minIndex
),
&
(
pAggrBlkCol
->
maxIndex
),
&
(
pAggrBlkCol
->
numOfNull
));
++
aggrNum
;
++
nAggrCols
;
}
nColsNotAllNull
++
;
}
...
...
@@ -1119,14 +1120,14 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
int32_t
lsize
=
tsize
;
int32_t
keyLen
=
0
;
int32_t
tsizeAggr
=
(
int32_t
)
tsdbBlockAggrSize
(
nColsNotAllNull
,
SBlockVerLatest
);
uint32_t
tsizeAggr
=
(
u
int32_t
)
tsdbBlockAggrSize
(
nColsNotAllNull
,
SBlockVerLatest
);
for
(
int
ncol
=
0
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
// All not NULL columns finish
if
(
ncol
!=
0
&&
tcol
>=
nColsNotAllNull
)
break
;
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SBlockCol
*
pBlockCol
=
pBlockData
->
cols
+
tcol
;
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SBlockCol
*
pBlockCol
=
pBlockData
->
cols
+
tcol
;
if
(
ncol
!=
0
&&
(
pDataCol
->
colId
!=
pBlockCol
->
colId
))
continue
;
...
...
@@ -1181,14 +1182,13 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pBlockData
,
tsize
);
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
pBlockData
,
tsize
-
sizeof
(
TSCKSUM
)));
// Write the whole block to file
if
(
tsdbAppendDFile
(
pDFile
,
(
void
*
)
pBlockData
,
lsize
,
&
offset
)
<
lsize
)
{
return
-
1
;
}
// pAggrBlkData->delimiter = TSDB_FILE_DELIMITER;
// pAggrBlkData->uid = TABLE_UID(pTable);
int
aggrStatus
=
((
aggrNum
>
0
)
&&
(
rowsToWrite
>
5
))
?
1
:
0
;
// TODO: How to make the decision?
uint32_t
aggrStatus
=
((
nAggrCols
>
0
)
&&
(
rowsToWrite
>
10
))
?
1
:
0
;
// TODO: How to make the decision?
if
(
aggrStatus
>
0
)
{
pAggrBlkData
->
numOfCols
=
nColsNotAllNull
;
...
...
@@ -1201,7 +1201,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
}
}
// Update pBlock membership va
ir
ables
// Update pBlock membership va
ri
ables
pBlock
->
last
=
isLast
;
pBlock
->
offset
=
offset
;
pBlock
->
algorithm
=
pCfg
->
compression
;
...
...
@@ -1215,7 +1215,7 @@ int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDFile
// since blkVer1
pBlock
->
aggrStat
=
aggrStatus
;
pBlock
->
blkVer
=
SBlockVerLatest
;
pBlock
->
aggrOffset
=
offsetAggr
;
pBlock
->
aggrOffset
=
(
uint64_t
)
offsetAggr
;
pBlock
->
aggrLen
=
tsizeAggr
;
tsdbDebug
(
"vgId:%d tid:%d a block of data is written to file %s, offset %"
PRId64
...
...
@@ -1573,6 +1573,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
pCommith
->
isDFileSame
=
false
;
pCommith
->
isLFileSame
=
false
;
tsdbDebug
(
"vgId:%d FSET %d at level %d disk id %d is created to commit"
,
REPO_ID
(
pRepo
),
TSDB_FSET_FID
(
pWSet
),
TSDB_FSET_LEVEL
(
pWSet
),
TSDB_FSET_ID
(
pWSet
));
}
else
{
...
...
@@ -1679,14 +1680,14 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
return
-
1
;
}
}
}
}
// TSDB_FILE_SMAL
ASSERT
(
tsdbGetNFiles
(
pWSet
)
>=
TSDB_FILE_SMAL
);
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
...
...
@@ -1699,7 +1700,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
tsdbCloseAndUnsetFSet
(
&
(
pCommith
->
readh
));
return
-
1
;
}
}
}
}
else
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmalF
));
tsdbInitDFile
(
pWSmalF
,
did
,
REPO_ID
(
pRepo
),
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAL
);
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
54e3a3d3
...
...
@@ -391,9 +391,6 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
pTh
->
bindex
=
*
(
pReadH
->
pBlkIdx
);
pTh
->
pBlkIdx
=
&
(
pTh
->
bindex
);
// if (tsdbMakeRoom((void **)(&(pTh->pInfo)), pTh->pBlkIdx->len) < 0) {
// return -1;
// }
uint32_t
originLen
=
0
;
if
(
tsdbLoadBlockInfo
(
pReadH
,
(
void
**
)(
&
(
pTh
->
pInfo
)),
&
originLen
)
<
0
)
{
return
-
1
;
...
...
src/tsdb/src/tsdbFS.c
浏览文件 @
54e3a3d3
...
...
@@ -342,6 +342,7 @@ int tsdbOpenFS(STsdbRepo *pRepo) {
return
-
1
;
}
// TODO: seems not need, remove this logic. 2021-09-29 13:00
if
(
tsdbEnableUpgradeFile
&&
tsdbRefactorFS
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to refactor FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -432,7 +433,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) {
return
-
1
;
}
fsheader
.
version
=
tsdbGetSFSVersion
()
;
fsheader
.
version
=
TSDB_LATEST_SFS_VER
;
if
(
pStatus
->
pmf
==
NULL
)
{
ASSERT
(
taosArrayGetSize
(
pStatus
->
df
)
==
0
);
fsheader
.
len
=
0
;
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
54e3a3d3
...
...
@@ -343,7 +343,7 @@ static int tsdbEncodeSDFileEx(void **buf, SDFile *pDFile) {
static
void
*
tsdbDecodeSDFileEx
(
void
*
buf
,
SDFile
*
pDFile
)
{
char
*
aname
;
// The sync module would send DFileSet with latest verion.
buf
=
tsdbDecodeDFInfo
(
buf
,
&
(
pDFile
->
info
),
tsdbGetSFSVersion
()
);
buf
=
tsdbDecodeDFInfo
(
buf
,
&
(
pDFile
->
info
),
TSDB_LATEST_SFS_VER
);
buf
=
taosDecodeString
(
buf
,
&
aname
);
strncpy
(
TSDB_FILE_FULL_NAME
(
pDFile
),
aname
,
TSDB_FILENAME_LEN
);
TSDB_FILE_SET_CLOSED
(
pDFile
);
...
...
@@ -431,7 +431,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
void
*
pBuf
=
buf
;
pBuf
=
tsdbDecodeDFInfo
(
pBuf
,
pInfo
,
TSDB_LATEST_FVER
);
pBuf
=
tsdbDecodeDFInfo
(
pBuf
,
pInfo
,
TSDB_LATEST_FVER
);
// only makesure the paramter sfver > 0
return
0
;
}
...
...
@@ -638,10 +638,11 @@ void *tsdbDecodeDFileSetEx(void *buf, SDFileSet *pSet) {
}
int
tsdbApplyDFileSetChange
(
SDFileSet
*
from
,
SDFileSet
*
to
)
{
uint8_t
nDFiles
=
(
from
==
NULL
)
?
TSDB_FILE_MAX
:
tsdbGetNFiles
(
from
);
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
nDFiles
;
ftype
++
)
{
SDFile
*
pDFileFrom
=
(
from
)
?
TSDB_DFILE_IN_SET
(
from
,
ftype
)
:
NULL
;
SDFile
*
pDFileTo
=
(
to
)
?
TSDB_DFILE_IN_SET
(
to
,
ftype
)
:
NULL
;
uint8_t
nFilesFrom
=
from
?
tsdbGetNFiles
(
from
)
:
0
;
uint8_t
nFilesTo
=
to
?
tsdbGetNFiles
(
to
)
:
0
;
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
MAX
(
nFilesFrom
,
nFilesTo
);
ftype
++
)
{
SDFile
*
pDFileFrom
=
ftype
<
nFilesFrom
?
TSDB_DFILE_IN_SET
(
from
,
ftype
)
:
NULL
;
SDFile
*
pDFileTo
=
ftype
<
nFilesTo
?
TSDB_DFILE_IN_SET
(
to
,
ftype
)
:
NULL
;
if
(
tsdbApplyDFileChange
(
pDFileFrom
,
pDFileTo
)
<
0
)
{
return
-
1
;
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
54e3a3d3
...
...
@@ -1090,22 +1090,8 @@ static int32_t loadBlockInfo(STsdbQueryHandle * pQueryHandle, int32_t index, int
assert
(
compIndex
->
len
>
0
);
// if (pCheckInfo->compSize < (int32_t)compIndex->len) {
// assert(compIndex->len > 0);
// char* t = realloc(pCheckInfo->pCompInfo, compIndex->len);
// if (t == NULL) {
// terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
// code = TSDB_CODE_TDB_OUT_OF_MEMORY;
// return code;
// }
// pCheckInfo->pCompInfo = (SBlockInfo*)t;
// pCheckInfo->compSize = compIndex->len;
// }
if
(
tsdbLoadBlockInfo
(
&
(
pQueryHandle
->
rhelper
),
(
void
**
)(
&
pCheckInfo
->
pCompInfo
),
(
uint32_t
*
)(
&
pCheckInfo
->
compSize
))
<
0
)
{
if
(
tsdbLoadBlockInfo
(
&
(
pQueryHandle
->
rhelper
),
(
void
**
)(
&
pCheckInfo
->
pCompInfo
),
(
uint32_t
*
)(
&
pCheckInfo
->
compSize
))
<
0
)
{
return
terrno
;
}
SBlockInfo
*
pCompInfo
=
pCheckInfo
->
pCompInfo
;
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
54e3a3d3
...
...
@@ -252,8 +252,9 @@ static FORCE_INLINE int32_t tsdbGetSBlockVer(int32_t fver) {
case
TSDB_FS_VER_0
:
return
TSDB_SBLK_VER_0
;
case
TSDB_FS_VER_1
:
default:
return
TSDB_SBLK_VER_1
;
default:
return
SBlockVerLatest
;
}
}
...
...
@@ -268,9 +269,9 @@ static FORCE_INLINE size_t tsdbSizeOfSBlock(int32_t sBlkVer) {
}
}
static
int
tsdb
Head
Refactor
(
SDFile
*
pHeadf
,
SBlockInfo
**
pDstBlkInfo
,
SBlockIdx
*
pBlkIdx
,
uint32_t
*
dstBlkInfoLen
)
{
static
int
tsdb
SBlkInfo
Refactor
(
SDFile
*
pHeadf
,
SBlockInfo
**
pDstBlkInfo
,
SBlockIdx
*
pBlkIdx
,
uint32_t
*
dstBlkInfoLen
)
{
int
sBlkVer
=
tsdbGetSBlockVer
(
pHeadf
->
info
.
fver
);
if
(
sBlkVer
==
SBlockVerLatest
)
{
if
(
sBlkVer
>
TSDB_SBLK_VER_0
)
{
*
dstBlkInfoLen
=
pBlkIdx
->
len
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -346,7 +347,7 @@ int tsdbLoadBlockInfo(SReadH *pReadh, void **pTarget, uint32_t *extendedLen) {
ASSERT
(
pBlkIdx
->
tid
==
pReadh
->
pBlkInfo
->
tid
&&
pBlkIdx
->
uid
==
pReadh
->
pBlkInfo
->
uid
);
uint32_t
dstBlkInfoLen
=
0
;
if
(
tsdb
Head
Refactor
(
pHeadf
,
&
(
pReadh
->
pBlkInfo
),
pBlkIdx
,
&
dstBlkInfoLen
)
<
0
)
{
if
(
tsdb
SBlkInfo
Refactor
(
pHeadf
,
&
(
pReadh
->
pBlkInfo
),
pBlkIdx
,
&
dstBlkInfoLen
)
<
0
)
{
return
-
1
;
}
...
...
@@ -425,7 +426,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
static
int
tsdbLoadBlockStatisFromDFile
(
SReadH
*
pReadh
,
SBlock
*
pBlock
)
{
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_DATA_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFile
,
pBlock
->
offset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
aggr
part while seek file %s to offset %"
PRId64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block
statis
part while seek file %s to offset %"
PRId64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -435,14 +436,14 @@ static int tsdbLoadBlockStatisFromDFile(SReadH *pReadh, SBlock *pBlock) {
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
(
void
*
)(
pReadh
->
pBlkData
),
size
);
if
(
nread
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
aggr
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block
statis
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
}
if
(
nread
<
size
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
aggr
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
" read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
,
nread
);
return
-
1
;
...
...
@@ -450,7 +451,7 @@ static int tsdbLoadBlockStatisFromDFile(SReadH *pReadh, SBlock *pBlock) {
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pBlkData
),
(
uint32_t
)
size
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
aggr
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
}
...
...
@@ -462,8 +463,8 @@ static int tsdbLoadBlockStatisFromAggr(SReadH *pReadh, SBlock *pBlock) {
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while seek file %s to offset %"
PRI
d
64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
int64_t
)
pBlock
->
aggrOffset
,
tsdbError
(
"vgId:%d failed to load block aggr part while seek file %s to offset %"
PRI
u
64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
u
int64_t
)
pBlock
->
aggrOffset
,
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -473,25 +474,25 @@ static int tsdbLoadBlockStatisFromAggr(SReadH *pReadh, SBlock *pBlock) {
int64_t
nreadAggr
=
tsdbReadDFile
(
pDFileAggr
,
(
void
*
)(
pReadh
->
pAggrBlkData
),
sizeAggr
);
if
(
nreadAggr
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while read file %s since %s, offset:%"
PRI
d
64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block aggr part while read file %s since %s, offset:%"
PRI
u
64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
(
u
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
}
if
(
nreadAggr
<
sizeAggr
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted, offset:%"
PRI
d
64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted, offset:%"
PRI
u
64
" expected bytes:%"
PRIzu
" read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
u
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
nreadAggr
);
return
-
1
;
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pAggrBlkData
),
(
uint32_t
)
sizeAggr
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted since wrong checksum, offset:%"
PRI
d
64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted since wrong checksum, offset:%"
PRI
u
64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
u
int64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
}
return
0
;
...
...
@@ -667,6 +668,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
int
ccol
=
0
;
// loop iter for SBlockCol object
int
dcol
=
0
;
// loop iter for SDataCols object
SBlockCol
blockCol
=
{
0
};
SBlockCol
*
pBlockCol
=
&
blockCol
;
while
(
dcol
<
pDataCols
->
numOfCols
)
{
SDataCol
*
pDataCol
=
&
(
pDataCols
->
cols
[
dcol
]);
if
(
dcol
!=
0
&&
ccol
>=
pBlockData
->
numOfCols
)
{
...
...
@@ -680,20 +682,12 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
uint32_t
toffset
=
TSDB_KEY_COL_OFFSET
;
int32_t
tlen
=
pBlock
->
keyLen
;
if
(
dcol
!=
0
)
{
if
(
pBlock
->
blkVer
==
SBlockVerLatest
)
{
SBlockCol
*
pBlockCol
=
&
(
pBlockData
->
cols
[
ccol
]);
tcolId
=
pBlockCol
->
colId
;
toffset
=
tsdbGetBlockColOffset
(
pBlockCol
);
tlen
=
pBlockCol
->
len
;
}
else
{
SBlockColV0
*
pBlockCol
=
(
SBlockColV0
*
)(
pBlockData
->
cols
)
+
ccol
;
tcolId
=
pBlockCol
->
colId
;
blockCol
.
offset
=
pBlockCol
->
offset
;
blockCol
.
offsetH
=
pBlockCol
->
offsetH
;
toffset
=
tsdbGetBlockColOffset
(
&
blockCol
);
tlen
=
pBlockCol
->
len
;
}
tsdbGetSBlockCol
(
pBlock
,
&
pBlockCol
,
pBlockData
->
cols
,
ccol
);
tcolId
=
pBlockCol
->
colId
;
toffset
=
tsdbGetBlockColOffset
(
pBlockCol
);
tlen
=
pBlockCol
->
len
;
}
else
{
ASSERT
(
pDataCol
->
colId
==
tcolId
);
}
...
...
@@ -814,17 +808,8 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
break
;
}
if
(
pBlock
->
blkVer
==
SBlockVerLatest
)
{
pBlockCol
=
&
(
pReadh
->
pBlkData
->
cols
[
ccol
]);
}
else
{
SBlockColV0
*
pBlkCol
=
((
SBlockColV0
*
)(
pReadh
->
pBlkData
->
cols
))
+
ccol
;
blockCol
.
colId
=
pBlkCol
->
colId
;
blockCol
.
len
=
pBlkCol
->
len
;
blockCol
.
type
=
pBlkCol
->
type
;
blockCol
.
offset
=
pBlkCol
->
offset
;
blockCol
.
offsetH
=
pBlkCol
->
offsetH
;
pBlockCol
=
&
blockCol
;
}
pBlockCol
=
&
blockCol
;
tsdbGetSBlockCol
(
pBlock
,
&
pBlockCol
,
pReadh
->
pBlkData
->
cols
,
ccol
);
if
(
pBlockCol
->
colId
>
colId
)
{
pBlockCol
=
NULL
;
...
...
src/wal/src/walWrite.c
浏览文件 @
54e3a3d3
...
...
@@ -411,7 +411,6 @@ static int walSMemRowCheck(SWalHead *pHead) {
pWalHead
->
len
=
pWalHead
->
len
+
lenExpand
;
}
ASSERT
((
sizeof
(
SWalHead
)
+
pWalHead
->
len
)
<=
WAL_MAX_SIZE
);
memcpy
(
pHead
,
pWalHead
,
sizeof
(
SWalHead
)
+
pWalHead
->
len
);
tfree
(
pWalHead
);
}
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim
浏览文件 @
54e3a3d3
...
...
@@ -408,4 +408,4 @@ sql select count(*) from $stb
print data00 $data00
if $data00 != $totalRows then
return -1
endi
endi
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录