diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index c435cdb03b..8b1ac3ed8d 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -75,14 +75,18 @@ extern "C" { #define WAL_CUR_FAILED 1 #pragma pack(push, 1) -typedef enum { TAOS_WAL_NOLOG = 0, TAOS_WAL_WRITE = 1, TAOS_WAL_FSYNC = 2 } EWalType; +typedef enum { + TAOS_WAL_NOLOG = 0, + TAOS_WAL_WRITE = 1, + TAOS_WAL_FSYNC = 2, +} EWalType; // used by sync module typedef struct { int8_t isWeek; uint64_t seqNum; uint64_t term; -} SSyncInfo; +} SSyncLogMeta; typedef struct SWalReadHead { int8_t headVer; @@ -92,8 +96,8 @@ typedef struct SWalReadHead { int64_t ingestTs; // not implemented int64_t version; - // sync info - SSyncInfo syncInfo; + // sync meta + SSyncLogMeta syncMeta; char body[]; } SWalReadHead; @@ -169,7 +173,8 @@ int32_t walAlter(SWal *, SWalCfg *pCfg); void walClose(SWal *); // write -int64_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncInfo info, const void *body, int32_t bodyLen); +int64_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, + int32_t bodyLen); int64_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen); void walFsync(SWal *, bool force); diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index e1b347d2b8..a578c6f368 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -253,7 +253,7 @@ static int walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { return 0; } -int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncInfo syncInfo, const void *body, +int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLogMeta syncMeta, const void *body, int32_t bodyLen) { if (pWal == NULL) return -1; int code = 0; @@ -299,7 +299,7 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncInf pWal->writeHead.head.msgType = msgType; // sync info - pWal->writeHead.head.syncInfo = syncInfo; + pWal->writeHead.head.syncMeta = syncMeta; pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead); pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen); @@ -338,12 +338,12 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncInf } int64_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen) { - SSyncInfo info = { + SSyncLogMeta syncMeta = { .isWeek = -1, .seqNum = UINT64_MAX, .term = UINT64_MAX, }; - return walWriteWithSyncInfo(pWal, index, msgType, info, body, bodyLen); + return walWriteWithSyncInfo(pWal, index, msgType, syncMeta, body, bodyLen); } void walFsync(SWal *pWal, bool forceFsync) {