From 0a7ef098baf664cb64978f9d5da23fdbb47f45d2 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 13 Dec 2023 14:01:52 +0800 Subject: [PATCH] enh: reduce wait time to start a new snap replication --- source/libs/sync/inc/syncSnapshot.h | 1 - source/libs/sync/src/syncSnapshot.c | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index f8ee99e8a0..66d8edfdfc 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -63,7 +63,6 @@ typedef struct SSyncSnapshotSender { int64_t sendingMS; SyncTerm term; int64_t startTime; - int64_t waitTime; int64_t lastSendTime; bool finish; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 353e28890b..cbdc60b2b3 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -81,7 +81,6 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->replicaIndex = replicaIndex; pSender->term = raftStoreGetTerm(pSyncNode); pSender->startTime = -1; - pSender->waitTime = -1; pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; @@ -201,7 +200,6 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { taosThreadMutexLock(&pSender->pSndBuf->mutex); { pSender->finish = finish; - pSender->waitTime = -1; // close reader if (pSender->pReader != NULL) { @@ -373,14 +371,7 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) { return 0; } - int64_t timeNow = taosGetTimestampMs(); - if (pSender->waitTime <= 0) { - pSender->waitTime = timeNow + SNAPSHOT_WAIT_MS; - } - if (timeNow < pSender->waitTime) { - sSDebug(pSender, "snapshot sender waitTime not expired yet, ignore"); - return 0; - } + taosMsleep(1); int32_t code = snapshotSenderStart(pSender); if (code != 0) {