Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4029cda3
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看板
未验证
提交
4029cda3
编写于
11月 28, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4373 from taosdata/feature/wal
TD-1895
上级
6a4481f4
a2331e5d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
113 addition
and
70 deletion
+113
-70
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+2
-0
src/inc/twal.h
src/inc/twal.h
+2
-3
src/os/inc/osFile.h
src/os/inc/osFile.h
+7
-12
src/os/src/detail/osFile.c
src/os/src/detail/osFile.c
+1
-1
src/util/inc/tfile.h
src/util/inc/tfile.h
+12
-9
src/util/src/tfile.c
src/util/src/tfile.c
+55
-13
src/wal/inc/walInt.h
src/wal/inc/walInt.h
+1
-1
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+5
-4
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+28
-27
未找到文件。
src/dnode/src/dnodeMain.c
浏览文件 @
4029cda3
...
...
@@ -19,6 +19,7 @@
#include "tutil.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tfile.h"
#include "twal.h"
#include "trpc.h"
#include "dnode.h"
...
...
@@ -55,6 +56,7 @@ typedef struct {
}
SDnodeComponent
;
static
const
SDnodeComponent
tsDnodeComponents
[]
=
{
{
"tfile"
,
tfInit
,
tfCleanup
},
{
"rpc"
,
rpcInit
,
rpcCleanup
},
{
"storage"
,
dnodeInitStorage
,
dnodeCleanupStorage
},
{
"dnodecfg"
,
dnodeInitCfg
,
dnodeCleanupCfg
},
...
...
src/inc/twal.h
浏览文件 @
4029cda3
...
...
@@ -51,9 +51,8 @@ typedef struct {
typedef
void
*
twalh
;
// WAL HANDLE
typedef
int32_t
FWalWrite
(
void
*
ahandle
,
void
*
pHead
,
int32_t
qtype
,
void
*
pMsg
);
int32_t
walInit
();
void
walCleanUp
();
int32_t
walInit
();
void
walCleanUp
();
twalh
walOpen
(
char
*
path
,
SWalCfg
*
pCfg
);
int32_t
walAlter
(
twalh
pWal
,
SWalCfg
*
pCfg
);
void
walStop
(
twalh
);
...
...
src/os/inc/osFile.h
浏览文件 @
4029cda3
...
...
@@ -20,17 +20,6 @@
extern
"C"
{
#endif
#define tread(fd, buf, count) read(fd, buf, count)
#define twrite(fd, buf, count) write(fd, buf, count)
#define tlseek(fd, offset, whence) lseek(fd, offset, whence)
#define tclose(fd) \
{ \
if (FD_VALID(fd)) { \
close(fd); \
fd = FD_INITIALIZER; \
} \
}
int64_t
taosReadImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosWriteImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
);
...
...
@@ -39,7 +28,13 @@ int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstP
#define taosRead(fd, buf, count) taosReadImp(fd, buf, count)
#define taosWrite(fd, buf, count) taosWriteImp(fd, buf, count)
#define taosLSeek(fd, offset, whence) taosLSeekImp(fd, offset, whence)
#define taosClose(x) tclose(x)
#define taosClose(fd) \
{ \
if (FD_VALID(fd)) { \
close(fd); \
fd = FD_INITIALIZER; \
} \
}
// TAOS_OS_FUNC_FILE_SENDIFLE
int64_t
taosSendFile
(
int32_t
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
size
);
...
...
src/os/src/detail/osFile.c
浏览文件 @
4029cda3
...
...
@@ -116,7 +116,7 @@ int64_t taosWriteImp(int32_t fd, void *buf, int64_t n) {
}
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
)
{
return
(
int64_t
)
t
lseek
(
fd
,
(
long
)
offset
,
whence
);
return
(
int64_t
)
lseek
(
fd
,
(
long
)
offset
,
whence
);
}
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
...
...
src/util/inc/tfile.h
浏览文件 @
4029cda3
...
...
@@ -20,23 +20,26 @@
extern
"C"
{
#endif
#include <unistd.h>
// init taos file module
int32_t
tf
i
nit
();
int32_t
tf
I
nit
();
// clean up taos file module
void
tf
c
leanup
();
void
tf
C
leanup
();
// the same syntax as UNIX standard open/close/read/write
// but FD is int64_t and will never be reused
int64_t
tfopen
(
const
char
*
pathname
,
int32_t
flags
);
int64_t
tfclose
(
int64_t
tfd
);
int64_t
tfwrite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfread
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfOpen
(
const
char
*
pathname
,
int32_t
flags
);
int64_t
tfOpenM
(
const
char
*
pathname
,
int32_t
flags
,
mode_t
mode
);
int64_t
tfClose
(
int64_t
tfd
);
int64_t
tfWrite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfRead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int32_t
tfFsync
(
int64_t
tfd
);
bool
tfValid
(
int64_t
tfd
);
int64_t
tfLseek
(
int64_t
tfd
,
int64_t
offset
,
int32_t
whence
);
int32_t
tfFtruncate
(
int64_t
tfd
,
int64_t
length
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_T
REF
_H
#endif // TDENGINE_T
FILE
_H
src/util/src/tfile.c
浏览文件 @
4029cda3
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "tulog.h"
...
...
@@ -21,40 +22,52 @@
static
int32_t
tsFileRsetId
=
-
1
;
static
void
t
aos
CloseFile
(
void
*
p
)
{
static
void
t
f
CloseFile
(
void
*
p
)
{
close
((
int32_t
)(
uintptr_t
)
p
);
}
int32_t
tfinit
()
{
tsFileRsetId
=
taosOpenRef
(
2000
,
taosCloseFile
);
return
tsFileRsetId
;
int32_t
tfInit
()
{
tsFileRsetId
=
taosOpenRef
(
2000
,
tfCloseFile
);
if
(
tsFileRsetId
>
0
)
{
return
0
;
}
else
{
return
-
1
;
}
}
void
tf
c
leanup
()
{
void
tf
C
leanup
()
{
if
(
tsFileRsetId
>=
0
)
taosCloseRef
(
tsFileRsetId
);
tsFileRsetId
=
-
1
;
}
int64_t
tfopen
(
const
char
*
pathname
,
int32_t
flags
)
{
int32_t
fd
=
open
(
pathname
,
flags
);
static
int64_t
tfOpenImp
(
int32_t
fd
)
{
if
(
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
void
*
p
=
(
void
*
)(
int64_t
)
fd
;
void
*
p
=
(
void
*
)(
int64_t
)
fd
;
int64_t
rid
=
taosAddRef
(
tsFileRsetId
,
p
);
if
(
rid
<
0
)
close
(
fd
);
return
rid
;
}
int64_t
tfclose
(
int64_t
tfd
)
{
int64_t
tfOpen
(
const
char
*
pathname
,
int32_t
flags
)
{
int32_t
fd
=
open
(
pathname
,
flags
);
return
tfOpenImp
(
fd
);
}
int64_t
tfOpenM
(
const
char
*
pathname
,
int32_t
flags
,
mode_t
mode
)
{
int32_t
fd
=
open
(
pathname
,
flags
,
mode
);
return
tfOpenImp
(
fd
);
}
int64_t
tfClose
(
int64_t
tfd
)
{
return
taosRemoveRef
(
tsFileRsetId
,
tfd
);
}
int64_t
tf
w
rite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
int64_t
tf
W
rite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
...
...
@@ -67,7 +80,7 @@ int64_t tfwrite(int64_t tfd, void *buf, int64_t count) {
return
ret
;
}
int64_t
tf
r
ead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
int64_t
tf
R
ead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
...
...
@@ -79,3 +92,32 @@ int64_t tfread(int64_t tfd, void *buf, int64_t count) {
taosReleaseRef
(
tsFileRsetId
,
tfd
);
return
ret
;
}
int64_t
tfFsync
(
int64_t
tfd
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
fsync
(
fd
);
}
bool
tfValid
(
int64_t
tfd
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
return
p
!=
NULL
;
}
int64_t
tfLseek
(
int64_t
tfd
,
int64_t
offset
,
int32_t
whence
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
taosLSeek
(
fd
,
offset
,
whence
);
}
int32_t
tfFtruncate
(
int64_t
tfd
,
int64_t
length
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
taosFtruncate
(
fd
,
length
);
}
src/wal/inc/walInt.h
浏览文件 @
4029cda3
...
...
@@ -44,8 +44,8 @@ typedef struct {
uint64_t
version
;
int64_t
fileId
;
int64_t
rid
;
int64_t
tfd
;
int32_t
vgId
;
int32_t
fd
;
int32_t
keep
;
int32_t
level
;
int32_t
fsyncPeriod
;
...
...
src/wal/src/walMgmt.c
浏览文件 @
4029cda3
...
...
@@ -17,6 +17,7 @@
#include "os.h"
#include "taoserror.h"
#include "tref.h"
#include "tfile.h"
#include "twal.h"
#include "walInt.h"
...
...
@@ -61,7 +62,7 @@ void *walOpen(char *path, SWalCfg *pCfg) {
}
pWal
->
vgId
=
pCfg
->
vgId
;
pWal
->
fd
=
-
1
;
pWal
->
t
fd
=
-
1
;
pWal
->
fileId
=
-
1
;
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
keep
=
pCfg
->
keep
;
...
...
@@ -124,7 +125,7 @@ void walClose(void *handle) {
SWal
*
pWal
=
handle
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
t
aosClose
(
pWal
->
fd
);
t
fClose
(
pWal
->
t
fd
);
pthread_mutex_unlock
(
&
pWal
->
mutex
);
taosRemoveRef
(
tsWal
.
refId
,
pWal
->
rid
);
}
...
...
@@ -143,7 +144,7 @@ static void walFreeObj(void *wal) {
SWal
*
pWal
=
wal
;
wDebug
(
"vgId:%d, wal:%p is freed"
,
pWal
->
vgId
,
pWal
);
t
aosClose
(
pWal
->
fd
);
t
fClose
(
pWal
->
t
fd
);
pthread_mutex_destroy
(
&
pWal
->
mutex
);
tfree
(
pWal
);
}
...
...
@@ -172,7 +173,7 @@ static void walFsyncAll() {
while
(
pWal
)
{
if
(
walNeedFsync
(
pWal
))
{
wTrace
(
"vgId:%d, do fsync, level:%d seq:%d rseq:%d"
,
pWal
->
vgId
,
pWal
->
level
,
pWal
->
fsyncSeq
,
tsWal
.
seq
);
int32_t
code
=
fsync
(
pWal
->
fd
);
int32_t
code
=
tfFsync
(
pWal
->
t
fd
);
if
(
code
!=
0
)
{
wError
(
"vgId:%d, file:%s, failed to fsync since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
code
));
}
...
...
src/wal/src/walWrite.c
浏览文件 @
4029cda3
...
...
@@ -18,6 +18,7 @@
#include "os.h"
#include "taoserror.h"
#include "tchecksum.h"
#include "tfile.h"
#include "twal.h"
#include "walInt.h"
...
...
@@ -36,8 +37,8 @@ int32_t walRenew(void *handle) {
pthread_mutex_lock
(
&
pWal
->
mutex
);
if
(
pWal
->
fd
>=
0
)
{
t
close
(
pWal
->
fd
);
if
(
tfValid
(
pWal
->
tfd
)
)
{
t
fClose
(
pWal
->
t
fd
);
wDebug
(
"vgId:%d, file:%s, it is closed"
,
pWal
->
vgId
,
pWal
->
name
);
}
...
...
@@ -49,9 +50,9 @@ int32_t walRenew(void *handle) {
}
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
pWal
->
tfd
=
tfOpenM
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
if
(
!
tfValid
(
pWal
->
tfd
)
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
}
else
{
...
...
@@ -67,7 +68,7 @@ void walRemoveOneOldFile(void *handle) {
SWal
*
pWal
=
handle
;
if
(
pWal
==
NULL
)
return
;
if
(
pWal
->
keep
==
TAOS_WAL_KEEP
)
return
;
if
(
pWal
->
fd
<=
0
)
return
;
if
(
!
tfValid
(
pWal
->
tfd
)
)
return
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
...
...
@@ -113,7 +114,7 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
int32_t
code
=
0
;
// no wal
if
(
pWal
->
fd
<=
0
)
return
0
;
if
(
!
tfValid
(
pWal
->
tfd
)
)
return
0
;
if
(
pWal
->
level
==
TAOS_WAL_NOLOG
)
return
0
;
if
(
pHead
->
version
<=
pWal
->
version
)
return
0
;
...
...
@@ -123,12 +124,12 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
pthread_mutex_lock
(
&
pWal
->
mutex
);
if
(
t
aosWrite
(
pWal
->
fd
,
pHead
,
contLen
)
!=
contLen
)
{
if
(
t
fWrite
(
pWal
->
t
fd
,
pHead
,
contLen
)
!=
contLen
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to write since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
}
else
{
wTrace
(
"vgId:%d, write wal, fileId:%"
PRId64
"
fd:%d
hver:%"
PRId64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
pWal
->
fileId
,
pWal
->
fd
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
wTrace
(
"vgId:%d, write wal, fileId:%"
PRId64
"
tfd:%"
PRId64
"
hver:%"
PRId64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
pWal
->
fileId
,
pWal
->
t
fd
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
pWal
->
version
=
pHead
->
version
;
}
...
...
@@ -141,11 +142,11 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
void
walFsync
(
void
*
handle
,
bool
forceFsync
)
{
SWal
*
pWal
=
handle
;
if
(
pWal
==
NULL
||
pWal
->
fd
<
0
)
return
;
if
(
pWal
==
NULL
||
!
tfValid
(
pWal
->
tfd
)
)
return
;
if
(
forceFsync
||
(
pWal
->
level
==
TAOS_WAL_FSYNC
&&
pWal
->
fsyncPeriod
==
0
))
{
wTrace
(
"vgId:%d, fileId:%"
PRId64
", do fsync"
,
pWal
->
vgId
,
pWal
->
fileId
);
if
(
fsync
(
pWal
->
fd
)
<
0
)
{
if
(
tfFsync
(
pWal
->
t
fd
)
<
0
)
{
wError
(
"vgId:%d, fileId:%"
PRId64
", fsync failed since %s"
,
pWal
->
vgId
,
pWal
->
fileId
,
strerror
(
errno
));
}
}
...
...
@@ -186,8 +187,8 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) {
// open the existing WAL file in append mode
pWal
->
fileId
=
0
;
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
pWal
->
tfd
=
tfOpenM
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
!
tfValid
(
pWal
->
tfd
)
)
{
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
}
...
...
@@ -217,22 +218,22 @@ int32_t walGetWalFile(void *handle, char *fileName, int64_t *fileId) {
return
code
;
}
static
void
walFtruncate
(
SWal
*
pWal
,
int
32_t
fd
,
int64_t
offset
)
{
t
aosFtruncate
(
fd
,
offset
);
fsync
(
fd
);
static
void
walFtruncate
(
SWal
*
pWal
,
int
64_t
t
fd
,
int64_t
offset
)
{
t
fFtruncate
(
t
fd
,
offset
);
tfFsync
(
t
fd
);
}
static
int32_t
walSkipCorruptedRecord
(
SWal
*
pWal
,
SWalHead
*
pHead
,
int
32_t
fd
,
int64_t
*
offset
)
{
static
int32_t
walSkipCorruptedRecord
(
SWal
*
pWal
,
SWalHead
*
pHead
,
int
64_t
t
fd
,
int64_t
*
offset
)
{
int64_t
pos
=
*
offset
;
while
(
1
)
{
pos
++
;
if
(
lseek
(
fd
,
pos
,
SEEK_SET
)
<
0
)
{
if
(
tfLseek
(
t
fd
,
pos
,
SEEK_SET
)
<
0
)
{
wError
(
"vgId:%d, failed to seek from corrupted wal file since %s"
,
pWal
->
vgId
,
strerror
(
errno
));
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
if
(
t
aosRead
(
fd
,
pHead
,
sizeof
(
SWalHead
))
<=
0
)
{
if
(
t
fRead
(
t
fd
,
pHead
,
sizeof
(
SWalHead
))
<=
0
)
{
wError
(
"vgId:%d, read to end of corrupted wal file, offset:%"
PRId64
,
pWal
->
vgId
,
pos
);
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
...
...
@@ -259,8 +260,8 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
return
TAOS_SYSTEM_ERROR
(
errno
);
}
int
32_t
fd
=
o
pen
(
name
,
O_RDWR
);
if
(
fd
<
0
)
{
int
64_t
tfd
=
tfO
pen
(
name
,
O_RDWR
);
if
(
!
tfValid
(
tfd
)
)
{
wError
(
"vgId:%d, file:%s, failed to open for restore since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
tfree
(
buffer
);
return
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -273,7 +274,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
SWalHead
*
pHead
=
buffer
;
while
(
1
)
{
int32_t
ret
=
t
aosRead
(
fd
,
pHead
,
sizeof
(
SWalHead
));
int32_t
ret
=
t
fRead
(
t
fd
,
pHead
,
sizeof
(
SWalHead
));
if
(
ret
==
0
)
break
;
if
(
ret
<
0
)
{
...
...
@@ -284,16 +285,16 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
if
(
ret
<
sizeof
(
SWalHead
))
{
wError
(
"vgId:%d, file:%s, failed to read wal head, ret is %d"
,
pWal
->
vgId
,
name
,
ret
);
walFtruncate
(
pWal
,
fd
,
offset
);
walFtruncate
(
pWal
,
t
fd
,
offset
);
break
;
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
wError
(
"vgId:%d, file:%s, wal head cksum is messed up, hver:%"
PRIu64
" len:%d offset:%"
PRId64
,
pWal
->
vgId
,
name
,
pHead
->
version
,
pHead
->
len
,
offset
);
code
=
walSkipCorruptedRecord
(
pWal
,
pHead
,
fd
,
&
offset
);
code
=
walSkipCorruptedRecord
(
pWal
,
pHead
,
t
fd
,
&
offset
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
walFtruncate
(
pWal
,
fd
,
offset
);
walFtruncate
(
pWal
,
t
fd
,
offset
);
break
;
}
}
...
...
@@ -310,7 +311,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
pHead
=
buffer
;
}
ret
=
t
aosRead
(
fd
,
pHead
->
cont
,
pHead
->
len
);
ret
=
t
fRead
(
t
fd
,
pHead
->
cont
,
pHead
->
len
);
if
(
ret
<
0
)
{
wError
(
"vgId:%d, file:%s, failed to read wal body since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
code
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -332,7 +333,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
(
*
writeFp
)(
pVnode
,
pHead
,
TAOS_QTYPE_WAL
,
NULL
);
}
t
close
(
fd
);
t
fClose
(
t
fd
);
tfree
(
buffer
);
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录