Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
9958b3d8
TDengine
项目概览
lzh_me
/
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,发现更多精彩内容 >>
提交
9958b3d8
编写于
5月 20, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1920]add mnode compact wal functions
上级
99f73593
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
11 deletion
+41
-11
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+2
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+2
-0
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+11
-0
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+1
-3
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+25
-8
未找到文件。
src/common/inc/tglobal.h
浏览文件 @
9958b3d8
...
@@ -149,6 +149,8 @@ extern char configDir[];
...
@@ -149,6 +149,8 @@ extern char configDir[];
extern
char
tsVnodeDir
[];
extern
char
tsVnodeDir
[];
extern
char
tsDnodeDir
[];
extern
char
tsDnodeDir
[];
extern
char
tsMnodeDir
[];
extern
char
tsMnodeDir
[];
extern
char
tsMnodeBakDir
[];
extern
char
tsMnodeTmpDir
[];
extern
char
tsDataDir
[];
extern
char
tsDataDir
[];
extern
char
tsLogDir
[];
extern
char
tsLogDir
[];
extern
char
tsScriptDir
[];
extern
char
tsScriptDir
[];
...
...
src/common/src/tglobal.c
浏览文件 @
9958b3d8
...
@@ -183,6 +183,8 @@ char configDir[TSDB_FILENAME_LEN] = {0};
...
@@ -183,6 +183,8 @@ char configDir[TSDB_FILENAME_LEN] = {0};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeTmpDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeBakDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsTempDir
[
TSDB_FILENAME_LEN
]
=
"/tmp/"
;
char
tsTempDir
[
TSDB_FILENAME_LEN
]
=
"/tmp/"
;
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
9958b3d8
...
@@ -217,6 +217,17 @@ static int32_t dnodeInitStorage() {
...
@@ -217,6 +217,17 @@ static int32_t dnodeInitStorage() {
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
// sprintf(tsVnodeBakDir, "%s/vnode_bak", tsDataDir);
// sprintf(tsVnodeBakDir, "%s/vnode_bak", tsDataDir);
if
(
tsCompactMnodeWal
==
1
)
{
sprintf
(
tsMnodeTmpDir
,
"%s/mnode_tmp"
,
tsDataDir
);
tfsRmdir
(
tsMnodeTmpDir
);
if
(
dnodeCreateDir
(
tsMnodeTmpDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeTmpDir
,
strerror
(
errno
));
return
-
1
;
}
sprintf
(
tsMnodeBakDir
,
"%s/mnode_bak"
,
tsDataDir
);
//tfsRmdir(tsMnodeBakDir);
}
//TODO(dengyihao): no need to init here
//TODO(dengyihao): no need to init here
if
(
dnodeCreateDir
(
tsMnodeDir
)
<
0
)
{
if
(
dnodeCreateDir
(
tsMnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
9958b3d8
...
@@ -59,8 +59,6 @@ static SStep tsMnodeSteps[] = {
...
@@ -59,8 +59,6 @@ static SStep tsMnodeSteps[] = {
static
SStep
tsMnodeCompactSteps
[]
=
{
static
SStep
tsMnodeCompactSteps
[]
=
{
{
"cluster"
,
mnodeCompactCluster
,
NULL
},
{
"cluster"
,
mnodeCompactCluster
,
NULL
},
/*
{
"dnodes"
,
mnodeCompactDnodes
,
NULL
},
{
"dnodes"
,
mnodeCompactDnodes
,
NULL
},
{
"mnodes"
,
mnodeCompactMnodes
,
NULL
},
{
"mnodes"
,
mnodeCompactMnodes
,
NULL
},
{
"accts"
,
mnodeCompactAccts
,
NULL
},
{
"accts"
,
mnodeCompactAccts
,
NULL
},
...
@@ -68,7 +66,7 @@ static SStep tsMnodeCompactSteps[] = {
...
@@ -68,7 +66,7 @@ static SStep tsMnodeCompactSteps[] = {
{
"dbs"
,
mnodeCompactDbs
,
NULL
},
{
"dbs"
,
mnodeCompactDbs
,
NULL
},
{
"vgroups"
,
mnodeCompactVgroups
,
NULL
},
{
"vgroups"
,
mnodeCompactVgroups
,
NULL
},
{
"tables"
,
mnodeCompactTables
,
NULL
},
{
"tables"
,
mnodeCompactTables
,
NULL
},
*/
};
};
static
void
mnodeInitTimer
();
static
void
mnodeInitTimer
();
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
9958b3d8
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "tutil.h"
#include "tutil.h"
#include "tref.h"
#include "tref.h"
#include "tbn.h"
#include "tbn.h"
#include "tfs.h"
#include "tqueue.h"
#include "tqueue.h"
#include "twal.h"
#include "twal.h"
#include "tsync.h"
#include "tsync.h"
...
@@ -1154,26 +1155,42 @@ int32_t sdbGetReplicaNum() {
...
@@ -1154,26 +1155,42 @@ int32_t sdbGetReplicaNum() {
int32_t
mnodeCompactWal
()
{
int32_t
mnodeCompactWal
()
{
sdbInfo
(
"vgId:1, start compact mnode wal..."
);
sdbInfo
(
"vgId:1, start compact mnode wal..."
);
// close wal
// close
old
wal
walFsync
(
tsSdbMgmt
.
wal
,
true
);
walFsync
(
tsSdbMgmt
.
wal
,
true
);
walClose
(
tsSdbMgmt
.
wal
);
walClose
(
tsSdbMgmt
.
wal
);
// change wal to wal_bak dir
// reset version,then compacted wal log can start from version 1
char
temp
[
TSDB_FILENAME_LEN
]
=
{
0
};
tsSdbMgmt
.
version
=
0
;
// change wal to wal_tmp dir
SWalCfg
walCfg
=
{.
vgId
=
1
,
.
walLevel
=
TAOS_WAL_FSYNC
,
.
keep
=
TAOS_WAL_KEEP
,
.
fsyncPeriod
=
0
};
SWalCfg
walCfg
=
{.
vgId
=
1
,
.
walLevel
=
TAOS_WAL_FSYNC
,
.
keep
=
TAOS_WAL_KEEP
,
.
fsyncPeriod
=
0
};
sprintf
(
temp
,
"%s/wal_tmp"
,
tsMnodeDir
);
char
temp
[
TSDB_FILENAME_LEN
]
=
{
0
};
if
(
mkdir
(
temp
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
sprintf
(
temp
,
"%s/wal"
,
tsMnodeTmpDir
);
return
-
1
;
}
tsSdbMgmt
.
wal
=
walOpen
(
temp
,
&
walCfg
);
tsSdbMgmt
.
wal
=
walOpen
(
temp
,
&
walCfg
);
walRenew
(
tsSdbMgmt
.
wal
);
walRenew
(
tsSdbMgmt
.
wal
);
// compact memory tables info to wal tmp dir
// compact memory tables info to wal tmp dir
mnodeCompactComponents
();
if
(
mnodeCompactComponents
()
!=
0
)
{
tfsRmdir
(
tsMnodeTmpDir
);
return
-
1
;
}
// close wal
// close wal
walFsync
(
tsSdbMgmt
.
wal
,
true
);
walFsync
(
tsSdbMgmt
.
wal
,
true
);
walClose
(
tsSdbMgmt
.
wal
);
walClose
(
tsSdbMgmt
.
wal
);
// rename old wal to wal_bak
if
(
taosRename
(
tsMnodeDir
,
tsMnodeBakDir
)
!=
0
)
{
return
-
1
;
}
// rename wal_tmp to wal
if
(
taosRename
(
tsMnodeTmpDir
,
tsMnodeDir
)
!=
0
)
{
return
-
1
;
}
// del wal_tmp dir
sdbInfo
(
"vgId:1, compact mnode wal success"
);
return
0
;
return
0
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录