Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
6628a47e
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看板
提交
6628a47e
编写于
1月 21, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove invalid files from system when start
上级
5037b495
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
11 deletion
+95
-11
src/inc/tfs.h
src/inc/tfs.h
+1
-1
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+6
-1
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+2
-0
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+84
-5
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+2
-4
未找到文件。
src/inc/tfs.h
浏览文件 @
6628a47e
...
...
@@ -67,7 +67,7 @@ typedef struct {
#define tfsrename(sf, df) rename(TFILE_NAME(sf), TFILE_NAME(df))
void
tfsInitFile
(
TFILE
*
pf
,
int
level
,
int
id
,
const
char
*
bname
);
bool
tfsIsSameFile
(
TFILE
*
pf1
,
TFILE
*
pf2
);
bool
tfsIsSameFile
(
const
TFILE
*
pf1
,
const
TFILE
*
pf2
);
int
tfsEncodeFile
(
void
**
buf
,
TFILE
*
pf
);
void
*
tfsDecodeFile
(
void
*
buf
,
TFILE
*
pf
);
void
tfsbasename
(
const
TFILE
*
pf
,
char
*
dest
);
...
...
src/tfs/src/tfs.c
浏览文件 @
6628a47e
...
...
@@ -189,7 +189,9 @@ void tfsInitFile(TFILE *pf, int level, int id, const char *bname) {
snprintf
(
pf
->
aname
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
DISK_DIR
(
pDisk
),
bname
);
}
bool
tfsIsSameFile
(
TFILE
*
pf1
,
TFILE
*
pf2
)
{
bool
tfsIsSameFile
(
const
TFILE
*
pf1
,
const
TFILE
*
pf2
)
{
ASSERT
(
pf1
!=
NULL
||
pf2
!=
NULL
);
if
(
pf1
==
NULL
||
pf2
==
NULL
)
return
false
;
if
(
pf1
->
level
!=
pf2
->
level
)
return
false
;
if
(
pf1
->
id
!=
pf2
->
id
)
return
false
;
if
(
strncmp
(
pf1
->
rname
,
pf2
->
rname
,
TSDB_FILENAME_LEN
)
!=
0
)
return
false
;
...
...
@@ -326,6 +328,9 @@ const TFILE *tfsReaddir(TDIR *tdir) {
struct
dirent
*
dp
=
NULL
;
dp
=
readdir
(
tdir
->
dir
);
if
(
dp
!=
NULL
)
{
// Skip . and ..
if
(
strcmp
(
dp
->
d_name
,
"."
)
==
0
||
strcmp
(
dp
->
d_name
,
".."
)
==
0
)
continue
;
snprintf
(
bname
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
tdir
->
dirname
,
dp
->
d_name
);
tfsInitFile
(
&
(
tdir
->
tfile
),
tdir
->
level
,
tdir
->
id
,
bname
);
return
&
(
tdir
->
tfile
);
...
...
src/tsdb/inc/tsdbint.h
浏览文件 @
6628a47e
...
...
@@ -95,6 +95,8 @@ int tsdbUnlockRepo(STsdbRepo* pRepo);
STsdbMeta
*
tsdbGetMeta
(
STsdbRepo
*
pRepo
);
int
tsdbCheckCommit
(
STsdbRepo
*
pRepo
);
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
);
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[]);
static
FORCE_INLINE
STsdbBufBlock
*
tsdbGetCurrBufBlock
(
STsdbRepo
*
pRepo
)
{
ASSERT
(
pRepo
!=
NULL
);
...
...
src/tsdb/src/tsdbFS.c
浏览文件 @
6628a47e
...
...
@@ -26,6 +26,9 @@ static void tsdbApplyFSTxnOnDisk(SFSStatus *pFrom, SFSStatus *pTo);
static
void
tsdbGetTxnFname
(
int
repoid
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[]);
static
int
tsdbOpenFSFromCurrent
(
STsdbRepo
*
pRepo
);
static
int
tsdbScanAndTryFixFS
(
STsdbRepo
*
pRepo
);
static
int
tsdbScanRootDir
(
STsdbRepo
*
pRepo
);
static
int
tsdbScanDataDir
(
STsdbRepo
*
pRepo
);
static
bool
tsdbIsTFileInFS
(
STsdbFS
*
pfs
,
const
TFILE
*
pf
);
// ================== CURRENT file header info
static
int
tsdbEncodeFSHeader
(
void
**
buf
,
SFSHeader
*
pHeader
)
{
...
...
@@ -683,9 +686,9 @@ static int tsdbScanAndTryFixFS(STsdbRepo *pRepo) {
}
}
//
TODO
: remove those unused files
{}
// : remove those unused files
tsdbScanRootDir
(
pRepo
);
tsdbScanDataDir
(
pRepo
);
return
0
;
}
...
...
@@ -699,8 +702,6 @@ int tsdbLoadMetaCache(STsdbRepo *pRepo, bool recoverMeta) {
int64_t
maxBufSize
=
0
;
SMFInfo
minfo
;
// TODO: clear meta at first
// No meta file, just return
if
(
pfs
->
cstatus
->
pmf
==
NULL
)
return
0
;
...
...
@@ -817,4 +818,82 @@ int tsdbLoadMetaCache(STsdbRepo *pRepo, bool recoverMeta) {
tsdbCloseMFile
(
pMFile
);
tfree
(
pBuf
);
return
0
;
}
static
int
tsdbScanRootDir
(
STsdbRepo
*
pRepo
)
{
char
rootDir
[
TSDB_FILENAME_LEN
];
char
bname
[
TSDB_FILENAME_LEN
];
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
const
TFILE
*
pf
;
tsdbGetRootDir
(
REPO_ID
(
pRepo
),
rootDir
);
TDIR
*
tdir
=
tfsOpendir
(
rootDir
);
if
(
tdir
==
NULL
)
{
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
rootDir
,
tstrerror
(
terrno
));
return
-
1
;
}
while
((
pf
=
tfsReaddir
(
tdir
)))
{
tfsbasename
(
pf
,
bname
);
if
(
strcmp
(
bname
,
tsdbTxnFname
[
TSDB_TXN_CURR_FILE
])
==
0
||
strcmp
(
bname
,
"data"
)
==
0
)
{
// Skip current file and data directory
continue
;
}
if
(
tfsIsSameFile
(
pf
,
&
(
pfs
->
cstatus
->
pmf
->
f
)))
{
continue
;
}
tfsremove
(
pf
);
tsdbDebug
(
"vgId:%d invalid file %s is removed"
,
REPO_ID
(
pRepo
),
TFILE_NAME
(
pf
));
}
tfsClosedir
(
tdir
);
return
0
;
}
static
int
tsdbScanDataDir
(
STsdbRepo
*
pRepo
)
{
char
dataDir
[
TSDB_FILENAME_LEN
];
char
bname
[
TSDB_FILENAME_LEN
];
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
const
TFILE
*
pf
;
tsdbGetDataDir
(
REPO_ID
(
pRepo
),
dataDir
);
TDIR
*
tdir
=
tfsOpendir
(
dataDir
);
if
(
tdir
==
NULL
)
{
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tstrerror
(
terrno
));
return
-
1
;
}
while
((
pf
=
tfsReaddir
(
tdir
)))
{
tfsbasename
(
pf
,
bname
);
if
(
!
tsdbIsTFileInFS
(
pfs
,
pf
))
{
tfsremove
(
pf
);
tsdbDebug
(
"vgId:%d invalid file %s is removed"
,
REPO_ID
(
pRepo
),
TFILE_NAME
(
pf
));
}
}
tfsClosedir
(
tdir
);
return
0
;
}
static
bool
tsdbIsTFileInFS
(
STsdbFS
*
pfs
,
const
TFILE
*
pf
)
{
SFSIter
fsiter
;
tsdbFSIterInit
(
&
fsiter
,
pfs
,
TSDB_FS_ITER_FORWARD
);
SDFileSet
*
pSet
;
while
((
pSet
=
tsdbFSIterNext
(
&
fsiter
)))
{
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
SDFile
*
pDFile
=
TSDB_DFILE_IN_SET
(
pSet
,
ftype
);
if
(
tfsIsSameFile
(
pf
,
TSDB_FILE_F
(
pDFile
)))
{
return
true
;
}
}
}
return
false
;
}
\ No newline at end of file
src/tsdb/src/tsdbMain.c
浏览文件 @
6628a47e
...
...
@@ -21,8 +21,6 @@
#define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP
#define IS_VALID_COMPRESSION(compression) (((compression) >= NO_COMPRESSION) && ((compression) <= TWO_STAGE_COMP))
static
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[]);
static
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
static
int32_t
tsdbCheckAndSetDefaultCfg
(
STsdbCfg
*
pCfg
);
static
STsdbRepo
*
tsdbNewRepo
(
STsdbCfg
*
pCfg
,
STsdbAppH
*
pAppH
);
static
void
tsdbFreeRepo
(
STsdbRepo
*
pRepo
);
...
...
@@ -334,11 +332,11 @@ uint32_t tsdbGetFileInfo(STsdbRepo *repo, char *name, uint32_t *index, uint32_t
#endif
}
static
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[])
{
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[])
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/tsdb"
,
repoid
);
}
static
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[])
{
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[])
{
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/tsdb/data"
,
repoid
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录