From f397aa467881bb1cfc672ffe97b171050ab138d2 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Tue, 12 May 2020 05:41:03 +0000 Subject: [PATCH] restart TSDB when sync finished --- src/vnode/inc/vnodeInt.h | 1 + src/vnode/src/vnodeMain.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index d4842fdf7f..b2dd69df37 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -49,6 +49,7 @@ typedef struct { STsdbCfg tsdbCfg; SSyncCfg syncCfg; SWalCfg walCfg; + char * rootDir; } SVnodeObj; int vnodeWriteToQueue(void *param, void *pHead, int type); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 7d7a3e0bc8..c6fa840c1a 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -182,6 +182,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { pVnode->refCount = 1; pVnode->version = 0; pVnode->tsdbCfg.tsdbId = pVnode->vgId; + pVnode->rootDir = strdup(rootDir); taosAddIntHash(tsDnodeVnodesHash, pVnode->vgId, (char *)(&pVnode)); int32_t code = vnodeReadCfg(pVnode); @@ -271,6 +272,7 @@ void vnodeRelease(void *pVnodeRaw) { return; } + tfree(pVnode->rootDir); // remove read queue dnodeFreeRqueue(pVnode->rqueue); pVnode->rqueue = NULL; @@ -406,7 +408,15 @@ static void vnodeNotifyFileSynced(void *ahandle) { SVnodeObj *pVnode = ahandle; vTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); + char rootDir[128] = "\0"; + sprintf(rootDir, "%s/tsdb", pVnode->rootDir); // clsoe tsdb, then open tsdb + tsdbCloseRepo(pVnode->tsdb); + STsdbAppH appH = {0}; + appH.appH = (void *)pVnode; + appH.walCallBack = vnodeWalCallback; + appH.cqH = pVnode->cq; + pVnode->tsdb = tsdbOpenRepo(rootDir, &appH); } static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { -- GitLab