enh: send the END snap msg at last
This commit is contained in:
parent
f444cd7a6d
commit
1c60e67a83
|
@ -247,6 +247,7 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) {
|
||||||
pSender->blockLen = 0;
|
pSender->blockLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) {
|
||||||
pSender->seq++;
|
pSender->seq++;
|
||||||
|
|
||||||
// read data
|
// read data
|
||||||
|
@ -266,6 +267,8 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) {
|
||||||
pSender->seq = SYNC_SNAPSHOT_SEQ_END;
|
pSender->seq = SYNC_SNAPSHOT_SEQ_END;
|
||||||
sSInfo(pSender, "vgId:%d, snapshot sender read to the end, blockLen:%d seq:%d", pSender->pSyncNode->vgId,
|
sSInfo(pSender, "vgId:%d, snapshot sender read to the end, blockLen:%d seq:%d", pSender->pSyncNode->vgId,
|
||||||
pSender->blockLen, pSender->seq);
|
pSender->blockLen, pSender->seq);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// build msg
|
// build msg
|
||||||
|
@ -1188,19 +1191,28 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int64_t ack = pSndBuf->start; ack < pSndBuf->cursor; ++ack) {
|
for (int64_t ack = pSndBuf->start; ack <= pSndBuf->cursor; ++ack) {
|
||||||
rpcFreeCont(pSndBuf->entries[ack % pSndBuf->size]);
|
rpcFreeCont(pSndBuf->entries[ack % pSndBuf->size]);
|
||||||
pSndBuf->entries[ack % pSndBuf->size] = NULL;
|
pSndBuf->entries[ack % pSndBuf->size] = NULL;
|
||||||
pSndBuf->start = ack + 1;
|
pSndBuf->start = ack + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) {
|
while (pSender->seq != SYNC_SNAPSHOT_SEQ_END && pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) {
|
||||||
|
if (snapshotSend(pSender) != 0) {
|
||||||
|
code = terrno;
|
||||||
|
goto _out;
|
||||||
|
}
|
||||||
|
if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) {
|
||||||
|
pSndBuf->end = TMAX(pSender->seq + 1, pSndBuf->end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSender->seq == SYNC_SNAPSHOT_SEQ_END && pSndBuf->end <= pSndBuf->start) {
|
||||||
if (snapshotSend(pSender) != 0) {
|
if (snapshotSend(pSender) != 0) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_out:
|
_out:
|
||||||
taosThreadMutexUnlock(&pSndBuf->mutex);
|
taosThreadMutexUnlock(&pSndBuf->mutex);
|
||||||
return code;
|
return code;
|
||||||
|
|
Loading…
Reference in New Issue