From d4abe20eeb81abe1872f23963cb770133f3a378c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 25 Jul 2022 18:21:13 +0800 Subject: [PATCH] fix: can't drop db since transaction conflict --- source/dnode/mnode/impl/src/mndOffset.c | 10 +++++----- source/dnode/mnode/impl/src/mndSubscribe.c | 10 ++++++---- source/dnode/mnode/impl/src/mndTopic.c | 11 +++++++---- source/dnode/mnode/impl/src/mndTrans.c | 1 + 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index 00753de0ec..9f6108004d 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -281,7 +281,7 @@ static int32_t mndSetDropOffsetRedoLogs(SMnode *pMnode, STrans *pTrans, SMqOffse } int32_t mndDropOffsetByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -297,15 +297,15 @@ int32_t mndDropOffsetByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { if (mndSetDropOffsetCommitLogs(pMnode, pTrans, pOffset) < 0) { sdbRelease(pSdb, pOffset); - goto END; + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } sdbRelease(pSdb, pOffset); } - code = 0; -END: - return code; + return code; } int32_t mndDropOffsetByTopic(SMnode *pMnode, STrans *pTrans, const char *topic) { diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 245dc413f1..8feed476cd 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -824,7 +824,7 @@ int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj } int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -840,12 +840,14 @@ int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { sdbRelease(pSdb, pSub); - goto END; + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } + + sdbRelease(pSdb, pSub); } - code = 0; -END: return code; } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7acfc95bfc..7e3e5a9838 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -833,7 +833,7 @@ static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter) { } int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { - int32_t code = -1; + int32_t code = 0; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -848,11 +848,14 @@ int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { } if (mndSetDropTopicCommitLogs(pMnode, pTrans, pTopic) < 0) { - goto END; + sdbRelease(pSdb, pTopic); + sdbCancelFetch(pSdb, pIter); + code = -1; + break; } + + sdbRelease(pSdb, pTopic); } - code = 0; -END: return code; } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 096a1534fd..04587d96a8 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -794,6 +794,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { mError("trans:%d, can't execute since conflict with trans:%d, db1:%s db2:%s", pNew->id, pTrans->id, pTrans->dbname1, pTrans->dbname2); + conflict = true; sdbRelease(pMnode->pSdb, pTrans); } -- GitLab