Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cccfa170
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看板
提交
cccfa170
编写于
10月 31, 2022
作者:
B
benguang.zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fsync wal files and their meta if data size unsynced exceeds a limit
上级
bfb92713
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
4 deletion
+34
-4
source/libs/wal/inc/walInt.h
source/libs/wal/inc/walInt.h
+7
-0
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+10
-0
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+17
-4
未找到文件。
source/libs/wal/inc/walInt.h
浏览文件 @
cccfa170
...
@@ -34,6 +34,7 @@ typedef struct {
...
@@ -34,6 +34,7 @@ typedef struct {
int64_t
createTs
;
int64_t
createTs
;
int64_t
closeTs
;
int64_t
closeTs
;
int64_t
fileSize
;
int64_t
fileSize
;
int64_t
syncedOffset
;
}
SWalFileInfo
;
}
SWalFileInfo
;
typedef
struct
WalIdxEntry
{
typedef
struct
WalIdxEntry
{
...
@@ -66,6 +67,12 @@ static inline int64_t walGetLastFileSize(SWal* pWal) {
...
@@ -66,6 +67,12 @@ static inline int64_t walGetLastFileSize(SWal* pWal) {
return
pInfo
->
fileSize
;
return
pInfo
->
fileSize
;
}
}
static
inline
int64_t
walGetLastFileCachedSize
(
SWal
*
pWal
)
{
if
(
taosArrayGetSize
(
pWal
->
fileInfoSet
)
==
0
)
return
0
;
SWalFileInfo
*
pInfo
=
(
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
);
return
(
pInfo
->
fileSize
-
pInfo
->
syncedOffset
);
}
static
inline
int64_t
walGetLastFileFirstVer
(
SWal
*
pWal
)
{
static
inline
int64_t
walGetLastFileFirstVer
(
SWal
*
pWal
)
{
if
(
taosArrayGetSize
(
pWal
->
fileInfoSet
)
==
0
)
return
-
1
;
if
(
taosArrayGetSize
(
pWal
->
fileInfoSet
)
==
0
)
return
-
1
;
SWalFileInfo
*
pInfo
=
(
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
);
SWalFileInfo
*
pInfo
=
(
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
);
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
cccfa170
...
@@ -589,6 +589,7 @@ int walRollFileInfo(SWal* pWal) {
...
@@ -589,6 +589,7 @@ int walRollFileInfo(SWal* pWal) {
pNewInfo
->
createTs
=
ts
;
pNewInfo
->
createTs
=
ts
;
pNewInfo
->
closeTs
=
-
1
;
pNewInfo
->
closeTs
=
-
1
;
pNewInfo
->
fileSize
=
0
;
pNewInfo
->
fileSize
=
0
;
pNewInfo
->
syncedOffset
=
0
;
taosArrayPush
(
pArray
,
pNewInfo
);
taosArrayPush
(
pArray
,
pNewInfo
);
taosMemoryFree
(
pNewInfo
);
taosMemoryFree
(
pNewInfo
);
return
0
;
return
0
;
...
@@ -739,6 +740,12 @@ static int walFindCurMetaVer(SWal* pWal) {
...
@@ -739,6 +740,12 @@ static int walFindCurMetaVer(SWal* pWal) {
return
metaVer
;
return
metaVer
;
}
}
void
walUpdateSyncedOffset
(
SWal
*
pWal
)
{
SWalFileInfo
*
pFileInfo
=
walGetCurFileInfo
(
pWal
);
if
(
pFileInfo
==
NULL
)
return
;
pFileInfo
->
syncedOffset
=
pFileInfo
->
fileSize
;
}
int
walSaveMeta
(
SWal
*
pWal
)
{
int
walSaveMeta
(
SWal
*
pWal
)
{
int
metaVer
=
walFindCurMetaVer
(
pWal
);
int
metaVer
=
walFindCurMetaVer
(
pWal
);
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
...
@@ -758,6 +765,9 @@ int walSaveMeta(SWal* pWal) {
...
@@ -758,6 +765,9 @@ int walSaveMeta(SWal* pWal) {
return
-
1
;
return
-
1
;
}
}
// update synced offset
(
void
)
walUpdateSyncedOffset
(
pWal
);
// flush to a tmpfile
// flush to a tmpfile
n
=
walBuildTmpMetaName
(
pWal
,
tmpFnameStr
);
n
=
walBuildTmpMetaName
(
pWal
,
tmpFnameStr
);
ASSERT
(
n
<
sizeof
(
tmpFnameStr
)
&&
"Buffer overflow of file name"
);
ASSERT
(
n
<
sizeof
(
tmpFnameStr
)
&&
"Buffer overflow of file name"
);
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
cccfa170
...
@@ -252,23 +252,36 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) {
...
@@ -252,23 +252,36 @@ static FORCE_INLINE int32_t walCheckAndRoll(SWal *pWal) {
}
}
}
}
if
(
walGetLastFileCachedSize
(
pWal
)
>
WAL_RECOV_SIZE_LIMIT
/
2
)
{
if
(
walSaveMeta
(
pWal
)
<
0
)
{
return
-
1
;
}
}
return
0
;
return
0
;
}
}
int32_t
walBeginSnapshot
(
SWal
*
pWal
,
int64_t
ver
)
{
int32_t
walBeginSnapshot
(
SWal
*
pWal
,
int64_t
ver
)
{
taosThreadMutexLock
(
&
pWal
->
mutex
);
pWal
->
vers
.
verInSnapshotting
=
ver
;
pWal
->
vers
.
verInSnapshotting
=
ver
;
wDebug
(
"vgId:%d, wal begin snapshot for version %"
PRId64
", first ver %"
PRId64
", last ver %"
PRId64
,
wDebug
(
"vgId:%d, wal begin snapshot for version %"
PRId64
", first ver %"
PRId64
", last ver %"
PRId64
,
pWal
->
cfg
.
vgId
,
ver
,
pWal
->
vers
.
firstVer
,
pWal
->
vers
.
lastVer
);
pWal
->
cfg
.
vgId
,
ver
,
pWal
->
vers
.
firstVer
,
pWal
->
vers
.
lastVer
);
// check file rolling
// check file rolling
if
(
pWal
->
cfg
.
retentionPeriod
==
0
)
{
if
(
pWal
->
cfg
.
retentionPeriod
==
0
)
{
taosThreadMutexLock
(
&
pWal
->
mutex
);
if
(
walGetLastFileSize
(
pWal
)
!=
0
)
{
if
(
walGetLastFileSize
(
pWal
)
!=
0
)
{
walRollImpl
(
pWal
);
if
(
walRollImpl
(
pWal
)
<
0
)
{
wError
(
"vgId:%d, failed to roll wal files since %s"
,
pWal
->
cfg
.
vgId
,
terrstr
());
goto
_err
;
}
}
}
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
}
}
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
0
;
return
0
;
_err:
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
}
}
int32_t
walEndSnapshot
(
SWal
*
pWal
)
{
int32_t
walEndSnapshot
(
SWal
*
pWal
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录