diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 60bec6ab659cbb92c275465c803a44f26581f484..dbe72bea7a2b7bdd2e6091da879cfd471460fc37 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -171,7 +171,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex); // execute fsm - if (pSyncNode->pFsm != NULL) { + if (pSyncNode != NULL && pSyncNode->pFsm != NULL) { int32_t code = syncNodeDoCommit(pSyncNode, beginIndex, endIndex, pSyncNode->state); if (code != 0) { sNError(pSyncNode, "advance commit index error, do commit begin:%" PRId64 ", end:%" PRId64, beginIndex, diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index a7594091639c3ce69c25abfe993b908e43084c28..4329722958187fd8ac73fe2898e57b92a5d963fa 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -64,7 +64,7 @@ SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, Syn } SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg) { - SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->dataLen); + SSyncRaftEntry* pEntry = syncEntryBuild((int32_t)(pMsg->dataLen)); if (pEntry == NULL) return NULL; memcpy(pEntry, pMsg->data, pMsg->dataLen); @@ -91,15 +91,14 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId) void syncEntryDestory(SSyncRaftEntry* pEntry) { if (pEntry != NULL) { - taosMemoryFree(pEntry); - sTrace("free entry: %p", pEntry); + taosMemoryFree(pEntry); } } void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg) { pRpcMsg->msgType = pEntry->originalRpcType; - pRpcMsg->contLen = pEntry->dataLen; + pRpcMsg->contLen = (int32_t)(pEntry->dataLen); pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); memcpy(pRpcMsg->pCont, pEntry->data, pRpcMsg->contLen); } @@ -339,7 +338,8 @@ int32_t raftEntryCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry* pEntry = NULL; int32_t code = raftEntryCacheGetEntryP(pCache, index, &pEntry); if (code == 1) { - *ppEntry = taosMemoryMalloc((int64_t)(pEntry->bytes)); + int32_t bytes = (int32_t)pEntry->bytes; + *ppEntry = taosMemoryMalloc((int64_t)bytes); memcpy(*ppEntry, pEntry, pEntry->bytes); (*ppEntry)->rid = -1; } else { diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 802595c55af72956434866ef9686b6f3c84d2a12..de5f71e5a99222ed433ffaa192766c5e8b4fdac4 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -91,7 +91,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh if (code == 0) { ASSERT(pEntry != NULL); - code = syncBuildAppendEntries(&rpcMsg, pEntry->bytes, pSyncNode->vgId); + code = syncBuildAppendEntries(&rpcMsg, (int32_t)(pEntry->bytes), pSyncNode->vgId); ASSERT(code == 0); pMsg = rpcMsg.pCont; diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 4fc7dd245dc198881198419e9b1f87f2d7c46266..da6f8a52d92499abf4b21d0a5582f9dfb391ad21 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -229,7 +229,10 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer); va_end(argpointer); - int32_t aqItems = pNode->pFsm->FpApplyQueueItems(pNode->pFsm); + int32_t aqItems = 0; + if (pNode != NULL && pNode->pFsm != NULL && pNode->pFsm->FpApplyQueueItems != NULL) { + aqItems = pNode->pFsm->FpApplyQueueItems(pNode->pFsm); + } // restore error code terrno = errCode;