fix: ttl fill cache only in initialization
This commit is contained in:
parent
ede9cf4ab9
commit
dbf47f5fc1
|
@ -81,7 +81,7 @@ typedef struct {
|
|||
|
||||
int ttlMgrOpen(STtlManger** ppTtlMgr, TDB* pEnv, int8_t rollback);
|
||||
int ttlMgrClose(STtlManger* pTtlMgr);
|
||||
int ttlMgrBegin(STtlManger* pTtlMgr, void* pMeta);
|
||||
int ttlMgrPostOpen(STtlManger* pTtlMgr, void* pMeta);
|
||||
|
||||
int ttlMgrConvert(TTB* pOldTtlIdx, TTB* pNewTtlIdx, void* pMeta);
|
||||
int ttlMgrFlush(STtlManger* pTtlMgr, TXN* pTxn);
|
||||
|
|
|
@ -136,6 +136,7 @@ typedef struct STbUidStore STbUidStore;
|
|||
#define META_BEGIN_HEAP_NIL 2
|
||||
|
||||
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
||||
int metaPostOpen(SVnode* pVnode, SMeta** ppMeta); // for operations depend on "meta txn"
|
||||
int metaClose(SMeta** pMeta);
|
||||
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||
TXN* metaGetTxn(SMeta* pMeta);
|
||||
|
|
|
@ -40,10 +40,6 @@ int metaBegin(SMeta *pMeta, int8_t heap) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (ttlMgrBegin(pMeta->pTtlMgr, pMeta) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -29,6 +29,8 @@ static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen
|
|||
static int32_t metaInitLock(SMeta *pMeta) { return taosThreadRwlockInit(&pMeta->lock, NULL); }
|
||||
static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); }
|
||||
|
||||
static void metaCleanup(SMeta **ppMeta);
|
||||
|
||||
int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
||||
SMeta *pMeta = NULL;
|
||||
int ret;
|
||||
|
@ -180,51 +182,26 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
return 0;
|
||||
|
||||
_err:
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
taosMemoryFree(pMeta);
|
||||
metaCleanup(&pMeta);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int metaPostOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||
SMeta *pMeta = *ppMeta;
|
||||
if (ttlMgrPostOpen(pMeta->pTtlMgr, pMeta) < 0) {
|
||||
metaError("vgId:%d, failed to post open meta ttl since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
metaCleanup(ppMeta);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int metaClose(SMeta **ppMeta) {
|
||||
SMeta *pMeta = *ppMeta;
|
||||
if (pMeta) {
|
||||
if (pMeta->pEnv) metaAbort(pMeta);
|
||||
if (pMeta->pCache) metaCacheClose(pMeta);
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
|
||||
taosMemoryFreeClear(*ppMeta);
|
||||
}
|
||||
|
||||
metaCleanup(ppMeta);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,6 +247,32 @@ int32_t metaULock(SMeta *pMeta) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void metaCleanup(SMeta **ppMeta) {
|
||||
SMeta *pMeta = *ppMeta;
|
||||
if (pMeta) {
|
||||
if (pMeta->pEnv) metaAbort(pMeta);
|
||||
if (pMeta->pCache) metaCacheClose(pMeta);
|
||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
|
||||
if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx);
|
||||
if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx);
|
||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||
if (pMeta->pTtlMgr) ttlMgrClose(pMeta->pTtlMgr);
|
||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||
if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx);
|
||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
|
||||
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
|
||||
if (pMeta->pEnv) tdbClose(pMeta->pEnv);
|
||||
metaDestroyLock(pMeta);
|
||||
|
||||
taosMemoryFreeClear(*ppMeta);
|
||||
}
|
||||
}
|
||||
|
||||
static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
|
||||
STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1;
|
||||
STbDbKey *pTbDbKey2 = (STbDbKey *)pKey2;
|
||||
|
|
|
@ -79,8 +79,8 @@ int ttlMgrClose(STtlManger *pTtlMgr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ttlMgrBegin(STtlManger *pTtlMgr, void *pMeta) {
|
||||
metaInfo("ttl mgr start open");
|
||||
int ttlMgrPostOpen(STtlManger *pTtlMgr, void *pMeta) {
|
||||
metaInfo("ttl mgr start post open");
|
||||
int ret;
|
||||
|
||||
int64_t startNs = taosGetTimestampNs();
|
||||
|
@ -112,7 +112,7 @@ int ttlMgrBegin(STtlManger *pTtlMgr, void *pMeta) {
|
|||
|
||||
int64_t endNs = taosGetTimestampNs();
|
||||
|
||||
metaInfo("ttl mgr open end, hash size: %d, time consumed: %" PRId64 " ns", taosHashGetSize(pTtlMgr->pTtlCache),
|
||||
metaInfo("ttl mgr post open end, hash size: %d, time consumed: %" PRId64 " ns", taosHashGetSize(pTtlMgr->pTtlCache),
|
||||
endNs - startNs);
|
||||
_out:
|
||||
return ret;
|
||||
|
|
|
@ -416,6 +416,11 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
|||
goto _err;
|
||||
}
|
||||
|
||||
if (metaPostOpen(pVnode, &pVnode->pMeta) < 0) {
|
||||
vError("vgId:%d, failed to post open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// open sync
|
||||
if (vnodeSyncOpen(pVnode, dir)) {
|
||||
vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
|
|
Loading…
Reference in New Issue