Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f346de9
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看板
提交
2f346de9
编写于
9月 29, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix TD-1635
上级
38c6df29
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
10 deletion
+45
-10
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+5
-1
src/wal/src/walMain.c
src/wal/src/walMain.c
+39
-9
未找到文件。
src/inc/taoserror.h
浏览文件 @
2f346de9
...
...
@@ -246,6 +246,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "Sync modul
// wal
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in wal"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_FILE_CORRUPTED
,
0
,
0x1001
,
"WAL file is corrupted"
)
// http
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_SERVER_OFFLINE
,
0
,
0x1100
,
"http server is not onlin"
)
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
2f346de9
...
...
@@ -185,7 +185,11 @@ static int32_t sdbInitWal() {
}
sdbInfo
(
"open sdb wal for restore"
);
walRestore
(
tsSdbObj
.
wal
,
NULL
,
sdbWrite
);
int
code
=
walRestore
(
tsSdbObj
.
wal
,
NULL
,
sdbWrite
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sdbError
(
"failed to open wal for restore, reason:%s"
,
tstrerror
(
code
));
return
-
1
;
}
return
0
;
}
...
...
src/wal/src/walMain.c
浏览文件 @
2f346de9
...
...
@@ -347,9 +347,10 @@ static void walRelease(SWal *pWal) {
static
int
walRestoreWalFile
(
SWal
*
pWal
,
void
*
pVnode
,
FWalWrite
writeFp
)
{
char
*
name
=
pWal
->
name
;
int
size
=
1024
*
1024
;
// default 1M buffer size
terrno
=
0
;
char
*
buffer
=
malloc
(
1024000
);
// size for one record
char
*
buffer
=
malloc
(
size
);
if
(
buffer
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
terrno
;
...
...
@@ -357,7 +358,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
SWalHead
*
pHead
=
(
SWalHead
*
)
buffer
;
int
fd
=
open
(
name
,
O_RD
ONLY
);
int
fd
=
open
(
name
,
O_RD
WR
);
if
(
fd
<
0
)
{
wError
(
"wal:%s, failed to open for restore(%s)"
,
name
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -367,29 +368,58 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
wDebug
(
"wal:%s, start to restore"
,
name
);
size_t
offset
=
0
;
while
(
1
)
{
int
ret
=
taosTRead
(
fd
,
pHead
,
sizeof
(
SWalHead
));
if
(
ret
==
0
)
break
;
if
(
ret
==
0
)
break
;
if
(
ret
!=
sizeof
(
SWalHead
)
)
{
w
Warn
(
"wal:%s, failed to read head, skip, ret:%d(%s)"
,
name
,
ret
,
strerror
(
errno
));
if
(
ret
<
0
)
{
w
Error
(
"wal:%s, failed to read wal head part since %s"
,
name
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
}
if
(
ret
<
sizeof
(
SWalHead
))
{
wError
(
"wal:%s, failed to read head, ret:%d, skip the rest of file"
,
name
,
ret
);
taosFtruncate
(
fd
,
offset
);
fsync
(
fd
);
break
;
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
wWarn
(
"wal:%s, cksum is messed up, skip the rest of file"
,
name
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
false
);
break
;
}
}
if
(
pHead
->
len
>
size
-
sizeof
(
SWalHead
))
{
size
=
sizeof
(
SWalHead
)
+
pHead
->
len
;
buffer
=
realloc
(
buffer
,
size
);
if
(
buffer
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
}
pHead
=
(
SWalHead
*
)
buffer
;
}
ret
=
taosTRead
(
fd
,
pHead
->
cont
,
pHead
->
len
);
if
(
ret
!=
pHead
->
len
)
{
w
Warn
(
"wal:%s, failed to read body, skip, len:%d ret:%d"
,
name
,
pHead
->
len
,
ret
);
if
(
ret
<
0
)
{
w
Error
(
"wal:%s failed to read wal body part since %s"
,
name
,
strerror
(
errno
)
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
break
;
}
if
(
ret
<
pHead
->
len
)
{
wError
(
"wal:%s, failed to read body, len:%d ret:%d, skip the rest of file"
,
name
,
pHead
->
len
,
ret
);
taosFtruncate
(
fd
,
offset
);
fsync
(
fd
);
break
;
}
offset
=
offset
+
sizeof
(
SWalHead
)
+
pHead
->
len
;
if
(
pWal
->
keep
)
pWal
->
version
=
pHead
->
version
;
(
*
writeFp
)(
pVnode
,
pHead
,
TAOS_QTYPE_WAL
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录