Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e078c739
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看板
未验证
提交
e078c739
编写于
6月 22, 2022
作者:
L
Liu Jicong
提交者:
GitHub
6月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14128 from taosdata/feature/wal
feat(wal): provide is empty api
上级
df1967de
04f11e26
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
16 addition
and
9 deletion
+16
-9
include/libs/wal/wal.h
include/libs/wal/wal.h
+1
-7
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+2
-0
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+13
-2
未找到文件。
include/libs/wal/wal.h
浏览文件 @
e078c739
...
@@ -195,7 +195,6 @@ void walCloseReadHandle(SWalReadHandle *);
...
@@ -195,7 +195,6 @@ void walCloseReadHandle(SWalReadHandle *);
int32_t
walReadWithHandle
(
SWalReadHandle
*
pRead
,
int64_t
ver
);
int32_t
walReadWithHandle
(
SWalReadHandle
*
pRead
,
int64_t
ver
);
// only for tq usage
// only for tq usage
// int32_t walReadWithHandle_s(SWalReadHandle *pRead, int64_t ver, SWalReadHead **ppHead);
void
walSetReaderCapacity
(
SWalReadHandle
*
pRead
,
int32_t
capacity
);
void
walSetReaderCapacity
(
SWalReadHandle
*
pRead
,
int32_t
capacity
);
int32_t
walFetchHead
(
SWalReadHandle
*
pRead
,
int64_t
ver
,
SWalHead
*
pHead
);
int32_t
walFetchHead
(
SWalReadHandle
*
pRead
,
int64_t
ver
,
SWalHead
*
pHead
);
int32_t
walFetchBody
(
SWalReadHandle
*
pRead
,
SWalHead
**
ppHead
);
int32_t
walFetchBody
(
SWalReadHandle
*
pRead
,
SWalHead
**
ppHead
);
...
@@ -211,13 +210,8 @@ void walCloseRef(SWalRef *);
...
@@ -211,13 +210,8 @@ void walCloseRef(SWalRef *);
int32_t
walRefVer
(
SWalRef
*
,
int64_t
ver
);
int32_t
walRefVer
(
SWalRef
*
,
int64_t
ver
);
int32_t
walUnrefVer
(
SWal
*
);
int32_t
walUnrefVer
(
SWal
*
);
// deprecated
#if 0
int32_t walRead(SWal *, SWalHead **, int64_t ver);
int32_t walReadWithFp(SWal *, FWalWrite writeFp, int64_t verStart, int32_t readNum);
#endif
// lifecycle check
// lifecycle check
bool
walIsEmpty
(
SWal
*
);
int64_t
walGetFirstVer
(
SWal
*
);
int64_t
walGetFirstVer
(
SWal
*
);
int64_t
walGetSnapshotVer
(
SWal
*
);
int64_t
walGetSnapshotVer
(
SWal
*
);
int64_t
walGetLastVer
(
SWal
*
);
int64_t
walGetLastVer
(
SWal
*
);
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
e078c739
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#include "tref.h"
#include "tref.h"
#include "walInt.h"
#include "walInt.h"
bool
FORCE_INLINE
walIsEmpty
(
SWal
*
pWal
)
{
return
pWal
->
vers
.
firstVer
==
-
1
;
}
int64_t
FORCE_INLINE
walGetFirstVer
(
SWal
*
pWal
)
{
return
pWal
->
vers
.
firstVer
;
}
int64_t
FORCE_INLINE
walGetFirstVer
(
SWal
*
pWal
)
{
return
pWal
->
vers
.
firstVer
;
}
int64_t
FORCE_INLINE
walGetSnaphostVer
(
SWal
*
pWal
)
{
return
pWal
->
vers
.
snapshotVer
;
}
int64_t
FORCE_INLINE
walGetSnaphostVer
(
SWal
*
pWal
)
{
return
pWal
->
vers
.
snapshotVer
;
}
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
e078c739
...
@@ -141,7 +141,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -141,7 +141,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
// validate offset
// validate offset
SWalHead
head
;
SWalHead
head
;
ASSERT
(
taosValidFile
(
pLogTFile
));
ASSERT
(
taosValidFile
(
pLogTFile
));
int
size
=
taosReadFile
(
pLogTFile
,
&
head
,
sizeof
(
SWalHead
));
int
64_t
size
=
taosReadFile
(
pLogTFile
,
&
head
,
sizeof
(
SWalHead
));
if
(
size
!=
sizeof
(
SWalHead
))
{
if
(
size
!=
sizeof
(
SWalHead
))
{
return
-
1
;
return
-
1
;
}
}
...
@@ -149,22 +149,33 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -149,22 +149,33 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
-
1
;
return
-
1
;
}
}
if
(
head
.
head
.
version
!=
ver
)
{
if
(
head
.
head
.
version
!=
ver
)
{
// TODO
ASSERT
(
0
);
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
-
1
;
return
-
1
;
}
}
// truncate old files
// truncate old files
code
=
taosFtruncateFile
(
pLogTFile
,
entry
.
offset
);
code
=
taosFtruncateFile
(
pLogTFile
,
entry
.
offset
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
ASSERT
(
0
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
code
=
taosFtruncateFile
(
pIdxTFile
,
idxOff
);
code
=
taosFtruncateFile
(
pIdxTFile
,
idxOff
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
ASSERT
(
0
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
pWal
->
vers
.
lastVer
=
ver
-
1
;
pWal
->
vers
.
lastVer
=
ver
-
1
;
if
(
pWal
->
vers
.
lastVer
<
pWal
->
vers
.
firstVer
)
{
ASSERT
(
pWal
->
vers
.
lastVer
==
pWal
->
vers
.
firstVer
-
1
);
pWal
->
vers
.
firstVer
=
-
1
;
}
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
ver
-
1
;
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
ver
-
1
;
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
fileSize
=
entry
.
offset
;
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
fileSize
=
entry
.
offset
;
taosCloseFile
(
&
pIdxTFile
);
taosCloseFile
(
&
pIdxTFile
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录