fix: free stream/sma obj in trans
This commit is contained in:
parent
5ce84e4316
commit
04f9419829
|
@ -800,6 +800,11 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
|||
return conflict;
|
||||
}
|
||||
|
||||
static void mndTransFreeObj(SSdb *pSdb) {
|
||||
sdbFreeRowsByType(pSdb, SDB_STREAM);
|
||||
sdbFreeRowsByType(pSdb, SDB_SMA);
|
||||
}
|
||||
|
||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
||||
if (strlen(pTrans->dbname1) == 0 && strlen(pTrans->dbname2) == 0) {
|
||||
|
@ -826,6 +831,9 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
|||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
mndTransFreeObj(pMnode->pSdb);
|
||||
|
||||
mDebug("trans:%d, prepare finished", pTrans->id);
|
||||
|
||||
STrans *pNew = mndAcquireTrans(pMnode, pTrans->id);
|
||||
|
|
|
@ -367,6 +367,7 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type);
|
|||
*/
|
||||
void sdbSetApplyInfo(SSdb *pSdb, int64_t index, int64_t term, int64_t config);
|
||||
void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config);
|
||||
void sdbFreeRowsByType(SSdb *pSdb, ESdbType type);
|
||||
|
||||
SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen);
|
||||
void sdbFreeRaw(SSdbRaw *pRaw);
|
||||
|
|
|
@ -65,6 +65,25 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
|||
return pSdb;
|
||||
}
|
||||
|
||||
void sdbFreeRowsByType(SSdb *pSdb, ESdbType type) {
|
||||
SHashObj *hash = pSdb->hashObjs[type];
|
||||
if (hash == NULL || !taosHashGetSize(hash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||
while (ppRow != NULL) {
|
||||
SSdbRow *pRow = *ppRow;
|
||||
if (pRow == NULL) {
|
||||
ppRow = taosHashIterate(hash, ppRow);
|
||||
continue;
|
||||
}
|
||||
sdbFreeRow(pSdb, pRow, false);
|
||||
ppRow = taosHashIterate(hash, ppRow);
|
||||
}
|
||||
taosHashClear(hash);
|
||||
}
|
||||
|
||||
void sdbCleanup(SSdb *pSdb) {
|
||||
mDebug("start to cleanup sdb");
|
||||
|
||||
|
|
Loading…
Reference in New Issue