提交 96eb6a9b 编写于 作者: L Liu Jicong

wal add sync info

上级 7bd71bcb
......@@ -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);
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册