Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a031010a
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a031010a
编写于
11月 01, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 01, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17721 from taosdata/FIX/TD-19673-3.0
enh: check completeness of WAL log entries after repairing
上级
801d65cb
96520291
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
42 addition
and
8 deletion
+42
-8
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+32
-0
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+1
-1
source/libs/wal/test/walMetaTest.cpp
source/libs/wal/test/walMetaTest.cpp
+7
-7
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
a031010a
...
...
@@ -451,6 +451,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
#define TSDB_CODE_WAL_CHKSUM_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x1006)
#define TSDB_CODE_WAL_LOG_INCOMPLETE TAOS_DEF_ERROR_CODE(0, 0x1007)
// tfs
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
a031010a
...
...
@@ -288,6 +288,33 @@ void walAlignVersions(SWal* pWal) {
pWal
->
vers
.
appliedVer
=
TMIN
(
pWal
->
vers
.
commitVer
,
pWal
->
vers
.
appliedVer
);
}
bool
walLogEntriesComplete
(
const
SWal
*
pWal
)
{
int32_t
sz
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
bool
complete
=
true
;
int32_t
fileIdx
=
-
1
;
int64_t
index
=
pWal
->
vers
.
firstVer
;
while
(
++
fileIdx
<
sz
)
{
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
fileIdx
);
if
(
pFileInfo
->
firstVer
!=
index
)
{
break
;
}
index
=
pFileInfo
->
lastVer
+
((
fileIdx
+
1
<
sz
)
?
1
:
0
);
}
// empty is regarded as complete
if
(
sz
!=
0
)
{
complete
=
(
index
==
pWal
->
vers
.
lastVer
);
}
if
(
!
complete
)
{
wError
(
"vgId:%d, WAL log entries incomplete in range [%"
PRId64
", %"
PRId64
"], aligned with snaphotVer:%"
PRId64
,
pWal
->
cfg
.
vgId
,
pWal
->
vers
.
firstVer
,
pWal
->
vers
.
lastVer
,
pWal
->
vers
.
snapshotVer
);
terrno
=
TSDB_CODE_WAL_LOG_INCOMPLETE
;
}
return
complete
;
}
int
walCheckAndRepairMeta
(
SWal
*
pWal
)
{
// load log files, get first/snapshot/last version info
const
char
*
logPattern
=
"^[0-9]+.log$"
;
...
...
@@ -401,6 +428,11 @@ int walCheckAndRepairMeta(SWal* pWal) {
if
(
updateMeta
)
{
(
void
)
walSaveMeta
(
pWal
);
}
if
(
!
walLogEntriesComplete
(
pWal
))
{
return
-
1
;
}
return
0
;
}
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
a031010a
...
...
@@ -101,7 +101,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
taosThreadMutexLock
(
&
pWal
->
mutex
);
int64_t
code
;
char
fnameStr
[
WAL_FILE_LEN
];
if
(
ver
>
pWal
->
vers
.
lastVer
||
ver
<
pWal
->
vers
.
commitVer
)
{
if
(
ver
>
pWal
->
vers
.
lastVer
||
ver
<
pWal
->
vers
.
commitVer
||
ver
<=
pWal
->
vers
.
snapshotVer
)
{
terrno
=
TSDB_CODE_WAL_INVALID_VER
;
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
...
...
source/libs/wal/test/walMetaTest.cpp
浏览文件 @
a031010a
...
...
@@ -274,17 +274,17 @@ TEST_F(WalCleanEnv, rollbackMultiFile) {
code
=
walRollback
(
pWal
,
9
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
8
);
code
=
walRollback
(
pWal
,
5
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
4
);
code
=
walRollback
(
pWal
,
3
);
code
=
walRollback
(
pWal
,
6
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
5
);
code
=
walRollback
(
pWal
,
5
);
ASSERT_EQ
(
code
,
-
1
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
2
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
5
);
code
=
walWrite
(
pWal
,
3
,
3
,
(
void
*
)
ranStr
,
ranStrLen
);
code
=
walWrite
(
pWal
,
6
,
6
,
(
void
*
)
ranStr
,
ranStrLen
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
3
);
ASSERT_EQ
(
pWal
->
vers
.
lastVer
,
6
);
code
=
walSaveMeta
(
pWal
);
ASSERT_EQ
(
code
,
0
);
...
...
source/util/src/terror.c
浏览文件 @
a031010a
...
...
@@ -452,6 +452,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_WAL_INVALID_VER, "WAL use invalid versi
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_OUT_OF_MEMORY
,
"WAL out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_LOG_NOT_EXIST
,
"WAL log not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_CHKSUM_MISMATCH
,
"WAL checksum mismatch"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_LOG_INCOMPLETE
,
"WAL log incomplete"
)
// tfs
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_INVLD_CFG
,
"tfs invalid mount config"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录