Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4a648d71
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
4a648d71
编写于
7月 07, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(wal): support filter
上级
1ec57798
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
132 addition
and
15 deletion
+132
-15
include/common/tcommon.h
include/common/tcommon.h
+12
-0
include/libs/wal/wal.h
include/libs/wal/wal.h
+1
-1
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+0
-9
source/libs/wal/inc/walInt.h
source/libs/wal/inc/walInt.h
+1
-0
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+118
-5
未找到文件。
include/common/tcommon.h
浏览文件 @
4a648d71
...
...
@@ -32,6 +32,18 @@ enum {
TMQ_CONF__RESET_OFFSET__LATEST
=
-
1
,
};
// clang-format off
#define IS_META_MSG(x) ( \
x == TDMT_VND_CREATE_STB \
|| x == TDMT_VND_ALTER_STB \
|| x == TDMT_VND_DROP_STB \
|| x == TDMT_VND_CREATE_TABLE \
|| x == TDMT_VND_ALTER_TABLE \
|| x == TDMT_VND_DROP_TABLE \
|| x == TDMT_VND_DROP_TTL_TABLE \
)
// clang-format on
enum
{
TMQ_MSG_TYPE__DUMMY
=
0
,
TMQ_MSG_TYPE__POLL_RSP
,
...
...
include/libs/wal/wal.h
浏览文件 @
4a648d71
...
...
@@ -194,7 +194,7 @@ int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
SWalReader
*
walOpenReader
(
SWal
*
,
SWalFilterCond
*
pCond
);
void
walCloseReader
(
SWalReader
*
pRead
);
int32_t
walReadVer
(
SWalReader
*
pRead
,
int64_t
ver
);
int32_t
walNextValidMsg
(
SWalReader
*
pRead
,
SWalCkHead
**
ppHead
);
int32_t
walNextValidMsg
(
SWalReader
*
pRead
);
// only for tq usage
void
walSetReaderCapacity
(
SWalReader
*
pRead
,
int32_t
capacity
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
4a648d71
...
...
@@ -40,15 +40,6 @@ extern "C" {
#define tqDebug(...) do { if (tqDebugFlag & DEBUG_DEBUG) { taosPrintLog("TQ ", DEBUG_DEBUG, tqDebugFlag, __VA_ARGS__); }} while(0)
#define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0)
#define IS_META_MSG(x) ( \
x == TDMT_VND_CREATE_STB \
|| x == TDMT_VND_ALTER_STB \
|| x == TDMT_VND_DROP_STB \
|| x == TDMT_VND_CREATE_TABLE \
|| x == TDMT_VND_ALTER_TABLE \
|| x == TDMT_VND_DROP_TABLE \
|| x == TDMT_VND_DROP_TTL_TABLE \
)
// clang-format on
typedef
struct
STqOffsetStore
STqOffsetStore
;
...
...
source/libs/wal/inc/walInt.h
浏览文件 @
4a648d71
...
...
@@ -19,6 +19,7 @@
#include "taoserror.h"
#include "tchecksum.h"
#include "tcoding.h"
#include "tcommon.h"
#include "tcompare.h"
#include "wal.h"
...
...
source/libs/wal/src/walRead.c
浏览文件 @
4a648d71
...
...
@@ -16,6 +16,10 @@
#include "taoserror.h"
#include "walInt.h"
static
int32_t
walFetchHeadNew
(
SWalReader
*
pRead
,
int64_t
fetchVer
);
static
int32_t
walFetchBodyNew
(
SWalReader
*
pRead
);
static
int32_t
walSkipFetchBodyNew
(
SWalReader
*
pRead
);
SWalReader
*
walOpenReader
(
SWal
*
pWal
,
SWalFilterCond
*
cond
)
{
SWalReader
*
pRead
=
taosMemoryMalloc
(
sizeof
(
SWalReader
));
if
(
pRead
==
NULL
)
{
...
...
@@ -29,7 +33,12 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) {
pRead
->
curVersion
=
-
1
;
pRead
->
curFileFirstVer
=
-
1
;
pRead
->
capacity
=
0
;
pRead
->
cond
=
*
cond
;
if
(
cond
)
pRead
->
cond
=
*
cond
;
else
{
pRead
->
cond
.
scanMeta
=
0
;
pRead
->
cond
.
scanUncommited
=
0
;
}
taosThreadMutexInit
(
&
pRead
->
mutex
,
NULL
);
...
...
@@ -39,6 +48,7 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) {
taosMemoryFree
(
pRead
);
return
NULL
;
}
return
pRead
;
}
...
...
@@ -49,10 +59,28 @@ void walCloseReader(SWalReader *pRead) {
taosMemoryFree
(
pRead
);
}
int32_t
walNextValidMsg
(
SWalReader
*
pRead
,
SWalCkHead
**
ppHead
)
{
//
return
0
;
int32_t
walNextValidMsg
(
SWalReader
*
pRead
)
{
int64_t
fetchVer
=
pRead
->
curVersion
;
int64_t
endVer
=
pRead
->
cond
.
scanUncommited
?
walGetLastVer
(
pRead
->
pWal
)
:
walGetCommittedVer
(
pRead
->
pWal
);
while
(
fetchVer
<=
endVer
)
{
if
(
walFetchHeadNew
(
pRead
,
fetchVer
)
<
0
)
{
return
-
1
;
}
if
(
pRead
->
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
||
(
IS_META_MSG
(
pRead
->
pHead
->
head
.
msgType
)
&&
pRead
->
cond
.
scanMeta
))
{
if
(
walFetchBodyNew
(
pRead
)
<
0
)
{
return
-
1
;
}
return
0
;
}
else
{
if
(
walSkipFetchBodyNew
(
pRead
)
<
0
)
{
return
-
1
;
}
fetchVer
++
;
ASSERT
(
fetchVer
==
pRead
->
curVersion
);
}
}
return
-
1
;
}
static
int64_t
walReadSeekFilePos
(
SWalReader
*
pRead
,
int64_t
fileFirstVer
,
int64_t
ver
)
{
...
...
@@ -156,6 +184,91 @@ static int32_t walReadSeekVer(SWalReader *pRead, int64_t ver) {
void
walSetReaderCapacity
(
SWalReader
*
pRead
,
int32_t
capacity
)
{
pRead
->
capacity
=
capacity
;
}
static
int32_t
walFetchHeadNew
(
SWalReader
*
pRead
,
int64_t
fetchVer
)
{
int64_t
contLen
;
if
(
pRead
->
curVersion
!=
fetchVer
)
{
if
(
walReadSeekVer
(
pRead
,
fetchVer
)
<
0
)
return
-
1
;
}
contLen
=
taosReadFile
(
pRead
->
pLogFile
,
pRead
->
pHead
,
sizeof
(
SWalCkHead
));
if
(
contLen
!=
sizeof
(
SWalCkHead
))
{
if
(
contLen
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
}
else
{
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
pRead
->
curVersion
=
-
1
;
return
-
1
;
}
return
0
;
}
static
int32_t
walFetchBodyNew
(
SWalReader
*
pRead
)
{
SWalCont
*
pReadHead
=
&
pRead
->
pHead
->
head
;
int64_t
ver
=
pReadHead
->
version
;
if
(
pRead
->
capacity
<
pReadHead
->
bodyLen
)
{
void
*
ptr
=
taosMemoryRealloc
(
pRead
->
pHead
,
sizeof
(
SWalCkHead
)
+
pReadHead
->
bodyLen
);
if
(
ptr
==
NULL
)
{
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
return
-
1
;
}
pRead
->
pHead
=
ptr
;
pReadHead
=
&
pRead
->
pHead
->
head
;
pRead
->
capacity
=
pReadHead
->
bodyLen
;
}
if
(
pReadHead
->
bodyLen
!=
taosReadFile
(
pRead
->
pLogFile
,
pReadHead
->
body
,
pReadHead
->
bodyLen
))
{
if
(
pReadHead
->
bodyLen
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"wal fetch body error: %"
PRId64
", read request version:%"
PRId64
", since %s"
,
pRead
->
pHead
->
head
.
version
,
ver
,
tstrerror
(
terrno
));
}
else
{
wError
(
"wal fetch body error: %"
PRId64
", read request version:%"
PRId64
", since file corrupted"
,
pRead
->
pHead
->
head
.
version
,
ver
);
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
pRead
->
curVersion
=
-
1
;
ASSERT
(
0
);
return
-
1
;
}
if
(
pReadHead
->
version
!=
ver
)
{
wError
(
"wal fetch body error: %"
PRId64
", read request version:%"
PRId64
""
,
pRead
->
pHead
->
head
.
version
,
ver
);
pRead
->
curVersion
=
-
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
0
);
return
-
1
;
}
if
(
walValidBodyCksum
(
pRead
->
pHead
)
!=
0
)
{
wError
(
"wal fetch body error: % "
PRId64
", since body checksum not passed"
,
ver
);
pRead
->
curVersion
=
-
1
;
terrno
=
TSDB_CODE_WAL_FILE_CORRUPTED
;
ASSERT
(
0
);
return
-
1
;
}
pRead
->
curVersion
=
ver
+
1
;
return
0
;
}
static
int32_t
walSkipFetchBodyNew
(
SWalReader
*
pRead
)
{
int64_t
code
;
ASSERT
(
pRead
->
curVersion
==
pRead
->
pHead
->
head
.
version
);
code
=
taosLSeekFile
(
pRead
->
pLogFile
,
pRead
->
pHead
->
head
.
bodyLen
,
SEEK_CUR
);
if
(
code
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
pRead
->
curVersion
=
-
1
;
return
-
1
;
}
pRead
->
curVersion
++
;
return
0
;
}
int32_t
walFetchHead
(
SWalReader
*
pRead
,
int64_t
ver
,
SWalCkHead
*
pHead
)
{
int64_t
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录