diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index fb403f79a7b6b6dc76b74e8da1824916ced71d8f..b86f8f4c16e94b9143f1c7c8ae83ab2433baabb8 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -273,8 +273,8 @@ struct SVnode { #define VND_TSDB(vnd) ((vnd)->pTsdb) #define VND_RSMA0(vnd) ((vnd)->pTsdb) -#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb1) -#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb2) +#define VND_RSMA1(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L0]) +#define VND_RSMA2(vnd) ((vnd)->pSma->pRSmaTsdb[TSDB_RETENTION_L1]) #define VND_RETENTIONS(vnd) (&(vnd)->config.tsdbCfg.retentions) #define VND_IS_RSMA(v) ((v)->config.isRsma == 1) #define VND_IS_TSMA(v) ((v)->config.isTsma == 1) @@ -289,8 +289,7 @@ struct SSma { bool locked; TdThreadMutex mutex; SVnode* pVnode; - STsdb* pRSmaTsdb1; - STsdb* pRSmaTsdb2; + STsdb* pRSmaTsdb[TSDB_RETENTION_L2]; void* pTSmaEnv; void* pRSmaEnv; }; @@ -305,8 +304,8 @@ struct SSma { #define SMA_TSMA_ENV(s) ((s)->pTSmaEnv) #define SMA_RSMA_ENV(s) ((s)->pRSmaEnv) #define SMA_RSMA_TSDB0(s) ((s)->pVnode->pTsdb) -#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb1) -#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb2) +#define SMA_RSMA_TSDB1(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L0]) +#define SMA_RSMA_TSDB2(s) ((s)->pRSmaTsdb[TSDB_RETENTION_L1]) // sma void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data); diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index d73b03f4a2e9690c36693d29860a5e2ad09f720e..d260b11a55b966ee658f0ca88cbc25d7a3b79c9e 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -123,11 +123,9 @@ int32_t smaOpen(SVnode *pVnode) { } // restore the rsma -#if 1 if (rsmaRestore(pSma) < 0) { goto _err; } -#endif } return 0; diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 5b1a87be203c30dbc1638eb58a17e0777364f302..054a8b6edf59105969c49403491d3b2c6f1e3dab 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -605,7 +605,7 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche snprintf(flag, 10, "level %" PRIi8, pItem->level); blockDebugShowDataBlocks(pResult, flag); #endif - STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2); + STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]); SSubmitReq *pReq = NULL; // TODO: the schema update should be handled if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) < 0) { @@ -949,13 +949,8 @@ _err: * @return int32_t */ static int32_t tdRSmaRestoreTSDataReload(SSma *pSma, int64_t committed) { - // TODO - smaDebug("vgId:%d, rsma restore from %" PRIi64 ", ts data reload success", SMA_VID(pSma), committed); + // NOTHING TODO: the data would be restored from the unified WAL replay procedure return TSDB_CODE_SUCCESS; -_err: - smaError("vgId:%d, rsma restore from %" PRIi64 ", ts data reload failed since %s", SMA_VID(pSma), committed, - terrstr()); - return TSDB_CODE_FAILED; } int32_t tdProcessRSmaRestoreImpl(SSma *pSma) { diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 59242cbd8add3aa37abcc7dd639ee994a4d3a265..7241ca4971b2b56a9c36574d062fc661d714ec55 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -27,6 +27,8 @@ struct SVSnapReader { // tsdb int8_t tsdbDone; STsdbSnapReader *pTsdbReader; + // rsma + int8_t rsmaDone[TSDB_RETENTION_L2]; }; int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) { @@ -115,6 +117,42 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) } } + // RSMA ============== +#if 0 + if (VND_IS_RSMA(pReader->pVnode)) { + // RSMA1/RSMA2 + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (!pReader->rsmaDone[i]) { + if (!pReader->pVnode->pSma->pRSmaTsdb[i]) { + // no valid tsdb + pReader->rsmaDone[i] = 1; + continue; + } + if (pReader->pTsdbReader == NULL) { + code = tsdbSnapReaderOpen(pReader->pVnode->pSma->pRSmaTsdb[i], pReader->sver, pReader->ever, + &pReader->pTsdbReader); + if (code) goto _err; + } + + code = tsdbSnapRead(pReader->pTsdbReader, ppData); + if (code) { + goto _err; + } else { + if (*ppData) { + goto _exit; + } else { + pReader->tsdbDone = 1; + code = tsdbSnapReaderClose(&pReader->pTsdbReader); + if (code) goto _err; + } + } + } + } + // QTaskInfoFile + // TODO ... + } +#endif + *ppData = NULL; *nData = 0;