Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
0fcfc142
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0fcfc142
编写于
2月 24, 2021
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3064]<fix>: fix wal file size(>2G) overflow with int32_t
上级
8e8437ad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
21 deletion
+21
-21
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+21
-21
未找到文件。
src/sync/src/syncRetrieve.c
浏览文件 @
0fcfc142
...
...
@@ -170,14 +170,14 @@ static int32_t syncReadOneWalRecord(int32_t sfd, SWalHead *pHead) {
return
sizeof
(
SWalHead
)
+
pHead
->
len
;
}
static
int
32
_t
syncRetrieveLastWal
(
SSyncPeer
*
pPeer
,
char
*
name
,
uint64_t
fversion
,
int64_t
offset
)
{
static
int
64
_t
syncRetrieveLastWal
(
SSyncPeer
*
pPeer
,
char
*
name
,
uint64_t
fversion
,
int64_t
offset
)
{
int32_t
sfd
=
open
(
name
,
O_RDONLY
|
O_BINARY
);
if
(
sfd
<
0
)
{
sError
(
"%s, failed to open wal:%s for retrieve since:%s"
,
pPeer
->
id
,
name
,
tstrerror
(
errno
));
return
-
1
;
}
int
32_t
code
=
(
int32_t
)
taosLSeek
(
sfd
,
offset
,
SEEK_SET
);
int
64_t
code
=
taosLSeek
(
sfd
,
offset
,
SEEK_SET
);
if
(
code
<
0
)
{
sError
(
"%s, failed to seek %"
PRId64
" in wal:%s for retrieve since:%s"
,
pPeer
->
id
,
offset
,
name
,
tstrerror
(
errno
));
close
(
sfd
);
...
...
@@ -187,7 +187,7 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
sDebug
(
"%s, retrieve last wal:%s, offset:%"
PRId64
" fver:%"
PRIu64
,
pPeer
->
id
,
name
,
offset
,
fversion
);
SWalHead
*
pHead
=
malloc
(
SYNC_MAX_SIZE
);
int
32
_t
bytes
=
0
;
int
64
_t
bytes
=
0
;
while
(
1
)
{
code
=
syncReadOneWalRecord
(
sfd
,
pHead
);
...
...
@@ -198,13 +198,13 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
if
(
code
==
0
)
{
code
=
bytes
;
sDebug
(
"%s, read to the end of wal, bytes:%
d"
,
pPeer
->
id
,
bytes
);
sDebug
(
"%s, read to the end of wal, bytes:%
"
PRId64
,
pPeer
->
id
,
bytes
);
break
;
}
sTrace
(
"%s, last wal is forwarded, hver:%"
PRIu64
,
pPeer
->
id
,
pHead
->
version
);
int32_t
wsize
=
code
;
int32_t
wsize
=
(
int32_t
)
code
;
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
pHead
,
wsize
);
if
(
ret
!=
wsize
)
{
code
=
-
1
;
...
...
@@ -228,7 +228,7 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
return
code
;
}
static
int
32
_t
syncProcessLastWal
(
SSyncPeer
*
pPeer
,
char
*
wname
,
int64_t
index
)
{
static
int
64
_t
syncProcessLastWal
(
SSyncPeer
*
pPeer
,
char
*
wname
,
int64_t
index
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
int32_t
once
=
0
;
// last WAL has once ever been processed
int64_t
offset
=
0
;
...
...
@@ -243,9 +243,9 @@ static int32_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index)
if
(
syncAreFilesModified
(
pNode
,
pPeer
))
return
-
1
;
if
(
syncGetWalVersion
(
pNode
,
pPeer
)
<
0
)
return
-
1
;
int
32
_t
bytes
=
syncRetrieveLastWal
(
pPeer
,
fname
,
fversion
,
offset
);
int
64
_t
bytes
=
syncRetrieveLastWal
(
pPeer
,
fname
,
fversion
,
offset
);
if
(
bytes
<
0
)
{
sDebug
(
"%s, failed to retrieve last wal, bytes:%
d"
,
pPeer
->
id
,
bytes
);
sDebug
(
"%s, failed to retrieve last wal, bytes:%
"
PRId64
,
pPeer
->
id
,
bytes
);
return
bytes
;
}
...
...
@@ -263,7 +263,7 @@ static int32_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index)
// if all data up to fversion is read out, it is over
if
(
pPeer
->
sversion
>=
fversion
&&
fversion
>
0
)
{
sDebug
(
"%s, data up to fver:%"
PRIu64
" has been read out, bytes:%
d
sver:%"
PRIu64
,
pPeer
->
id
,
fversion
,
bytes
,
sDebug
(
"%s, data up to fver:%"
PRIu64
" has been read out, bytes:%
"
PRId64
"
sver:%"
PRIu64
,
pPeer
->
id
,
fversion
,
bytes
,
pPeer
->
sversion
);
return
0
;
}
...
...
@@ -277,19 +277,19 @@ static int32_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index)
// if bytes > 0, file is updated, or fversion is not reached but file still open, read again
once
=
1
;
offset
+=
bytes
;
sDebug
(
"%s, continue retrieve last wal, bytes:%
d
offset:%"
PRId64
" sver:%"
PRIu64
" fver:%"
PRIu64
,
pPeer
->
id
,
sDebug
(
"%s, continue retrieve last wal, bytes:%
"
PRId64
"
offset:%"
PRId64
" sver:%"
PRIu64
" fver:%"
PRIu64
,
pPeer
->
id
,
bytes
,
offset
,
pPeer
->
sversion
,
fversion
);
}
return
-
1
;
}
static
int
32
_t
syncRetrieveWal
(
SSyncPeer
*
pPeer
)
{
static
int
64
_t
syncRetrieveWal
(
SSyncPeer
*
pPeer
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
char
fname
[
TSDB_FILENAME_LEN
*
3
];
char
wname
[
TSDB_FILENAME_LEN
*
2
];
int32_t
size
;
int
32
_t
code
=
-
1
;
int
64
_t
code
=
-
1
;
int64_t
index
=
0
;
while
(
1
)
{
...
...
@@ -297,7 +297,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
wname
[
0
]
=
0
;
code
=
(
*
pNode
->
getWalInfoFp
)(
pNode
->
vgId
,
wname
,
&
index
);
if
(
code
<
0
)
{
sError
(
"%s, failed to get wal info since:%s, code:0x%
x"
,
pPeer
->
id
,
strerror
(
errno
),
code
);
sError
(
"%s, failed to get wal info since:%s, code:0x%
"
PRIx64
,
pPeer
->
id
,
strerror
(
errno
),
code
);
break
;
}
...
...
@@ -309,7 +309,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
if
(
code
==
0
)
{
// last wal
code
=
syncProcessLastWal
(
pPeer
,
wname
,
index
);
sInfo
(
"%s, last wal processed, code:%
d"
,
pPeer
->
id
,
code
);
sInfo
(
"%s, last wal processed, code:%
"
PRId64
,
pPeer
->
id
,
code
);
break
;
}
...
...
@@ -320,7 +320,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
struct
stat
fstat
;
if
(
stat
(
fname
,
&
fstat
)
<
0
)
{
code
=
-
1
;
sDebug
(
"%s, failed to stat wal:%s for retrieve since %s, code:0x%
x"
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
sDebug
(
"%s, failed to stat wal:%s for retrieve since %s, code:0x%
"
PRIx64
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
break
;
}
...
...
@@ -330,14 +330,14 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
int32_t
sfd
=
open
(
fname
,
O_RDONLY
|
O_BINARY
);
if
(
sfd
<
0
)
{
code
=
-
1
;
sError
(
"%s, failed to open wal:%s for retrieve since %s, code:0x%
x"
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
sError
(
"%s, failed to open wal:%s for retrieve since %s, code:0x%
"
PRIx64
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
break
;
}
code
=
(
int32_t
)
taosSendFile
(
pPeer
->
syncFd
,
sfd
,
NULL
,
size
);
close
(
sfd
);
if
(
code
<
0
)
{
sError
(
"%s, failed to send wal:%s for retrieve since %s, code:0x%
x"
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
sError
(
"%s, failed to send wal:%s for retrieve since %s, code:0x%
"
PRIx64
,
pPeer
->
id
,
fname
,
strerror
(
errno
),
code
);
break
;
}
...
...
@@ -358,7 +358,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
code
=
-
1
;
}
}
else
{
sError
(
"%s, failed to send wal since %s, code:0x%
x"
,
pPeer
->
id
,
strerror
(
errno
),
code
);
sError
(
"%s, failed to send wal since %s, code:0x%
"
PRIx64
,
pPeer
->
id
,
strerror
(
errno
),
code
);
}
return
code
;
...
...
@@ -405,9 +405,9 @@ static int32_t syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
if
(
pPeer
->
sversion
==
0
)
pPeer
->
sversion
=
1
;
sInfo
(
"%s, start to retrieve wals"
,
pPeer
->
id
);
int
32
_t
code
=
syncRetrieveWal
(
pPeer
);
if
(
code
!=
0
)
{
sError
(
"%s, failed to retrieve wals, code:0x%
x"
,
pPeer
->
id
,
code
);
int
64
_t
code
=
syncRetrieveWal
(
pPeer
);
if
(
code
<
0
)
{
sError
(
"%s, failed to retrieve wals, code:0x%
"
PRIx64
,
pPeer
->
id
,
code
);
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录