Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
7337f759
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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,发现更多精彩内容 >>
提交
7337f759
编写于
3月 30, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add new API walGetWalFile
上级
6b02bd26
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
12 deletion
+12
-12
src/vnode/wal/inc/twal.h
src/vnode/wal/inc/twal.h
+1
-1
src/vnode/wal/src/walMain.c
src/vnode/wal/src/walMain.c
+10
-10
src/vnode/wal/test/waltest.c
src/vnode/wal/test/waltest.c
+1
-1
未找到文件。
src/vnode/wal/inc/twal.h
浏览文件 @
7337f759
...
...
@@ -41,7 +41,7 @@ int walRenew(twal_h);
int
walWrite
(
twal_h
,
SWalHead
*
);
void
walFsync
(
twal_h
);
int
walRestore
(
twal_h
,
void
*
pVnode
,
int
(
*
writeFp
)(
void
*
ahandle
,
void
*
pWalHead
));
int
walGetWalFile
(
twal_h
,
char
*
name
,
int32_t
*
index
);
int
walGetWalFile
(
twal_h
,
char
*
name
,
u
int32_t
*
index
);
extern
int
wDebugFlag
;
...
...
src/vnode/wal/src/walMain.c
浏览文件 @
7337f759
...
...
@@ -37,7 +37,7 @@ typedef struct {
int
fd
;
int
level
;
int
max
;
// maximum number of wal files
uint
64
_t
id
;
// increase continuously
uint
32
_t
id
;
// increase continuously
int
num
;
// number of wal files
char
path
[
TSDB_FILENAME_LEN
];
char
name
[
TSDB_FILENAME_LEN
];
...
...
@@ -86,7 +86,7 @@ void walClose(void *handle) {
// remove all files in the directory
for
(
int
i
=
0
;
i
<
pWal
->
num
;
++
i
)
{
sprintf
(
pWal
->
name
,
"%s/%s%
l
d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
i
);
sprintf
(
pWal
->
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
i
);
if
(
remove
(
pWal
->
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove"
,
pWal
->
name
);
}
else
{
...
...
@@ -113,7 +113,7 @@ int walRenew(twal_h handle) {
pWal
->
num
++
;
sprintf
(
pWal
->
name
,
"%s/%s%
l
d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
);
sprintf
(
pWal
->
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
...
...
@@ -125,7 +125,7 @@ int walRenew(twal_h handle) {
if
(
pWal
->
num
>
pWal
->
max
)
{
// remove the oldest wal file
char
name
[
TSDB_FILENAME_LEN
];
sprintf
(
name
,
"%s/%s%
l
d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
pWal
->
max
);
sprintf
(
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
pWal
->
max
);
if
(
remove
(
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove(%s)"
,
name
,
strerror
(
errno
));
}
else
{
...
...
@@ -173,7 +173,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *)) {
int
code
=
0
;
struct
dirent
*
ent
;
int
count
=
0
;
uint
64
_t
maxId
=
0
,
minId
=
-
1
,
index
=
0
;
uint
32
_t
maxId
=
0
,
minId
=
-
1
,
index
=
0
;
int
plen
=
strlen
(
walPrefix
);
char
opath
[
TSDB_FILENAME_LEN
];
...
...
@@ -185,7 +185,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *)) {
DIR
*
dir
=
opendir
(
opath
);
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
index
=
atol
l
(
ent
->
d_name
+
plen
);
index
=
atol
(
ent
->
d_name
+
plen
);
if
(
index
>
maxId
)
maxId
=
index
;
if
(
index
<
minId
)
minId
=
index
;
count
++
;
...
...
@@ -193,13 +193,13 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *)) {
}
if
(
count
!=
(
maxId
-
minId
+
1
)
)
{
wError
(
"wal:%s, messed up, count:%d max:%
ld min:%l
d"
,
opath
,
count
,
maxId
,
minId
);
wError
(
"wal:%s, messed up, count:%d max:%
d min:%
d"
,
opath
,
count
,
maxId
,
minId
);
code
=
-
1
;
}
else
{
wTrace
(
"wal:%s, %d files will be restored"
,
opath
,
count
);
for
(
index
=
minId
;
index
<=
maxId
;
++
index
)
{
sprintf
(
pWal
->
name
,
"%s/old/%s%
l
d"
,
pWal
->
path
,
walPrefix
,
index
);
sprintf
(
pWal
->
name
,
"%s/old/%s%d"
,
pWal
->
path
,
walPrefix
,
index
);
code
=
walRestoreWalFile
(
pWal
->
name
,
pVnode
,
writeFp
);
if
(
code
<
0
)
break
;
}
...
...
@@ -220,7 +220,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *)) {
return
code
;
}
int
walGetWalFile
(
void
*
handle
,
char
*
name
,
int32_t
*
index
)
{
int
walGetWalFile
(
void
*
handle
,
char
*
name
,
u
int32_t
*
index
)
{
SWal
*
pWal
=
(
SWal
*
)
handle
;
int
code
=
1
;
int32_t
first
=
0
;
...
...
@@ -236,7 +236,7 @@ int walGetWalFile(void *handle, char *name, int32_t *index) {
if
(
*
index
<
first
&&
*
index
>
pWal
->
id
)
{
code
=
-
1
;
// index out of range
}
else
{
sprintf
(
name
,
"%s/%s%
l
d"
,
pWal
->
path
,
walPrefix
,
*
index
);
sprintf
(
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
*
index
);
code
=
(
*
index
==
pWal
->
id
)
?
0
:
1
;
}
...
...
src/vnode/wal/test/waltest.c
浏览文件 @
7337f759
...
...
@@ -106,7 +106,7 @@ int main(int argc, char *argv[]) {
printf
(
"%d wal files are written
\n
"
,
total
);
int32_t
index
=
0
;
u
int32_t
index
=
0
;
char
name
[
256
];
while
(
1
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录