Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
22182131
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
22182131
编写于
5月 12, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(wal): add log
上级
06853043
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
5 deletion
+17
-5
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+17
-5
未找到文件。
source/libs/wal/src/walRead.c
浏览文件 @
22182131
...
...
@@ -65,11 +65,18 @@ static int32_t walReadSeekFilePos(SWalReadHandle *pRead, int64_t fileFirstVer, i
ret
=
taosLSeekFile
(
pIdxTFile
,
offset
,
SEEK_SET
);
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"failed to seek idx file, ver %ld, pos: %ld, since %s"
,
ver
,
offset
,
terrstr
());
return
-
1
;
}
SWalIdxEntry
entry
;
if
(
taosReadFile
(
pIdxTFile
,
&
entry
,
sizeof
(
SWalIdxEntry
))
!=
sizeof
(
SWalIdxEntry
))
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
if
((
ret
=
taosReadFile
(
pIdxTFile
,
&
entry
,
sizeof
(
SWalIdxEntry
)))
!=
sizeof
(
SWalIdxEntry
))
{
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"failed to read idx file, since %s"
,
terrstr
());
}
else
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
wError
(
"read idx file incompletely, read bytes %d, bytes should be %lu"
,
ret
,
sizeof
(
SWalIdxEntry
));
}
return
-
1
;
}
...
...
@@ -77,6 +84,7 @@ static int32_t walReadSeekFilePos(SWalReadHandle *pRead, int64_t fileFirstVer, i
ret
=
taosLSeekFile
(
pLogTFile
,
entry
.
offset
,
SEEK_SET
);
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"failed to seek log file, ver %ld, pos: %ld, since %s"
,
ver
,
entry
.
offset
,
terrstr
());
return
-
1
;
}
return
ret
;
...
...
@@ -92,6 +100,8 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) {
TdFilePtr
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
if
(
pLogTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TSDB_CODE_WAL_INVALID_VER
;
wError
(
"cannot open file %s, since %s"
,
fnameStr
,
terrstr
());
return
-
1
;
}
...
...
@@ -99,6 +109,7 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) {
TdFilePtr
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
);
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"cannot open file %s, since %s"
,
fnameStr
,
terrstr
());
return
-
1
;
}
...
...
@@ -113,6 +124,7 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) {
return
0
;
}
if
(
ver
>
pWal
->
vers
.
lastVer
||
ver
<
pWal
->
vers
.
firstVer
)
{
wError
(
"invalid version: % "
PRId64
", first ver %ld, last ver %ld"
,
ver
,
pWal
->
vers
.
firstVer
,
pWal
->
vers
.
lastVer
);
terrno
=
TSDB_CODE_WAL_INVALID_VER
;
return
-
1
;
}
...
...
@@ -125,12 +137,13 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) {
SWalFileInfo
*
pRet
=
taosArraySearch
(
pWal
->
fileInfoSet
,
&
tmpInfo
,
compareWalFileInfo
,
TD_LE
);
ASSERT
(
pRet
!=
NULL
);
if
(
pRead
->
curFileFirstVer
!=
pRet
->
firstVer
)
{
// error code set inner
if
(
walReadChangeFile
(
pRead
,
pRet
->
firstVer
)
<
0
)
{
return
-
1
;
}
}
// code set inner
//
error
code set inner
if
(
walReadSeekFilePos
(
pRead
,
pRet
->
firstVer
,
ver
)
<
0
)
{
return
-
1
;
}
...
...
@@ -248,8 +261,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
// TODO: check wal life
if
(
pRead
->
curVersion
!=
ver
)
{
if
(
walReadSeekVer
(
pRead
,
ver
)
<
0
)
{
terrno
=
TSDB_CODE_WAL_INVALID_VER
;
wError
(
"unexpected wal log version: % "
PRId64
", since seek error"
,
ver
);
wError
(
"unexpected wal log version: % "
PRId64
", since %s"
,
ver
,
terrstr
());
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录