diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index d561e6daedfceee6ae746ccf0d7b91dd8b886d84..fbfa1b73be6cae79c547b3f21248e25af5cddf3b 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -250,6 +250,7 @@ static int32_t mndInitSdb(SMnode *pMnode) { opt.path = pMnode->path; opt.pMnode = pMnode; opt.pWal = pMnode->pWal; + opt.sync = pMnode->syncMgmt.sync; pMnode->pSdb = sdbInit(&opt); if (pMnode->pSdb == NULL) { @@ -381,6 +382,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { mError("failed to open mnode since %s", terrstr()); return NULL; } + memset(pMnode, 0, sizeof(SMnode)); char timestr[24] = "1970-01-01 00:00:00.00"; (void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); diff --git a/source/dnode/mnode/sdb/CMakeLists.txt b/source/dnode/mnode/sdb/CMakeLists.txt index 2001a70da217d67e8a3b63137f40fbce9eaf6192..186c85004ab2e2acc4471fd268f3979894c32b58 100644 --- a/source/dnode/mnode/sdb/CMakeLists.txt +++ b/source/dnode/mnode/sdb/CMakeLists.txt @@ -5,5 +5,5 @@ target_include_directories( PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( - sdb os common util wal -) \ No newline at end of file + sdb os common util wal sync +) diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index d4db4709caa2f7a7a3d7c31e1aaf475acc067897..a6d81ecc0d85d468cbf880cb1904918ee8ddc024 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -169,6 +169,7 @@ typedef struct SSdbRow { typedef struct SSdb { SMnode *pMnode; SWal *pWal; + int64_t sync; char *currDir; char *tmpDir; int64_t commitIndex; @@ -212,6 +213,7 @@ typedef struct SSdbOpt { const char *path; SMnode *pMnode; SWal *pWal; + int64_t sync; } SSdbOpt; /** diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index e73fd28e71258adc85c9a2822b8a6b810bafbcdc..648ccff432dffe3b460a488940de3dcd953a8db8 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -53,6 +53,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { } pSdb->pWal = pOption->pWal; + pSdb->sync = pOption->sync; pSdb->applyIndex = -1; pSdb->applyTerm = -1; pSdb->applyConfig = -1; diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 5eedcc545a526dc1bb657f0173c54a1f03440de2..f2a18b7212c0c89bebc2fa48ec79f70a02af0771 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "sdb.h" +#include "sync.h" #include "tchecksum.h" #include "wal.h" @@ -456,14 +457,25 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { taosThreadMutexLock(&pSdb->filelock); 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) { code = sdbWriteFileImp(pSdb); } if (code == 0) { 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) {