From 4baafd3417c53debfc535d460fc353eb85f2139d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 7 Nov 2022 17:46:45 +0800 Subject: [PATCH] refact: adjust sync log --- source/libs/sync/inc/syncRaftCfg.h | 3 -- source/libs/sync/inc/syncVoteMgr.h | 20 ---------- source/libs/sync/src/syncElection.c | 2 + source/libs/sync/src/syncMain.c | 2 +- source/libs/sync/src/syncUtil.c | 6 +-- source/libs/sync/src/syncVoteMgr.c | 57 +---------------------------- 6 files changed, 6 insertions(+), 84 deletions(-) diff --git a/source/libs/sync/inc/syncRaftCfg.h b/source/libs/sync/inc/syncRaftCfg.h index 94e5ffbc36..15ca82664a 100644 --- a/source/libs/sync/inc/syncRaftCfg.h +++ b/source/libs/sync/inc/syncRaftCfg.h @@ -93,9 +93,6 @@ typedef struct SRaftCfgMeta { int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path); -// for debug ------------------- -void raftCfgIndexLog2(char *s, SRaftCfgIndex *pCfg); - #ifdef __cplusplus } #endif diff --git a/source/libs/sync/inc/syncVoteMgr.h b/source/libs/sync/inc/syncVoteMgr.h index aa245ce32c..d894e91600 100644 --- a/source/libs/sync/inc/syncVoteMgr.h +++ b/source/libs/sync/inc/syncVoteMgr.h @@ -20,15 +20,8 @@ extern "C" { #endif -#include -#include -#include #include "syncInt.h" -#include "syncMessage.h" -#include "syncUtil.h" -#include "taosdef.h" -// SVotesGranted ----------------------------- typedef struct SVotesGranted { SRaftId (*replicas)[TSDB_MAX_REPLICA]; bool isGranted[TSDB_MAX_REPLICA]; @@ -49,13 +42,6 @@ void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term); cJSON *voteGranted2Json(SVotesGranted *pVotesGranted); char *voteGranted2Str(SVotesGranted *pVotesGranted); -// for debug ------------------- -void voteGrantedPrint(SVotesGranted *pObj); -void voteGrantedPrint2(char *s, SVotesGranted *pObj); -void voteGrantedLog(SVotesGranted *pObj); -void voteGrantedLog2(char *s, SVotesGranted *pObj); - -// SVotesRespond ----------------------------- typedef struct SVotesRespond { SRaftId (*replicas)[TSDB_MAX_REPLICA]; bool isRespond[TSDB_MAX_REPLICA]; @@ -73,12 +59,6 @@ void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term); cJSON *votesRespond2Json(SVotesRespond *pVotesRespond); char *votesRespond2Str(SVotesRespond *pVotesRespond); -// for debug ------------------- -void votesRespondPrint(SVotesRespond *pObj); -void votesRespondPrint2(char *s, SVotesRespond *pObj); -void votesRespondLog(SVotesRespond *pObj); -void votesRespondLog2(char *s, SVotesRespond *pObj); - #ifdef __cplusplus } #endif diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 32a9a84547..85e4572877 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -13,11 +13,13 @@ * along with this program. If not, see . */ +#define _DEFAULT_SOURCE #include "syncElection.h" #include "syncMessage.h" #include "syncRaftCfg.h" #include "syncRaftStore.h" #include "syncVoteMgr.h" +#include "syncUtil.h" // TLA+ Spec // RequestVote(i, j) == diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index f24cbc410b..3a17e021aa 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -349,7 +349,7 @@ _DEL_WAL: sNTrace(pSyncNode, "wal snapshot begin, index:%" PRId64 ", last apply index:%" PRId64, pSyncNode->snapshottingIndex, lastApplyIndex); } else { - sNTrace(pSyncNode, "wal snapshot begin error since:%s, index:%" PRId64 ", last apply index:%" PRId64, + sNError(pSyncNode, "wal snapshot begin error since:%s, index:%" PRId64 ", last apply index:%" PRId64, terrstr(terrno), pSyncNode->snapshottingIndex, lastApplyIndex); atomic_store_64(&pSyncNode->snapshottingIndex, SYNC_INDEX_INVALID); } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index fb366960f9..6ec5c20d04 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -15,8 +15,6 @@ #define _DEFAULT_SOURCE #include "syncUtil.h" -#include "syncEnv.h" -#include "syncInt.h" #include "syncRaftCfg.h" #include "syncRaftStore.h" #include "syncSnapshot.h" @@ -26,7 +24,7 @@ extern void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint32_t hostU32 = taosGetIpv4FromFqdn(host); if (hostU32 == (uint32_t)-1) { - sError("failed to resolve ipv4 addr. host:%s", host); + sError("failed to resolve ipv4 addr, host:%s", host); terrno = TSDB_CODE_TSC_INVALID_FQDN; return -1; } @@ -62,7 +60,7 @@ void syncUtilraftId2EpSet(const SRaftId* raftId, SEpSet* pEpSet) { bool syncUtilnodeInfo2raftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) { uint32_t ipv4 = taosGetIpv4FromFqdn(pInfo->nodeFqdn); if (ipv4 == 0xFFFFFFFF || ipv4 == 1) { - sError("failed to resolve ipv4 addr. fqdn: %s", pInfo->nodeFqdn); + sError("failed to resolve ipv4 addr, fqdn: %s", pInfo->nodeFqdn); terrno = TSDB_CODE_TSC_INVALID_FQDN; return false; } diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index a684b0ad64..5aeea23b55 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -13,10 +13,10 @@ * along with this program. If not, see . */ +#define _DEFAULT_SOURCE #include "syncVoteMgr.h" #include "syncUtil.h" -// SVotesGranted ----------------------------- static void voteGrantedClearVotes(SVotesGranted *pVotesGranted) { memset(pVotesGranted->isGranted, 0, sizeof(pVotesGranted->isGranted)); pVotesGranted->votes = 0; @@ -140,34 +140,6 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { return serialized; } -// for debug ------------------- -void voteGrantedPrint(SVotesGranted *pObj) { - char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%d | %s \n", (int32_t)strlen(serialized), serialized); - fflush(NULL); - taosMemoryFree(serialized); -} - -void voteGrantedPrint2(char *s, SVotesGranted *pObj) { - char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%d | %s | %s \n", (int32_t)strlen(serialized), s, serialized); - fflush(NULL); - taosMemoryFree(serialized); -} - -void voteGrantedLog(SVotesGranted *pObj) { - char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%d | %s", (int32_t)strlen(serialized), serialized); - taosMemoryFree(serialized); -} - -void voteGrantedLog2(char *s, SVotesGranted *pObj) { - char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%d | %s | %s", (int32_t)strlen(serialized), s, serialized); - taosMemoryFree(serialized); -} - -// SVotesRespond ----------------------------- SVotesRespond *votesRespondCreate(SSyncNode *pSyncNode) { SVotesRespond *pVotesRespond = taosMemoryMalloc(sizeof(SVotesRespond)); ASSERT(pVotesRespond != NULL); @@ -272,30 +244,3 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON_Delete(pJson); return serialized; } - -// for debug ------------------- -void votesRespondPrint(SVotesRespond *pObj) { - char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%d | %s \n", (int32_t)strlen(serialized), serialized); - fflush(NULL); - taosMemoryFree(serialized); -} - -void votesRespondPrint2(char *s, SVotesRespond *pObj) { - char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%d | %s | %s \n", (int32_t)strlen(serialized), s, serialized); - fflush(NULL); - taosMemoryFree(serialized); -} - -void votesRespondLog(SVotesRespond *pObj) { - char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%d | %s", (int32_t)strlen(serialized), serialized); - taosMemoryFree(serialized); -} - -void votesRespondLog2(char *s, SVotesRespond *pObj) { - char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%d | %s | %s", (int32_t)strlen(serialized), s, serialized); - taosMemoryFree(serialized); -} -- GitLab