diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index cf0d4d25e85535671aea1d3e2e90303e2e420c7d..3f3b794f46cb5c3b82b7d5476f400b71aa066c8e 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -79,7 +79,7 @@ void syncNodeRemove(int64_t rid) { taosRemoveRef(gNodeRefId, rid); } SSyncNode *syncNodeAcquire(int64_t rid) { SSyncNode *pNode = taosAcquireRef(gNodeRefId, rid); if (pNode == NULL) { - sTrace("failed to acquire node from refId:%" PRId64, rid); + sError("failed to acquire node from refId:%" PRId64, rid); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 38cc9f3dfedc061f7c2f620ee2af3504ee1eb783..64d79b060cf44be52394fdabfd7869caafa12792 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -256,6 +256,7 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync begin snapshot error"); return -1; } ASSERT(rid == pSyncNode->rid); @@ -394,6 +395,7 @@ int32_t syncEndSnapshot(int64_t rid) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync end snapshot error"); return -1; } ASSERT(rid == pSyncNode->rid); @@ -427,6 +429,7 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync step down error"); return -1; } ASSERT(rid == pSyncNode->rid); @@ -441,6 +444,7 @@ bool syncIsReadyForRead(int64_t rid) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync ready for read error"); return false; } ASSERT(rid == pSyncNode->rid); @@ -786,6 +790,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { if (pSyncNode == NULL) { syncNodeRelease(pSyncNode); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync propose error"); return -1; } ASSERT(rid == pSyncNode->rid); @@ -3004,9 +3009,19 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SyncClientRequest* pMsg, SyncInd // append entry code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); if (code != 0) { - // del resp mgr, call FpCommitCb - ASSERT(0); - return -1; + if (ths->replicaNum == 1) { + if (h) { + taosLRUCacheRelease(ths->pLogStore->pCache, h, false); + } else { + syncEntryDestory(pEntry); + } + return -1; + + } else { + // del resp mgr, call FpCommitCb + ASSERT(0); + return -1; + } } // if mulit replica, start replicate right now diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 04228d4759b6465791584f4a7d790d114622c2a0..39b2d69947193b8b45999d84bf9435c81edb1817 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -248,6 +248,8 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SWalReader* pWalHandle = pData->pWalHandle; if (pWalHandle == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("vgId:%d, wal handle is NULL", pData->pSyncNode->vgId); + return -1; }