save sdb in every 3 seconds

This commit is contained in:
Shengliang Guan 2022-01-25 11:46:15 +00:00
parent 59d7cb6d82
commit 2c3f35e7c7
6 changed files with 26 additions and 19 deletions

View File

@ -529,7 +529,7 @@ int32_t dndInitMgmt(SDnode *pDnode) {
} }
if (pMgmt->dropped) { if (pMgmt->dropped) {
dError("dnode will not start for its already dropped"); dError("dnode not start since its already dropped");
return -1; return -1;
} }

View File

@ -921,7 +921,7 @@ static int32_t mndProcessTransMsg(SMnodeMsg *pMsg) {
void mndTransPullup(SMnode *pMnode) { void mndTransPullup(SMnode *pMnode) {
STrans *pTrans = NULL; STrans *pTrans = NULL;
void *pIter = NULL; void * pIter = NULL;
while (1) { while (1) {
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans); pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
@ -930,4 +930,6 @@ void mndTransPullup(SMnode *pMnode) {
mndTransExecute(pMnode, pTrans); mndTransExecute(pMnode, pTrans);
sdbRelease(pMnode->pSdb, pTrans); sdbRelease(pMnode->pSdb, pTrans);
} }
sdbWriteFile(pMnode->pSdb);
} }

View File

@ -64,11 +64,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
void sdbCleanup(SSdb *pSdb) { void sdbCleanup(SSdb *pSdb) {
mDebug("start to cleanup sdb"); mDebug("start to cleanup sdb");
if (pSdb->curVer > pSdb->lastCommitVer) {
mDebug("write sdb file for current ver:%" PRId64 " larger than last commit ver:%" PRId64, pSdb->curVer,
pSdb->lastCommitVer);
sdbWriteFile(pSdb); sdbWriteFile(pSdb);
}
if (pSdb->currDir != NULL) { if (pSdb->currDir != NULL) {
tfree(pSdb->currDir); tfree(pSdb->currDir);

View File

@ -221,7 +221,7 @@ PARSE_SDB_DATA_ERROR:
return code; return code;
} }
int32_t sdbWriteFile(SSdb *pSdb) { static int32_t sdbWriteFileImp(SSdb *pSdb) {
int32_t code = 0; int32_t code = 0;
char tmpfile[PATH_MAX] = {0}; char tmpfile[PATH_MAX] = {0};
@ -229,7 +229,8 @@ int32_t sdbWriteFile(SSdb *pSdb) {
char curfile[PATH_MAX] = {0}; char curfile[PATH_MAX] = {0};
snprintf(curfile, sizeof(curfile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP); snprintf(curfile, sizeof(curfile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
mDebug("start to write file:%s", curfile); mDebug("start to write file:%s, current ver:%" PRId64 ", commit ver:%" PRId64, curfile, pSdb->curVer,
pSdb->lastCommitVer);
FileFd fd = taosOpenFileCreateWriteTrunc(tmpfile); FileFd fd = taosOpenFileCreateWriteTrunc(tmpfile);
if (fd <= 0) { if (fd <= 0) {
@ -323,12 +324,20 @@ int32_t sdbWriteFile(SSdb *pSdb) {
return code; return code;
} }
int32_t sdbWriteFile(SSdb *pSdb) {
if (pSdb->curVer == pSdb->lastCommitVer) {
return 0;
}
return sdbWriteFileImp(pSdb);
}
int32_t sdbDeploy(SSdb *pSdb) { int32_t sdbDeploy(SSdb *pSdb) {
if (sdbRunDeployFp(pSdb) != 0) { if (sdbRunDeployFp(pSdb) != 0) {
return -1; return -1;
} }
if (sdbWriteFile(pSdb) != 0) { if (sdbWriteFileImp(pSdb) != 0) {
return -1; return -1;
} }

View File

@ -178,9 +178,9 @@ if $rows != 3 then
endi endi
sql select * from st sql select * from st
#if $rows != 15 then if $rows != 15 then
# return -1 return -1
#endi endi
print =============== drop dnode print =============== drop dnode
sql drop dnode 2; sql drop dnode 2;

View File

@ -139,9 +139,9 @@ endi
print =============== query data frpm st print =============== query data frpm st
sql select * from st sql select * from st
#if $rows != 21 then if $rows != 21 then
# return -1 return -1
#endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
@ -200,8 +200,8 @@ endi
print =============== query data frpm st print =============== query data frpm st
sql select * from st sql select * from st
#if $rows != 21 then if $rows != 21 then
# return -1 return -1
#endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT