From 11f153cf1a8bb1dc784d178c9bc3321bdb6ff1bc Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Mon, 24 Oct 2022 09:18:35 +0800 Subject: [PATCH 1/2] fix(client): memory leak --- include/common/tmsg.h | 30 +++++++++++++++--------------- source/client/src/clientTmq.c | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index c58cc3c7c5..a0f78d0d59 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1234,20 +1234,20 @@ int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); typedef struct { - int32_t vgVersion; - int32_t buffer; - int32_t pageSize; - int32_t pages; - int32_t cacheLastSize; - int32_t daysPerFile; - int32_t daysToKeep0; - int32_t daysToKeep1; - int32_t daysToKeep2; - int32_t walFsyncPeriod; - int8_t walLevel; - int8_t strict; - int8_t cacheLast; - int64_t reserved[8]; + int32_t vgVersion; + int32_t buffer; + int32_t pageSize; + int32_t pages; + int32_t cacheLastSize; + int32_t daysPerFile; + int32_t daysToKeep0; + int32_t daysToKeep1; + int32_t daysToKeep2; + int32_t walFsyncPeriod; + int8_t walLevel; + int8_t strict; + int8_t cacheLast; + int64_t reserved[8]; } SAlterVnodeConfigReq; int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq); @@ -3065,7 +3065,7 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) { } static FORCE_INLINE void tDeleteSMqAskEpRsp(SMqAskEpRsp* pRsp) { - taosArrayDestroyEx(pRsp->topics, (void (*)(void*))tDeleteSMqSubTopicEp); + taosArrayDestroyEx(pRsp->topics, (FDelete)tDeleteSMqSubTopicEp); } #define TD_AUTO_CREATE_TABLE 0x1 diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 0b7b80649e..6e3e274052 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1206,7 +1206,7 @@ CREATE_MSG_FAIL: return -1; } -bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { +bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { bool set = false; int32_t topicNumGet = taosArrayGetSize(pRsp->topics); @@ -1599,6 +1599,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset) SMqAskEpRsp* rspMsg = &pEpRspWrapper->msg; tmqUpdateEp(tmq, rspWrapper->epoch, rspMsg); /*tmqClearUnhandleMsg(tmq);*/ + tDeleteSMqAskEpRsp(rspMsg); *pReset = true; } else { *pReset = false; From bbb0475d69d68ad2de14625e1406f3abb999dc73 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 10:05:57 +0800 Subject: [PATCH 2/2] fix: alter replica one by one --- source/dnode/mnode/impl/src/mndVgroup.c | 3 ++- tests/script/tsim/db/alter_replica_13.sim | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index f46fc5d23e..9bd89c1983 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1586,10 +1586,11 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1; if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1; if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1; if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; } else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) { mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName, pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId); diff --git a/tests/script/tsim/db/alter_replica_13.sim b/tests/script/tsim/db/alter_replica_13.sim index db64d4ede3..ab4f349002 100644 --- a/tests/script/tsim/db/alter_replica_13.sim +++ b/tests/script/tsim/db/alter_replica_13.sim @@ -127,8 +127,27 @@ if $data[0][8] != follower then goto step4 endi -print ============= step5: stop dnode 2 +print ============= step5: result +$i = 0 +while $i < 1000 + $i = $i + 1 + sleep 1000 + sql show db.vgroups + print ===> loop: $i | v0: $data03 $data04 | v1: $data05 $data06 | v2: $data07 $data08 + if $data[0][4] != leader then + return -1 + endi + if $data[0][6] != follower then + return -1 + endi + if $data[0][8] != follower then + return -1 + endi +endw + + +print ============= step5: stop dnode 2 sql select * from db.stb if $rows != 1 then return -1