Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a194ea05
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a194ea05
编写于
11月 08, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change wal cfg options
上级
88f7e7d7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
16 addition
and
19 deletion
+16
-19
src/inc/twal.h
src/inc/twal.h
+9
-5
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+1
-1
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+1
-2
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+1
-1
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+4
-5
src/wal/test/waltest.c
src/wal/test/waltest.c
+0
-5
未找到文件。
src/inc/twal.h
浏览文件 @
a194ea05
...
...
@@ -25,6 +25,11 @@ typedef enum {
TAOS_WAL_FSYNC
=
2
}
EWalType
;
typedef
enum
{
TAOS_WAL_NOT_KEEP
=
0
,
TAOS_WAL_KEEP
=
1
}
EWalKeep
;
typedef
struct
{
int8_t
msgType
;
int8_t
reserved
[
3
];
...
...
@@ -36,11 +41,10 @@ typedef struct {
}
SWalHead
;
typedef
struct
{
int32_t
vgId
;
int32_t
fsyncPeriod
;
// millisecond
int8_t
walLevel
;
// wal level
int8_t
wals
;
// number of WAL files;
int8_t
keep
;
// keep the wal file when closed
int32_t
vgId
;
int32_t
fsyncPeriod
;
// millisecond
EWalType
walLevel
;
// wal level
EWalKeep
keep
;
// keep the wal file when closed
}
SWalCfg
;
typedef
void
*
twalh
;
// WAL HANDLE
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
a194ea05
...
...
@@ -175,7 +175,7 @@ static void *sdbGetTableFromId(int32_t tableId) {
}
static
int32_t
sdbInitWal
()
{
SWalCfg
walCfg
=
{.
vgId
=
1
,
.
walLevel
=
2
,
.
wals
=
2
,
.
keep
=
1
,
.
fsyncPeriod
=
0
};
SWalCfg
walCfg
=
{.
vgId
=
1
,
.
walLevel
=
TAOS_WAL_FSYNC
,
.
keep
=
TAOS_WAL_KEEP
,
.
fsyncPeriod
=
0
};
char
temp
[
TSDB_FILENAME_LEN
];
sprintf
(
temp
,
"%s/wal"
,
tsMnodeDir
);
tsSdbObj
.
wal
=
walOpen
(
temp
,
&
walCfg
);
...
...
src/vnode/src/vnodeCfg.c
浏览文件 @
a194ea05
...
...
@@ -39,8 +39,7 @@ static void vnodeLoadCfg(SVnodeObj *pVnode, SCreateVnodeMsg* vnodeMsg) {
pVnode
->
tsdbCfg
.
compression
=
vnodeMsg
->
cfg
.
compression
;
pVnode
->
walCfg
.
walLevel
=
vnodeMsg
->
cfg
.
walLevel
;
pVnode
->
walCfg
.
fsyncPeriod
=
vnodeMsg
->
cfg
.
fsyncPeriod
;
pVnode
->
walCfg
.
wals
=
vnodeMsg
->
cfg
.
wals
;
pVnode
->
walCfg
.
keep
=
0
;
pVnode
->
walCfg
.
keep
=
TAOS_WAL_NOT_KEEP
;
pVnode
->
syncCfg
.
replica
=
vnodeMsg
->
cfg
.
replications
;
pVnode
->
syncCfg
.
quorum
=
vnodeMsg
->
cfg
.
quorum
;
...
...
src/wal/src/walMgmt.c
浏览文件 @
a194ea05
...
...
@@ -128,7 +128,7 @@ void walClose(void *handle) {
taosClose
(
pWal
->
fd
);
if
(
!
pWal
->
keep
)
{
if
(
pWal
->
keep
!=
TAOS_WAL_KEEP
)
{
int64_t
fileId
=
-
1
;
while
(
walGetNextFile
(
pWal
,
&
fileId
)
>=
0
)
{
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
fileId
);
...
...
src/wal/src/walWrite.c
浏览文件 @
a194ea05
...
...
@@ -41,7 +41,7 @@ int32_t walRenew(void *handle) {
wDebug
(
"vgId:%d, file:%s, it is closed"
,
pWal
->
vgId
,
pWal
->
name
);
}
if
(
pWal
->
keep
)
{
if
(
pWal
->
keep
==
TAOS_WAL_KEEP
)
{
pWal
->
fileId
=
0
;
}
else
{
if
(
walGetNewFile
(
pWal
,
&
pWal
->
fileId
)
!=
0
)
pWal
->
fileId
=
0
;
...
...
@@ -58,7 +58,7 @@ int32_t walRenew(void *handle) {
wDebug
(
"vgId:%d, file:%s, it is created"
,
pWal
->
vgId
,
pWal
->
name
);
}
if
(
!
pWal
->
keep
)
{
if
(
pWal
->
keep
!=
TAOS_WAL_KEEP
)
{
// remove the oldest wal file
int64_t
oldFileId
=
-
1
;
if
(
walGetOldFile
(
pWal
,
pWal
->
fileId
,
WAL_FILE_NUM
,
&
oldFileId
)
==
0
)
{
...
...
@@ -144,12 +144,12 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) {
continue
;
}
wDebug
(
"vgId:%d, file:%s, restore success
and keep it
"
,
pWal
->
vgId
,
walName
);
wDebug
(
"vgId:%d, file:%s, restore success"
,
pWal
->
vgId
,
walName
);
count
++
;
}
if
(
!
pWal
->
keep
)
return
TSDB_CODE_SUCCESS
;
if
(
pWal
->
keep
!=
TAOS_WAL_KEEP
)
return
TSDB_CODE_SUCCESS
;
if
(
count
==
0
)
{
wDebug
(
"vgId:%d, wal file not exist, renew it"
,
pWal
->
vgId
);
...
...
@@ -173,7 +173,6 @@ int32_t walGetWalFile(void *handle, char *fileName, int64_t *fileId) {
if
(
handle
==
NULL
)
return
-
1
;
SWal
*
pWal
=
handle
;
// for keep
if
(
*
fileId
==
0
)
*
fileId
=
-
1
;
pthread_mutex_lock
(
&
(
pWal
->
mutex
));
...
...
src/wal/test/waltest.c
浏览文件 @
a194ea05
...
...
@@ -37,7 +37,6 @@ int writeToQueue(void *pVnode, void *data, int type, void *pMsg) {
int
main
(
int
argc
,
char
*
argv
[])
{
char
path
[
128
]
=
"/home/jhtao/test/wal"
;
int
max
=
3
;
int
level
=
2
;
int
total
=
5
;
int
rows
=
10000
;
...
...
@@ -47,8 +46,6 @@ int main(int argc, char *argv[]) {
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
&&
i
<
argc
-
1
)
{
tstrncpy
(
path
,
argv
[
++
i
],
sizeof
(
path
));
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
&&
i
<
argc
-
1
)
{
max
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
&&
i
<
argc
-
1
)
{
level
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
&&
i
<
argc
-
1
)
{
...
...
@@ -66,7 +63,6 @@ int main(int argc, char *argv[]) {
}
else
{
printf
(
"
\n
usage: %s [options]
\n
"
,
argv
[
0
]);
printf
(
" [-p path]: wal file path default is:%s
\n
"
,
path
);
printf
(
" [-m max]: max wal files, default is:%d
\n
"
,
max
);
printf
(
" [-l level]: log level, default is:%d
\n
"
,
level
);
printf
(
" [-t total]: total wal files, default is:%d
\n
"
,
total
);
printf
(
" [-r rows]: rows of records per wal file, default is:%d
\n
"
,
rows
);
...
...
@@ -82,7 +78,6 @@ int main(int argc, char *argv[]) {
SWalCfg
walCfg
;
walCfg
.
walLevel
=
level
;
walCfg
.
wals
=
max
;
walCfg
.
keep
=
keep
;
pWal
=
walOpen
(
path
,
&
walCfg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录