refactor: rsma restore

This commit is contained in:
Cary Xu 2022-06-27 15:02:18 +08:00
parent e2ec8b57d9
commit 16b2d7932d
2 changed files with 12 additions and 9 deletions

View File

@ -217,7 +217,7 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) {
} }
} }
// step 6: free the timer handle // step 6: cleanup the timer handle
if (RSMA_TMR_HANDLE(pStat)) { if (RSMA_TMR_HANDLE(pStat)) {
taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); taosTmrCleanUp(RSMA_TMR_HANDLE(pStat));
} }

View File

@ -18,7 +18,7 @@
static int32_t smaEvalDays(SRetention *r, int8_t precision); static int32_t smaEvalDays(SRetention *r, int8_t precision);
static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type);
static int32_t smaRestore(SSma *pSma); static int32_t rsmaRestore(SSma *pSma);
#define SMA_SET_KEEP_CFG(l) \ #define SMA_SET_KEEP_CFG(l) \
do { \ do { \
@ -101,6 +101,9 @@ int32_t smaOpen(SVnode *pVnode) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
} }
pVnode->pSma = pSma;
pSma->pVnode = pVnode; pSma->pVnode = pVnode;
taosThreadMutexInit(&pSma->mutex, NULL); taosThreadMutexInit(&pSma->mutex, NULL);
pSma->locked = false; pSma->locked = false;
@ -118,13 +121,11 @@ int32_t smaOpen(SVnode *pVnode) {
ASSERT(0); ASSERT(0);
} }
} }
}
pVnode->pSma = pSma; // restore the rsma
if (rsmaRestore(pSma) < 0) {
// restore the sma goto _err;
if (smaRestore(pSma) < 0) { }
goto _err;
} }
return 0; return 0;
@ -164,7 +165,9 @@ int32_t smaClose(SSma *pSma) {
* @param pSma * @param pSma
* @return int32_t * @return int32_t
*/ */
static int32_t smaRestore(SSma *pSma) { static int32_t rsmaRestore(SSma *pSma) {
ASSERT(VND_IS_RSMA(pSma->pVnode));
// iterate all stables to restore the rsma env // iterate all stables to restore the rsma env
SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t));
if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) {