From f9f5449b5ddc16f6e0bbf9733b371a7b1427cd08 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 1 Aug 2022 14:13:03 +0800 Subject: [PATCH 1/2] refactor(sync): modify auto bench --- source/libs/sync/test/sh/auto_bench.sh | 11 +++++++---- source/libs/sync/test/sh/insert.tpl.json | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/libs/sync/test/sh/auto_bench.sh b/source/libs/sync/test/sh/auto_bench.sh index 06af59da34..d786b5f43c 100644 --- a/source/libs/sync/test/sh/auto_bench.sh +++ b/source/libs/sync/test/sh/auto_bench.sh @@ -1,7 +1,7 @@ #!/bin/bash -if [ $# != 6 ] ; then - echo "Uasge: $0 instances vgroups replica ctables rows weak" +if [ $# != 7 ] ; then + echo "Uasge: $0 instances vgroups replica ctables rows weak drop(yes/no)" echo "" exit 1 fi @@ -12,11 +12,13 @@ replica=$3 ctables=$4 rows=$5 weak=$6 +drop=$7 -echo "params: instances:${instances}, vgroups:${vgroups}, replica:${replica}, ctables:${ctables}, rows:${rows}" + +echo "params: instances:${instances}, vgroups:${vgroups}, replica:${replica}, ctables:${ctables}, rows:${rows}, weak:${weak}, drop:${drop}" dt=`date "+%Y-%m-%d-%H-%M-%S"` -casedir=instances_${instances}_vgroups_${vgroups}_replica_${replica}_ctables_${ctables}_rows_${rows}_weak_${weak}_${dt} +casedir=instances_${instances}_vgroups_${vgroups}_replica_${replica}_ctables_${ctables}_rows_${rows}_weak_${weak}_drop_${drop}_${dt} mkdir ${casedir} cp ./insert.tpl.json ${casedir} cd ${casedir} @@ -26,6 +28,7 @@ for i in `seq 1 ${instances}`;do cfg_file=bench_${i}.json cp ./insert.tpl.json ${cfg_file} rstfile=result_${i} + sed -i 's/tpl_drop_tpl/'${drop}'/g' ${cfg_file} sed -i 's/tpl_vgroups_tpl/'${vgroups}'/g' ${cfg_file} sed -i 's/tpl_replica_tpl/'${replica}'/g' ${cfg_file} sed -i 's/tpl_ctables_tpl/'${ctables}'/g' ${cfg_file} diff --git a/source/libs/sync/test/sh/insert.tpl.json b/source/libs/sync/test/sh/insert.tpl.json index e68ff3c5ff..1d952b98e8 100644 --- a/source/libs/sync/test/sh/insert.tpl.json +++ b/source/libs/sync/test/sh/insert.tpl.json @@ -15,8 +15,8 @@ "databases": [ { "dbinfo": { - "name": "db1", - "drop": "no", + "name": "db_auto", + "drop": "tpl_drop_tpl", "wal_retention_period": -1, "wal_retention_size": -1, "drop": "no", From cd7d434ed8d82c3cfd25c2268bc721c597f1f72a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 1 Aug 2022 15:50:51 +0800 Subject: [PATCH 2/2] refactor(sync): delete trace log --- source/dnode/mnode/impl/src/mndMain.c | 16 +------------ source/libs/sync/src/syncAppendEntriesReply.c | 10 -------- source/libs/sync/src/syncMain.c | 23 +------------------ 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 443d70aef9..c3296ac5c1 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -416,7 +416,7 @@ int32_t mndStart(SMnode *pMnode) { } mndSetRestore(pMnode, true); } - + grantReset(pMnode, TSDB_GRANT_ALL, 0); return mndInitTimer(pMnode); @@ -446,20 +446,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { return -1; } - do { - char *syncNodeStr = sync2SimpleStr(pMgmt->sync); - static int64_t mndTick = 0; - if (++mndTick % 10 == 1) { - mTrace("vgId:%d, sync trace msg:%s, %s", syncGetVgId(pMgmt->sync), TMSG_INFO(pMsg->msgType), syncNodeStr); - } - if (gRaftDetailLog) { - char logBuf[512] = {0}; - snprintf(logBuf, sizeof(logBuf), "==mndProcessSyncMsg== msgType:%d, syncNode: %s", pMsg->msgType, syncNodeStr); - syncRpcMsgLog2(logBuf, pMsg); - } - taosMemoryFree(syncNodeStr); - } while (0); - // ToDo: ugly! use function pointer if (syncNodeStrategy(pSyncNode) == SYNC_STRATEGY_STANDARD_SNAPSHOT) { if (pMsg->msgType == TDMT_SYNC_TIMEOUT) { diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index e0cc45bd1d..7279f0858b 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -335,10 +335,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); - if (gRaftDetailLog) { - sTrace("update next match, index:%" PRId64 ", success:%d", pMsg->matchIndex + 1, pMsg->success); - } - // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); @@ -349,9 +345,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); - if (gRaftDetailLog) { - sTrace("update next index not match, begin, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); - } // notice! int64, uint64 if (nextIndex > SYNC_INDEX_BEGIN) { @@ -393,9 +386,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex); - if (gRaftDetailLog) { - sTrace("update next index not match, end, index:%" PRId64 ", success:%d", nextIndex, pMsg->success); - } } SyncIndex afterNextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 9a56bb3fb8..00ce1f7b68 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -88,10 +88,6 @@ int64_t syncOpen(const SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); ASSERT(pSyncNode != NULL); - if (gRaftDetailLog) { - syncNodeLog2("syncNodeOpen open success", pSyncNode); - } - pSyncNode->rid = taosAddRef(tsNodeRefId, pSyncNode); if (pSyncNode->rid < 0) { syncFreeNode(pSyncNode); @@ -245,11 +241,7 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) { return -1; } - char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); - if (gRaftDetailLog) { - sInfo("==syncReconfig== newconfig:%s", newconfig); - } - + char* newconfig = syncCfg2Str((SSyncCfg*)pNewCfg); int32_t ret = 0; SRpcMsg rpcMsg = {0}; @@ -912,12 +904,6 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { ASSERT(pSyncNode->pRaftCfg != NULL); pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; - if (gRaftDetailLog) { - char* seralized = raftCfg2Str(pSyncNode->pRaftCfg); - sInfo("syncNodeOpen update config :%s", seralized); - taosMemoryFree(seralized); - } - raftCfgClose(pSyncNode->pRaftCfg); } @@ -1348,13 +1334,6 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp SEpSet epSet; syncUtilraftId2EpSet(destRaftId, &epSet); if (pSyncNode->FpSendMsg != NULL) { - if (gRaftDetailLog) { - char* JsonStr = syncRpcMsg2Str(pMsg); - syncUtilJson2Line(JsonStr); - sTrace("sync send msg, vgId:%d, type:%d, msg:%s", pSyncNode->vgId, pMsg->msgType, JsonStr); - taosMemoryFree(JsonStr); - } - // htonl syncUtilMsgHtoN(pMsg->pCont);