未验证 提交 a9d19f83 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #2626 from taosdata/feature/sangshuduo/random-file-fail

replace read/write with tread/twrite in wal.
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "taoserror.h" #include "taoserror.h"
#include "twal.h" #include "twal.h"
#include "tqueue.h" #include "tqueue.h"
#include "tfile.h"
#define walPrefix "wal" #define walPrefix "wal"
...@@ -180,7 +181,7 @@ int walWrite(void *handle, SWalHead *pHead) { ...@@ -180,7 +181,7 @@ int walWrite(void *handle, SWalHead *pHead) {
taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SWalHead)); taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SWalHead));
int contLen = pHead->len + sizeof(SWalHead); int contLen = pHead->len + sizeof(SWalHead);
if(write(pWal->fd, pHead, contLen) != contLen) { if(twrite(pWal->fd, pHead, contLen) != contLen) {
wError("wal:%s, failed to write(%s)", pWal->name, strerror(errno)); wError("wal:%s, failed to write(%s)", pWal->name, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
} else { } else {
...@@ -325,7 +326,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) { ...@@ -325,7 +326,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
wDebug("wal:%s, start to restore", name); wDebug("wal:%s, start to restore", name);
while (1) { while (1) {
int ret = read(fd, pHead, sizeof(SWalHead)); int ret = tread(fd, pHead, sizeof(SWalHead));
if ( ret == 0) break; if ( ret == 0) break;
if (ret != sizeof(SWalHead)) { if (ret != sizeof(SWalHead)) {
...@@ -340,7 +341,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) { ...@@ -340,7 +341,7 @@ static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp) {
break; break;
} }
ret = read(fd, pHead->cont, pHead->len); ret = tread(fd, pHead->cont, pHead->len);
if ( ret != pHead->len) { if ( ret != pHead->len) {
wWarn("wal:%s, failed to read body, skip, len:%d ret:%d", name, pHead->len, ret); wWarn("wal:%s, failed to read body, skip, len:%d ret:%d", name, pHead->len, ret);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册