From daa3c6bbf4b8b2eb260776253317cc5754291275 Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 18 Nov 2024 15:57:06 +0800 Subject: [PATCH] ehn/add-sync-msg-statis --- source/libs/sync/src/syncReplication.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index a900b4707d..66c49834d8 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -88,15 +88,20 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI pMsg->destId = *destRaftId; TAOS_CHECK_RETURN(syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg)); - int32_t nRef = atomic_fetch_add_32(&pSyncNode->sendCount, 1); - if (nRef <= 0) { - sError("vgId:%d, send count is %d", pSyncNode->vgId, nRef); + int32_t nRef = 0; + if (pSyncNode != NULL) { + nRef = atomic_fetch_add_32(&pSyncNode->sendCount, 1); + if (nRef <= 0) { + sError("vgId:%d, send count is %d", pSyncNode->vgId, nRef); + } } SSyncLogReplMgr* mgr = syncNodeGetLogReplMgr(pSyncNode, (SRaftId*)destRaftId); - nRef = atomic_fetch_add_32(&mgr->sendCount, 1); - if (nRef <= 0) { - sError("vgId:%d, send count is %d", pSyncNode->vgId, nRef); + if (mgr != NULL) { + nRef = atomic_fetch_add_32(&mgr->sendCount, 1); + if (nRef <= 0) { + sError("vgId:%d, send count is %d", pSyncNode->vgId, nRef); + } } TAOS_RETURN(TSDB_CODE_SUCCESS);