enh: reduce wait time to start a new snap replication
This commit is contained in:
parent
6eb64fcd9b
commit
0a7ef098ba
|
@ -63,7 +63,6 @@ typedef struct SSyncSnapshotSender {
|
||||||
int64_t sendingMS;
|
int64_t sendingMS;
|
||||||
SyncTerm term;
|
SyncTerm term;
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
int64_t waitTime;
|
|
||||||
int64_t lastSendTime;
|
int64_t lastSendTime;
|
||||||
bool finish;
|
bool finish;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
|
||||||
pSender->replicaIndex = replicaIndex;
|
pSender->replicaIndex = replicaIndex;
|
||||||
pSender->term = raftStoreGetTerm(pSyncNode);
|
pSender->term = raftStoreGetTerm(pSyncNode);
|
||||||
pSender->startTime = -1;
|
pSender->startTime = -1;
|
||||||
pSender->waitTime = -1;
|
|
||||||
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot);
|
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot);
|
||||||
pSender->finish = false;
|
pSender->finish = false;
|
||||||
|
|
||||||
|
@ -201,7 +200,6 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) {
|
||||||
taosThreadMutexLock(&pSender->pSndBuf->mutex);
|
taosThreadMutexLock(&pSender->pSndBuf->mutex);
|
||||||
{
|
{
|
||||||
pSender->finish = finish;
|
pSender->finish = finish;
|
||||||
pSender->waitTime = -1;
|
|
||||||
|
|
||||||
// close reader
|
// close reader
|
||||||
if (pSender->pReader != NULL) {
|
if (pSender->pReader != NULL) {
|
||||||
|
@ -373,14 +371,7 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t timeNow = taosGetTimestampMs();
|
taosMsleep(1);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = snapshotSenderStart(pSender);
|
int32_t code = snapshotSenderStart(pSender);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
|
Loading…
Reference in New Issue