Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
10d5d9dd
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
10d5d9dd
编写于
2月 02, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add file state check
上级
219e0994
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
3 deletion
+29
-3
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+18
-0
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+7
-1
src/tsdb/src/tsdbSync.c
src/tsdb/src/tsdbSync.c
+4
-2
未找到文件。
src/tsdb/inc/tsdbFile.h
浏览文件 @
10d5d9dd
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#define TSDB_FILE_DELIMITER 0xF00AFA0F
#define TSDB_FILE_DELIMITER 0xF00AFA0F
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
#define TSDB_IVLD_FID INT_MIN
#define TSDB_IVLD_FID INT_MIN
#define TSDB_FILE_STATE_OK 0
#define TSDB_FILE_STATE_BAD 1
#define TSDB_FILE_INFO(tf) (&((tf)->info))
#define TSDB_FILE_INFO(tf) (&((tf)->info))
#define TSDB_FILE_F(tf) (&((tf)->f))
#define TSDB_FILE_F(tf) (&((tf)->f))
...
@@ -31,6 +33,10 @@
...
@@ -31,6 +33,10 @@
#define TSDB_FILE_LEVEL(tf) TFILE_LEVEL(TSDB_FILE_F(tf))
#define TSDB_FILE_LEVEL(tf) TFILE_LEVEL(TSDB_FILE_F(tf))
#define TSDB_FILE_ID(tf) TFILE_ID(TSDB_FILE_F(tf))
#define TSDB_FILE_ID(tf) TFILE_ID(TSDB_FILE_F(tf))
#define TSDB_FILE_FSYNC(tf) fsync(TSDB_FILE_FD(tf))
#define TSDB_FILE_FSYNC(tf) fsync(TSDB_FILE_FD(tf))
#define TSDB_FILE_STATE(tf) ((tf)->state)
#define TSDB_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
TSDB_FILE_DATA
,
TSDB_FILE_LAST
,
TSDB_FILE_MAX
,
TSDB_FILE_META
}
TSDB_FILE_T
;
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
TSDB_FILE_DATA
,
TSDB_FILE_LAST
,
TSDB_FILE_MAX
,
TSDB_FILE_META
}
TSDB_FILE_T
;
...
@@ -47,6 +53,7 @@ typedef struct {
...
@@ -47,6 +53,7 @@ typedef struct {
SMFInfo
info
;
SMFInfo
info
;
TFILE
f
;
TFILE
f
;
int
fd
;
int
fd
;
uint8_t
state
;
}
SMFile
;
}
SMFile
;
void
tsdbInitMFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
);
void
tsdbInitMFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
);
...
@@ -165,6 +172,7 @@ typedef struct {
...
@@ -165,6 +172,7 @@ typedef struct {
SDFInfo
info
;
SDFInfo
info
;
TFILE
f
;
TFILE
f
;
int
fd
;
int
fd
;
uint8_t
state
;
}
SDFile
;
}
SDFile
;
void
tsdbInitDFile
(
SDFile
*
pDFile
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
);
void
tsdbInitDFile
(
SDFile
*
pDFile
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
);
...
@@ -346,4 +354,14 @@ static FORCE_INLINE void tsdbGetFidKeyRange(int days, int8_t precision, int fid,
...
@@ -346,4 +354,14 @@ static FORCE_INLINE void tsdbGetFidKeyRange(int days, int8_t precision, int fid,
*
maxKey
=
*
minKey
+
days
*
tsMsPerDay
[
precision
]
-
1
;
*
maxKey
=
*
minKey
+
days
*
tsMsPerDay
[
precision
]
-
1
;
}
}
static
FORCE_INLINE
bool
tsdbFSetIsOk
(
SDFileSet
*
pSet
)
{
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
if
(
TSDB_FILE_IS_BAD
(
TSDB_DFILE_IN_SET
(
pSet
,
ftype
)))
{
return
false
;
}
}
return
true
;
}
#endif
/* _TS_TSDB_FILE_H_ */
#endif
/* _TS_TSDB_FILE_H_ */
\ No newline at end of file
src/tsdb/src/tsdbFile.c
浏览文件 @
10d5d9dd
...
@@ -33,7 +33,7 @@ static int tsdbRollBackDFile(SDFile *pDFile);
...
@@ -33,7 +33,7 @@ static int tsdbRollBackDFile(SDFile *pDFile);
void
tsdbInitMFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
)
{
void
tsdbInitMFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
)
{
char
fname
[
TSDB_FILENAME_LEN
];
char
fname
[
TSDB_FILENAME_LEN
];
TSDB_FILE_SET_
CLOSED
(
pMFile
);
TSDB_FILE_SET_
STATE
(
pMFile
,
TSDB_FILE_STATE_OK
);
memset
(
&
(
pMFile
->
info
),
0
,
sizeof
(
pMFile
->
info
));
memset
(
&
(
pMFile
->
info
),
0
,
sizeof
(
pMFile
->
info
));
pMFile
->
info
.
magic
=
TSDB_FILE_INIT_MAGIC
;
pMFile
->
info
.
magic
=
TSDB_FILE_INIT_MAGIC
;
...
@@ -201,6 +201,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) {
...
@@ -201,6 +201,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) {
tsdbError
(
"vgId:%d meta file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
tsdbError
(
"vgId:%d meta file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pMFile
));
TSDB_FILE_FULL_NAME
(
pMFile
));
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
TSDB_FILE_SET_STATE
(
pMFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
return
0
;
}
}
...
@@ -232,6 +233,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) {
...
@@ -232,6 +233,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) {
tsdbError
(
"vgId:%d meta file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
tsdbError
(
"vgId:%d meta file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pMFile
),
mfstat
.
st_size
,
pMFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pMFile
),
mfstat
.
st_size
,
pMFile
->
info
.
size
);
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
TSDB_FILE_SET_STATE
(
pMFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
return
0
;
return
0
;
}
else
{
}
else
{
...
@@ -293,6 +295,8 @@ static int tsdbRollBackMFile(SMFile *pMFile) {
...
@@ -293,6 +295,8 @@ static int tsdbRollBackMFile(SMFile *pMFile) {
void
tsdbInitDFile
(
SDFile
*
pDFile
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
)
{
void
tsdbInitDFile
(
SDFile
*
pDFile
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
)
{
char
fname
[
TSDB_FILENAME_LEN
];
char
fname
[
TSDB_FILENAME_LEN
];
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_OK
);
TSDB_FILE_SET_CLOSED
(
pDFile
);
TSDB_FILE_SET_CLOSED
(
pDFile
);
memset
(
&
(
pDFile
->
info
),
0
,
sizeof
(
pDFile
->
info
));
memset
(
&
(
pDFile
->
info
),
0
,
sizeof
(
pDFile
->
info
));
...
@@ -439,6 +443,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
...
@@ -439,6 +443,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
TSDB_FILE_FULL_NAME
(
pDFile
));
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
return
0
;
}
}
...
@@ -470,6 +475,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
...
@@ -470,6 +475,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st_size
,
pDFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st_size
,
pDFile
->
info
.
size
);
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
return
0
;
return
0
;
}
else
{
}
else
{
...
...
src/tsdb/src/tsdbSync.c
浏览文件 @
10d5d9dd
...
@@ -191,7 +191,8 @@ static int32_t tsdbSyncRecvMeta(SSyncH *pSynch) {
...
@@ -191,7 +191,8 @@ static int32_t tsdbSyncRecvMeta(SSyncH *pSynch) {
return
0
;
return
0
;
}
}
if
(
pLMFile
==
NULL
||
memcmp
(
&
(
pSynch
->
pmf
->
info
),
&
(
pLMFile
->
info
),
sizeof
(
SMFInfo
))
!=
0
)
{
if
(
pLMFile
==
NULL
||
memcmp
(
&
(
pSynch
->
pmf
->
info
),
&
(
pLMFile
->
info
),
sizeof
(
SMFInfo
))
!=
0
||
TSDB_FILE_IS_BAD
(
pLMFile
))
{
// Local has no meta file or has a different meta file, need to copy from remote
// Local has no meta file or has a different meta file, need to copy from remote
pSynch
->
mfChanged
=
true
;
pSynch
->
mfChanged
=
true
;
...
@@ -409,7 +410,8 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) {
...
@@ -409,7 +410,8 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) {
pSynch
->
pdf
!=
NULL
?
pSynch
->
pdf
->
fid
:
-
1
);
pSynch
->
pdf
!=
NULL
?
pSynch
->
pdf
->
fid
:
-
1
);
pLSet
=
tsdbFSIterNext
(
&
fsiter
);
pLSet
=
tsdbFSIterNext
(
&
fsiter
);
}
else
{
}
else
{
if
(
pLSet
&&
pSynch
->
pdf
&&
pLSet
->
fid
==
pSynch
->
pdf
->
fid
&&
tsdbIsTowFSetSame
(
pLSet
,
pSynch
->
pdf
))
{
if
(
pLSet
&&
pSynch
->
pdf
&&
pLSet
->
fid
==
pSynch
->
pdf
->
fid
&&
tsdbIsTowFSetSame
(
pLSet
,
pSynch
->
pdf
)
&&
tsdbFSetIsOk
(
pLSet
))
{
// Just keep local files and notify remote not to send
// Just keep local files and notify remote not to send
tsdbInfo
(
"vgId:%d, fileset:%d is same and no need to recv"
,
REPO_ID
(
pRepo
),
pLSet
->
fid
);
tsdbInfo
(
"vgId:%d, fileset:%d is same and no need to recv"
,
REPO_ID
(
pRepo
),
pLSet
->
fid
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录