Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
2980d7b1
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2980d7b1
编写于
1月 25, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix more bug
上级
822f1051
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
54 addition
and
21 deletion
+54
-21
src/inc/tsdb.h
src/inc/tsdb.h
+2
-1
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+1
-0
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+2
-2
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+1
-1
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+6
-8
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+38
-7
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/tsdb/src/tsdbSync.c
src/tsdb/src/tsdbSync.c
+2
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
未找到文件。
src/inc/tsdb.h
浏览文件 @
2980d7b1
...
...
@@ -40,7 +40,8 @@ extern "C" {
// TSDB STATE DEFINITION
#define TSDB_STATE_OK 0x0
#define TSDB_STATE_BAD_FILE 0x1
#define TSDB_STATE_BAD_META 0x1
#define TSDB_STATE_BAD_DATA 0x2
// --------- TSDB APPLICATION HANDLE DEFINITION
typedef
struct
{
...
...
src/sync/src/syncRestore.c
浏览文件 @
2980d7b1
...
...
@@ -224,6 +224,7 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) {
int32_t
code
=
syncRestoreFile
(
pPeer
,
&
fversion
);
if
(
code
<
0
)
{
(
*
pNode
->
stopSyncFileFp
)(
pNode
->
vgId
,
fversion
);
sError
(
"%s, failed to restore files"
,
pPeer
->
id
);
return
-
1
;
}
...
...
src/tsdb/inc/tsdbFile.h
浏览文件 @
2980d7b1
...
...
@@ -63,7 +63,7 @@ int tsdbApplyMFileChange(SMFile* from, SMFile* to);
int
tsdbCreateMFile
(
SMFile
*
pMFile
,
bool
updateHeader
);
int
tsdbUpdateMFileHeader
(
SMFile
*
pMFile
);
int
tsdbLoadMFileHeader
(
SMFile
*
pMFile
,
SMFInfo
*
pInfo
);
int
tsdbScanAndTryFixMFile
(
S
MFile
*
pMFile
);
int
tsdbScanAndTryFixMFile
(
S
TsdbRepo
*
pRepo
);
int
tsdbEncodeMFInfo
(
void
**
buf
,
SMFInfo
*
pInfo
);
void
*
tsdbDecodeMFInfo
(
void
*
buf
,
SMFInfo
*
pInfo
);
...
...
@@ -310,7 +310,7 @@ void* tsdbDecodeDFileSetEx(void* buf, SDFileSet* pSet);
int
tsdbApplyDFileSetChange
(
SDFileSet
*
from
,
SDFileSet
*
to
);
int
tsdbCreateDFileSet
(
SDFileSet
*
pSet
,
bool
updateHeader
);
int
tsdbUpdateDFileSetHeader
(
SDFileSet
*
pSet
);
int
tsdbScanAndTryFixDFileSet
(
SDFileSet
*
pSet
);
int
tsdbScanAndTryFixDFileSet
(
S
TsdbRepo
*
pRepo
,
S
DFileSet
*
pSet
);
static
FORCE_INLINE
void
tsdbCloseDFileSet
(
SDFileSet
*
pSet
)
{
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
...
...
src/tsdb/inc/tsdbint.h
浏览文件 @
2980d7b1
...
...
@@ -68,7 +68,7 @@ extern "C" {
#include "tsdbCommitQueue.h"
// Main definitions
struct
STsdbRepo
{
int8_t
state
;
u
int8_t
state
;
STsdbCfg
config
;
STsdbAppH
appH
;
...
...
src/tsdb/src/tsdbFS.c
浏览文件 @
2980d7b1
...
...
@@ -255,7 +255,7 @@ int tsdbOpenFS(STsdbRepo *pRepo) {
}
// Load meta cache if has meta file
if
(
tsdbLoadMetaCache
(
pRepo
,
true
)
<
0
)
{
if
(
(
!
(
pRepo
->
state
&
TSDB_STATE_BAD_META
))
&&
tsdbLoadMetaCache
(
pRepo
,
true
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open FS while loading meta cache since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -670,11 +670,9 @@ static int tsdbScanAndTryFixFS(STsdbRepo *pRepo) {
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
SFSStatus
*
pStatus
=
pfs
->
cstatus
;
if
(
pStatus
->
pmf
)
{
if
(
tsdbScanAndTryFixMFile
(
pStatus
->
pmf
)
<
0
)
{
tsdbError
(
"vgId:%d failed to fix MFile since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
}
if
(
tsdbScanAndTryFixMFile
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to fix MFile since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
}
size_t
size
=
taosArrayGetSize
(
pStatus
->
df
);
...
...
@@ -682,13 +680,13 @@ static int tsdbScanAndTryFixFS(STsdbRepo *pRepo) {
for
(
size_t
i
=
0
;
i
<
size
;
i
++
)
{
SDFileSet
*
pSet
=
(
SDFileSet
*
)
taosArrayGet
(
pStatus
->
df
,
i
);
if
(
tsdbScanAndTryFixDFileSet
(
pSet
)
<
0
)
{
if
(
tsdbScanAndTryFixDFileSet
(
p
Repo
,
p
Set
)
<
0
)
{
tsdbError
(
"vgId:%d failed to fix MFile since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
}
}
//
:
remove those unused files
// remove those unused files
tsdbScanRootDir
(
pRepo
);
tsdbScanDataDir
(
pRepo
);
return
0
;
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
2980d7b1
...
...
@@ -163,9 +163,23 @@ int tsdbLoadMFileHeader(SMFile *pMFile, SMFInfo *pInfo) {
return
0
;
}
int
tsdbScanAndTryFixMFile
(
SMFile
*
pMFile
)
{
int
tsdbScanAndTryFixMFile
(
STsdbRepo
*
pRepo
)
{
SMFile
*
pMFile
=
pRepo
->
fs
->
cstatus
->
pmf
;
struct
stat
mfstat
;
SMFile
mf
=
*
pMFile
;
SMFile
mf
;
if
(
pMFile
==
NULL
)
{
return
0
;
}
mf
=
*
pMFile
;
if
(
access
(
TSDB_FILE_FULL_NAME
(
pMFile
),
F_OK
)
!=
0
)
{
tsdbError
(
"vgId:%d meta file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pMFile
));
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
return
0
;
}
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
mf
),
&
mfstat
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -189,9 +203,14 @@ int tsdbScanAndTryFixMFile(SMFile *pMFile) {
}
tsdbCloseMFile
(
&
mf
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pMFile
),
mfstat
.
st_size
,
pMFile
->
info
.
size
);
}
else
if
(
pMFile
->
info
.
size
<
mfstat
.
st_size
)
{
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
);
pRepo
->
state
|=
TSDB_STATE_BAD_META
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
return
-
1
;
return
0
;
}
return
0
;
...
...
@@ -361,10 +380,17 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
return
0
;
}
static
int
tsdbScanAndTryFixDFile
(
SDFile
*
pDFile
)
{
static
int
tsdbScanAndTryFixDFile
(
S
TsdbRepo
*
pRepo
,
S
DFile
*
pDFile
)
{
struct
stat
dfstat
;
SDFile
df
=
*
pDFile
;
if
(
access
(
TSDB_FILE_FULL_NAME
(
pDFile
),
F_OK
)
!=
0
)
{
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
return
0
;
}
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
dfstat
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -387,9 +413,14 @@ static int tsdbScanAndTryFixDFile(SDFile *pDFile) {
}
tsdbCloseDFile
(
&
df
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
<
dfstat
.
st_size
)
{
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
);
pRepo
->
state
|=
TSDB_STATE_BAD_DATA
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
return
-
1
;
return
0
;
}
return
0
;
...
...
@@ -559,9 +590,9 @@ int tsdbUpdateDFileSetHeader(SDFileSet *pSet) {
return
0
;
}
int
tsdbScanAndTryFixDFileSet
(
SDFileSet
*
pSet
)
{
int
tsdbScanAndTryFixDFileSet
(
S
TsdbRepo
*
pRepo
,
S
DFileSet
*
pSet
)
{
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
if
(
tsdbScanAndTryFixDFile
(
TSDB_DFILE_IN_SET
(
pSet
,
ftype
))
<
0
)
{
if
(
tsdbScanAndTryFixDFile
(
pRepo
,
TSDB_DFILE_IN_SET
(
pSet
,
ftype
))
<
0
)
{
return
-
1
;
}
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
2980d7b1
...
...
@@ -98,7 +98,7 @@ STsdbRepo *tsdbOpenRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
}
// TODO: Restore information from data
if
(
tsdbRestoreInfo
(
pRepo
)
<
0
)
{
if
(
(
!
(
pRepo
->
state
&
TSDB_STATE_BAD_DATA
))
&&
tsdbRestoreInfo
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open TSDB repository while restore info since %s"
,
config
.
tsdbId
,
tstrerror
(
terrno
));
tsdbCloseRepo
(
pRepo
,
false
);
return
NULL
;
...
...
src/tsdb/src/tsdbSync.c
浏览文件 @
2980d7b1
...
...
@@ -82,6 +82,8 @@ int32_t tsdbSyncRecv(void *tsdb, int32_t socketFd) {
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
tsdb
;
SSyncH
synch
=
{
0
};
pRepo
->
state
=
TSDB_STATE_OK
;
tsdbInitSyncH
(
&
synch
,
pRepo
,
socketFd
);
tsdbStartFSTxn
(
pRepo
,
0
,
0
);
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
2980d7b1
...
...
@@ -242,7 +242,7 @@ int32_t vnodeOpen(int32_t vgId) {
if
(
pVnode
->
tsdb
==
NULL
)
{
vnodeCleanUp
(
pVnode
);
return
terrno
;
}
else
if
(
t
errno
!=
TSDB_CODE_SUCCESS
)
{
}
else
if
(
t
sdbGetState
(
pVnode
->
tsdb
)
!=
TSDB_STATE_OK
)
{
vError
(
"vgId:%d, failed to open tsdb, replica:%d reason:%s"
,
pVnode
->
vgId
,
pVnode
->
syncCfg
.
replica
,
tstrerror
(
terrno
));
if
(
pVnode
->
syncCfg
.
replica
<=
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录