Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
89789920
T
TDengine
项目概览
小楼昨夜-听风雨
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89789920
编写于
10月 30, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1846
上级
08c82ac3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
10 deletion
+13
-10
src/wal/inc/walInt.h
src/wal/inc/walInt.h
+2
-2
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+3
-6
src/wal/src/walUtil.c
src/wal/src/walUtil.c
+1
-1
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+7
-1
未找到文件。
src/wal/inc/walInt.h
浏览文件 @
89789920
...
...
@@ -38,22 +38,22 @@ extern int32_t wDebugFlag;
#define WAL_SIGNATURE ((uint32_t)(0xFAFBFDFE))
#define WAL_PATH_LEN (TSDB_FILENAME_LEN + 12)
#define WAL_FILE_LEN (TSDB_FILENAME_LEN + 32)
#define WAL_FILE_NUM 3
typedef
struct
{
uint64_t
version
;
int64_t
fileId
;
int32_t
vgId
;
int32_t
fd
;
int32_t
keep
;
int32_t
level
;
int32_t
fsyncPeriod
;
int32_t
fsyncSeq
;
int64_t
fileId
;
char
path
[
WAL_PATH_LEN
];
char
name
[
WAL_FILE_LEN
];
pthread_mutex_t
mutex
;
}
SWal
;
// util
int32_t
walGetNextFile
(
SWal
*
pWal
,
int64_t
*
nextFileId
);
int32_t
walGetOldFile
(
SWal
*
pWal
,
int64_t
curFileId
,
int32_t
minDiff
,
int64_t
*
oldFileId
);
...
...
src/wal/src/walMgmt.c
浏览文件 @
89789920
...
...
@@ -18,7 +18,6 @@
#include "taoserror.h"
#include "talloc.h"
#include "tref.h"
#include "tutil.h"
#include "twal.h"
#include "walInt.h"
...
...
@@ -135,9 +134,8 @@ void walClose(void *handle) {
static
int32_t
walInitObj
(
SWal
*
pWal
)
{
if
(
taosMkDir
(
pWal
->
path
,
0755
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to create directory since %s"
,
pWal
->
vgId
,
pWal
->
path
,
strerror
(
errno
));
return
terrno
;
return
TAOS_SYSTEM_ERROR
(
errno
)
;
}
if
(
pWal
->
keep
)
{
...
...
@@ -147,9 +145,8 @@ static int32_t walInitObj(SWal *pWal) {
walRenew
(
pWal
);
if
(
pWal
&&
pWal
->
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to open file since %s"
,
pWal
->
vgId
,
pWal
->
path
,
strerror
(
errno
));
return
terrno
;
return
TAOS_SYSTEM_ERROR
(
errno
)
;
}
wDebug
(
"vgId:%d, file is initialized"
,
pWal
->
vgId
);
...
...
@@ -191,7 +188,7 @@ static void walFsyncAll() {
wTrace
(
"vgId:%d, do fsync, level:%d seq:%d rseq:%d"
,
pWal
->
vgId
,
pWal
->
level
,
pWal
->
fsyncSeq
,
tsWal
.
seq
);
int32_t
code
=
fsync
(
pWal
->
fd
);
if
(
code
!=
0
)
{
wError
(
"vgId:%d, file:%s, f
sync failed
since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
code
));
wError
(
"vgId:%d, file:%s, f
ailed to fsync
since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
code
));
}
}
pWal
=
taosIterateRef
(
tsWal
.
refId
,
pWal
);
...
...
src/wal/src/walUtil.c
浏览文件 @
89789920
...
...
@@ -82,4 +82,4 @@ int32_t walGetOldFile(SWal *pWal, int64_t curFileId, int32_t minDiff, int64_t *o
wTrace
(
"vgId:%d, path:%s, curFileId:%"
PRId64
" oldFildId:%"
PRId64
,
pWal
->
vgId
,
pWal
->
path
,
curFileId
,
*
oldFileId
);
return
0
;
}
\ No newline at end of file
}
src/wal/src/walWrite.c
浏览文件 @
89789920
...
...
@@ -51,7 +51,7 @@ int32_t walRenew(void *handle) {
if
(
!
pWal
->
keep
)
{
// remove the oldest wal file
int64_t
oldFileId
=
-
1
;
if
(
walGetOldFile
(
pWal
,
pWal
->
fileId
,
2
,
&
oldFileId
)
==
0
)
{
if
(
walGetOldFile
(
pWal
,
pWal
->
fileId
,
WAL_FILE_NUM
,
&
oldFileId
)
==
0
)
{
char
walName
[
WAL_FILE_LEN
]
=
{
0
};
snprintf
(
walName
,
sizeof
(
walName
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
oldFileId
);
...
...
@@ -161,12 +161,18 @@ 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
));
int32_t
code
=
walGetNextFile
(
pWal
,
fileId
);
if
(
code
>=
0
)
{
sprintf
(
fileName
,
"wal/%s%"
PRId64
,
WAL_PREFIX
,
*
fileId
);
code
=
(
*
fileId
==
pWal
->
fileId
)
?
0
:
1
;
}
wTrace
(
"vgId:%d, get wal file, code:%d curId:%"
PRId64
" outId:%"
PRId64
,
pWal
->
vgId
,
code
,
pWal
->
fileId
,
*
fileId
);
pthread_mutex_unlock
(
&
(
pWal
->
mutex
));
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录