From 1dbe0650e03d8316c185fea2fb2ef3cd531c9b2e Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 12 May 2022 14:20:50 +0800 Subject: [PATCH] enh(wal): set errno code --- source/libs/wal/src/walRead.c | 13 ++++++++++--- source/libs/wal/src/walWrite.c | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 0cfe75bf33..7dfe1b8989 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -130,6 +130,7 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) { } } + // code set inner if (walReadSeekFilePos(pRead, pRet->firstVer, ver) < 0) { return -1; } @@ -249,16 +250,22 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { // TODO: check wal life if (pRead->curVersion != ver) { if (walReadSeekVer(pRead, ver) < 0) { + terrno = TSDB_CODE_WAL_INVALID_VER; + wError("unexpected wal log version: % " PRId64 ", since seek error", ver); return -1; } } - if (!taosValidFile(pRead->pReadLogTFile)) { - return -1; - } + /*if (!taosValidFile(pRead->pReadLogTFile)) {*/ + /*return -1;*/ + /*}*/ code = taosReadFile(pRead->pReadLogTFile, pRead->pHead, sizeof(SWalHead)); if (code != sizeof(SWalHead)) { + if (code < 0) + terrno = TAOS_SYSTEM_ERROR(errno); + else + terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index da1c36dcc4..2e43997584 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -225,6 +225,7 @@ int walRoll(SWal *pWal) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } + // terrno set inner code = walRollFileInfo(pWal); if (code != 0) { return -1; -- GitLab