Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
543b17cb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
543b17cb
编写于
7月 15, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-4352]fix tsdb meta compact bug
上级
2d0bca42
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
20 deletion
+17
-20
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+0
-1
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+15
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+2
-18
未找到文件。
src/tsdb/inc/tsdbFile.h
浏览文件 @
543b17cb
...
...
@@ -57,7 +57,6 @@ typedef struct {
}
SMFile
;
void
tsdbInitMFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
,
bool
tmp
);
void
tsdbRenameOrDeleleTempMetaFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
,
int
code
);
void
tsdbInitMFileEx
(
SMFile
*
pMFile
,
const
SMFile
*
pOMFile
);
int
tsdbEncodeSMFile
(
void
**
buf
,
SMFile
*
pMFile
);
void
*
tsdbDecodeSMFile
(
void
*
buf
,
SMFile
*
pMFile
);
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
543b17cb
...
...
@@ -460,6 +460,11 @@ static int tsdbCompactMetaFile(STsdbRepo *pRepo, STsdbFS *pfs, SMFile *pMFile) {
return
0
;
}
if
(
tsdbOpenMFile
(
pMFile
,
O_RDONLY
)
<
0
)
{
tsdbError
(
"open meta file %s compact fail"
,
pMFile
->
f
.
rname
);
return
-
1
;
}
tsdbInfo
(
"begin compact tsdb meta file, nDels:%"
PRId64
",nRecords:%"
PRId64
",tombSize:%"
PRId64
",size:%"
PRId64
,
pMFile
->
info
.
nDels
,
pMFile
->
info
.
nRecords
,
pMFile
->
info
.
tombSize
,
pMFile
->
info
.
size
);
...
...
@@ -530,10 +535,19 @@ static int tsdbCompactMetaFile(STsdbRepo *pRepo, STsdbFS *pfs, SMFile *pMFile) {
_err:
TSDB_FILE_FSYNC
(
&
mf
);
tsdbCloseMFile
(
&
mf
);
tsdbCloseMFile
(
pMFile
);
tsdbRenameOrDeleleTempMetaFile
(
&
mf
,
did
,
REPO_ID
(
pRepo
),
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
code
);
if
(
code
==
0
)
{
// rename meta.tmp -> meta
taosRename
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
);
tstrncpy
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
,
TSDB_FILENAME_LEN
);
tstrncpy
(
mf
.
f
.
rname
,
pMFile
->
f
.
rname
,
TSDB_FILENAME_LEN
);
// update current meta file info
pfs
->
nstatus
->
pmf
=
NULL
;
tsdbUpdateMFile
(
pfs
,
&
mf
);
}
else
{
// remove meta.tmp file
remove
(
mf
.
f
.
aname
);
}
tfree
(
pBuf
);
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
543b17cb
...
...
@@ -20,8 +20,8 @@ static const char *TSDB_FNAME_SUFFIX[] = {
"data"
,
// TSDB_FILE_DATA
"last"
,
// TSDB_FILE_LAST
""
,
// TSDB_FILE_MAX
"meta"
// TSDB_FILE_META
"meta.tmp"
// TSDB_FILE_META_TMP
"meta"
,
// TSDB_FILE_META
"meta.tmp"
,
// TSDB_FILE_META_TMP
};
static
void
tsdbGetFilename
(
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
,
char
*
fname
);
...
...
@@ -43,22 +43,6 @@ void tsdbInitMFile(SMFile *pMFile, SDiskID did, int vid, uint32_t ver, bool tmp)
tfsInitFile
(
TSDB_FILE_F
(
pMFile
),
did
.
level
,
did
.
id
,
fname
);
}
void
tsdbRenameOrDeleleTempMetaFile
(
SMFile
*
pMFile
,
SDiskID
did
,
int
vid
,
uint32_t
ver
,
int
code
)
{
char
mfname
[
TSDB_FILENAME_LEN
]
=
{
'\0'
};
char
tfname
[
TSDB_FILENAME_LEN
]
=
{
'\0'
};
tsdbGetFilename
(
vid
,
0
,
ver
,
TSDB_FILE_META_TMP
,
tfname
);
if
(
code
!=
0
)
{
remove
(
tfname
);
return
;
}
tsdbGetFilename
(
vid
,
0
,
ver
,
TSDB_FILE_META
,
mfname
);
(
void
)
taosRename
(
tfname
,
mfname
);
}
void
tsdbInitMFileEx
(
SMFile
*
pMFile
,
const
SMFile
*
pOMFile
)
{
*
pMFile
=
*
pOMFile
;
TSDB_FILE_SET_CLOSED
(
pMFile
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录