refacotr(sync): call syncBeginSnapshot instead of walBeginSnapshot
This commit is contained in:
parent
5965629b2e
commit
a35ad361d0
|
@ -250,6 +250,7 @@ static int32_t mndInitSdb(SMnode *pMnode) {
|
||||||
opt.path = pMnode->path;
|
opt.path = pMnode->path;
|
||||||
opt.pMnode = pMnode;
|
opt.pMnode = pMnode;
|
||||||
opt.pWal = pMnode->pWal;
|
opt.pWal = pMnode->pWal;
|
||||||
|
opt.sync = pMnode->syncMgmt.sync;
|
||||||
|
|
||||||
pMnode->pSdb = sdbInit(&opt);
|
pMnode->pSdb = sdbInit(&opt);
|
||||||
if (pMnode->pSdb == NULL) {
|
if (pMnode->pSdb == NULL) {
|
||||||
|
@ -381,6 +382,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
||||||
mError("failed to open mnode since %s", terrstr());
|
mError("failed to open mnode since %s", terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
memset(pMnode, 0, sizeof(SMnode));
|
||||||
|
|
||||||
char timestr[24] = "1970-01-01 00:00:00.00";
|
char timestr[24] = "1970-01-01 00:00:00.00";
|
||||||
(void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
(void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||||
|
|
|
@ -5,5 +5,5 @@ target_include_directories(
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
sdb os common util wal
|
sdb os common util wal sync
|
||||||
)
|
)
|
|
@ -169,6 +169,7 @@ typedef struct SSdbRow {
|
||||||
typedef struct SSdb {
|
typedef struct SSdb {
|
||||||
SMnode *pMnode;
|
SMnode *pMnode;
|
||||||
SWal *pWal;
|
SWal *pWal;
|
||||||
|
int64_t sync;
|
||||||
char *currDir;
|
char *currDir;
|
||||||
char *tmpDir;
|
char *tmpDir;
|
||||||
int64_t commitIndex;
|
int64_t commitIndex;
|
||||||
|
@ -212,6 +213,7 @@ typedef struct SSdbOpt {
|
||||||
const char *path;
|
const char *path;
|
||||||
SMnode *pMnode;
|
SMnode *pMnode;
|
||||||
SWal *pWal;
|
SWal *pWal;
|
||||||
|
int64_t sync;
|
||||||
} SSdbOpt;
|
} SSdbOpt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,6 +53,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pSdb->pWal = pOption->pWal;
|
pSdb->pWal = pOption->pWal;
|
||||||
|
pSdb->sync = pOption->sync;
|
||||||
pSdb->applyIndex = -1;
|
pSdb->applyIndex = -1;
|
||||||
pSdb->applyTerm = -1;
|
pSdb->applyTerm = -1;
|
||||||
pSdb->applyConfig = -1;
|
pSdb->applyConfig = -1;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "sdb.h"
|
#include "sdb.h"
|
||||||
|
#include "sync.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
#include "wal.h"
|
#include "wal.h"
|
||||||
|
|
||||||
|
@ -456,14 +457,25 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) {
|
||||||
|
|
||||||
taosThreadMutexLock(&pSdb->filelock);
|
taosThreadMutexLock(&pSdb->filelock);
|
||||||
if (pSdb->pWal != NULL) {
|
if (pSdb->pWal != NULL) {
|
||||||
code = walBeginSnapshot(pSdb->pWal, pSdb->applyIndex);
|
// code = walBeginSnapshot(pSdb->pWal, pSdb->applyIndex);
|
||||||
|
if (pSdb->sync == 0) {
|
||||||
|
code = 0;
|
||||||
|
} else {
|
||||||
|
code = syncBeginSnapshot(pSdb->sync, pSdb->applyIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
code = sdbWriteFileImp(pSdb);
|
code = sdbWriteFileImp(pSdb);
|
||||||
}
|
}
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
if (pSdb->pWal != NULL) {
|
if (pSdb->pWal != NULL) {
|
||||||
code = walEndSnapshot(pSdb->pWal);
|
// code = walEndSnapshot(pSdb->pWal);
|
||||||
|
|
||||||
|
if (pSdb->sync == 0) {
|
||||||
|
code = 0;
|
||||||
|
} else {
|
||||||
|
code = syncEndSnapshot(pSdb->sync);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
|
Loading…
Reference in New Issue