From b2de711a849e812695c919148d0b3451678b06f8 Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 10 Apr 2023 11:33:25 +0800 Subject: [PATCH] fix: change orReplace logic in mnode --- source/dnode/mnode/impl/src/mndFunc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index dcbcb5ea05..f0104194d8 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -231,11 +231,10 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre if(pCreate->orReplace == 1){ SFuncObj *oldFunc = mndAcquireFunc(pMnode, pCreate->name); - if(oldFunc == NULL){ - goto _OVER; + if(oldFunc != NULL){ + func.funcVersion = oldFunc->funcVersion + 1; + mndReleaseFunc(pMnode, oldFunc); } - func.funcVersion = oldFunc->funcVersion + 1; - mndReleaseFunc(pMnode, oldFunc); } pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func"); @@ -319,6 +318,9 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) { mInfo("func:%s, already exist, ignore exist is set", createReq.name); code = 0; goto _OVER; + } else if (createReq.orReplace) { + mInfo("func:%s, replace function is set", createReq.name); + code = 0; } else { terrno = TSDB_CODE_MND_FUNC_ALREADY_EXIST; goto _OVER; -- GitLab