From 948d01a3ace4b06880a2c5bf711607763e7fdecf Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 28 Jul 2022 11:17:53 +0800 Subject: [PATCH 1/3] enh: let alter all dnodes work --- source/dnode/mnode/impl/src/mndDnode.c | 44 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index d84455ac94..3f90f087fd 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -805,14 +805,6 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { return -1; } - SDnodeObj *pDnode = mndAcquireDnode(pMnode, cfgReq.dnodeId); - if (pDnode == NULL) { - mError("dnode:%d, failed to config since %s ", cfgReq.dnodeId, terrstr()); - return -1; - } - SEpSet epSet = mndGetDnodeEpset(pDnode); - mndReleaseDnode(pMnode, pDnode); - SDCfgDnodeReq dcfgReq = {0}; if (strcasecmp(cfgReq.config, "resetlog") == 0) { strcpy(dcfgReq.config, "resetlog"); @@ -860,16 +852,36 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } } - int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq); - void *pBuf = rpcMallocCont(bufLen); + int32_t code = -1; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + while (1) { + SDnodeObj *pDnode = NULL; + pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode); + if (pIter == NULL) break; - if (pBuf == NULL) return -1; - tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq); + if (pDnode->id == cfgReq.dnodeId || cfgReq.dnodeId == -1 || cfgReq.dnodeId == 0) { + SEpSet epSet = mndGetDnodeEpset(pDnode); + int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq); + void *pBuf = rpcMallocCont(bufLen); - mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle, - dcfgReq.config, dcfgReq.value); - SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; - return tmsgSendReq(&epSet, &rpcMsg); + if (pBuf != NULL) { + tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq); + mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle, + dcfgReq.config, dcfgReq.value); + SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; + tmsgSendReq(&epSet, &rpcMsg); + code = 0; + } + } + + sdbRelease(pSdb, pDnode); + } + + if (code == -1) { + terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; + } + return code; } static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) { From 9d72eda2c5183552dc7f9b8e95c000cd89da7bba Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 28 Jul 2022 11:18:05 +0800 Subject: [PATCH 2/3] fix: deadlock while rollback --- source/dnode/mnode/impl/src/mndTrans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 2d7117c11f..b2a0e6aac8 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1287,6 +1287,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) { mDebug("trans:%d, stage keep on redoAction since %s", pTrans->id, tstrerror(code)); continueExec = false; } else { + pTrans->failedTimes++; pTrans->code = terrno; if (pTrans->policy == TRN_POLICY_ROLLBACK) { if (pTrans->lastAction != 0) { @@ -1306,7 +1307,6 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) { mError("trans:%d, stage from redoAction to rollback since %s", pTrans->id, terrstr()); continueExec = true; } else { - pTrans->failedTimes++; mError("trans:%d, stage keep on redoAction since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes); continueExec = false; } From 5185fa90c52ccfc61a58b0c52203d0dd3ae65c26 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 28 Jul 2022 11:48:14 +0800 Subject: [PATCH 3/3] test: add reproduce codes --- tests/script/tsim/mnode/basic4.sim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/script/tsim/mnode/basic4.sim b/tests/script/tsim/mnode/basic4.sim index 6b4c8c6b7c..0ffcdd8c00 100644 --- a/tests/script/tsim/mnode/basic4.sim +++ b/tests/script/tsim/mnode/basic4.sim @@ -45,11 +45,8 @@ endi if $data(2)[4] != ready then goto step2 endi -if $data(3)[4] != ready then - goto step2 -endi -system sh/exec.sh -n dnode3 -s stop -x SIGKILL +system sh/exec.sh -n dnode3 -s stop sql_error create mnode on dnode 3 print =============== step3: show mnodes