Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fbdeadbc
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看板
提交
fbdeadbc
编写于
8月 01, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix possible commit log init failure
上级
d6cfd14e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
9 deletion
+17
-9
src/system/src/vnodeCommit.c
src/system/src/vnodeCommit.c
+17
-9
未找到文件。
src/system/src/vnodeCommit.c
浏览文件 @
fbdeadbc
...
...
@@ -28,10 +28,11 @@
#include "vnode.h"
typedef
struct
{
char
action
;
int
sversion
;
int
sid
;
int
contLen
;
int
action
:
8
;
int
simpleCheck
:
24
;
}
SCommitHead
;
int
vnodeOpenCommitLog
(
int
vnode
,
uint64_t
firstV
)
{
...
...
@@ -118,7 +119,7 @@ size_t vnodeRestoreDataFromLog(int vnode, char *fileName, uint64_t *firstV) {
fd
=
open
(
fileName
,
O_RDWR
);
if
(
fd
<
0
)
{
dError
(
"vid:%d, failed to open:%s, reason:%s"
,
vnode
,
fileName
);
dError
(
"vid:%d, failed to open:%s, reason:%s"
,
vnode
,
fileName
,
strerror
(
errno
)
);
goto
_error
;
}
...
...
@@ -137,22 +138,26 @@ size_t vnodeRestoreDataFromLog(int vnode, char *fileName, uint64_t *firstV) {
}
SCommitHead
head
;
int
simpleCheck
=
0
;
while
(
1
)
{
ret
=
read
(
fd
,
&
head
,
sizeof
(
head
));
if
(
ret
<
0
)
goto
_error
;
if
(
ret
==
0
)
break
;
if
(((
head
.
sversion
+
head
.
sid
+
head
.
contLen
+
head
.
action
)
&
0xFFFFFF
)
!=
head
.
simpleCheck
)
break
;
simpleCheck
=
head
.
simpleCheck
;
// head.contLen validation is removed
if
(
head
.
sid
>=
pVnode
->
cfg
.
maxSessions
||
head
.
sid
<
0
||
head
.
action
>=
TSDB_ACTION_MAX
)
{
dError
(
"vid, invalid commit head, sid:%d contLen:%d action:%d"
,
head
.
sid
,
head
.
contLen
,
head
.
action
);
}
else
{
if
(
head
.
contLen
>
0
)
{
if
(
bufLen
<
head
.
contLen
)
{
// pre-allocated buffer is not enough
cont
=
realloc
(
cont
,
head
.
contLen
);
bufLen
=
head
.
contLen
;
if
(
bufLen
<
head
.
contLen
+
sizeof
(
simpleCheck
)
)
{
// pre-allocated buffer is not enough
cont
=
realloc
(
cont
,
head
.
contLen
+
sizeof
(
simpleCheck
)
);
bufLen
=
head
.
contLen
+
sizeof
(
simpleCheck
)
;
}
if
(
read
(
fd
,
cont
,
head
.
contLen
)
<
0
)
goto
_error
;
if
(
read
(
fd
,
cont
,
head
.
contLen
+
sizeof
(
simpleCheck
))
<
0
)
goto
_error
;
if
(
*
(
int
*
)(
cont
+
head
.
contLen
)
!=
simpleCheck
)
break
;
SMeterObj
*
pObj
=
pVnode
->
meterList
[
head
.
sid
];
if
(
pObj
==
NULL
)
{
dError
(
...
...
@@ -171,7 +176,7 @@ size_t vnodeRestoreDataFromLog(int vnode, char *fileName, uint64_t *firstV) {
}
}
totalLen
+=
sizeof
(
head
)
+
head
.
contLen
;
totalLen
+=
sizeof
(
head
)
+
head
.
contLen
+
sizeof
(
simpleCheck
)
;
}
tclose
(
fd
);
...
...
@@ -253,19 +258,22 @@ int vnodeWriteToCommitLog(SMeterObj *pObj, char action, char *cont, int contLen,
head
.
action
=
action
;
head
.
sversion
=
pObj
->
sversion
;
head
.
contLen
=
contLen
;
head
.
simpleCheck
=
(
head
.
sversion
+
head
.
sid
+
head
.
contLen
+
head
.
action
)
&
0xFFFFFF
;
int
simpleCheck
=
head
.
simpleCheck
;
pthread_mutex_lock
(
&
(
pVnode
->
logMutex
));
// 100 bytes redundant mem space
if
(
pVnode
->
mappingSize
-
(
pVnode
->
pWrite
-
pVnode
->
pMem
)
<
contLen
+
sizeof
(
SCommitHead
)
+
100
)
{
if
(
pVnode
->
mappingSize
-
(
pVnode
->
pWrite
-
pVnode
->
pMem
)
<
contLen
+
sizeof
(
SCommitHead
)
+
sizeof
(
simpleCheck
)
+
100
)
{
pthread_mutex_unlock
(
&
(
pVnode
->
logMutex
));
dTrace
(
"vid:%d, mem mapping space is not enough, wait for commit"
,
pObj
->
vnode
);
vnodeProcessCommitTimer
(
pVnode
,
NULL
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
char
*
pWrite
=
pVnode
->
pWrite
;
pVnode
->
pWrite
+=
sizeof
(
head
)
+
contLen
;
pVnode
->
pWrite
+=
sizeof
(
head
)
+
contLen
+
sizeof
(
simpleCheck
)
;
memcpy
(
pWrite
,
(
char
*
)
&
head
,
sizeof
(
head
));
memcpy
(
pWrite
+
sizeof
(
head
),
cont
,
contLen
);
memcpy
(
pWrite
+
sizeof
(
head
)
+
contLen
,
&
simpleCheck
,
sizeof
(
simpleCheck
));
pthread_mutex_unlock
(
&
(
pVnode
->
logMutex
));
if
(
pVnode
->
pWrite
-
pVnode
->
pMem
>
pVnode
->
mappingThreshold
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录