enh: check snap begin index against commit index on leader

This commit is contained in:
Benguang Zhao 2024-05-06 16:57:22 +08:00
parent d28fa202d7
commit b0f7355d11
1 changed files with 8 additions and 0 deletions

View File

@ -1100,6 +1100,14 @@ static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSend
int32_t code = -1; int32_t code = -1;
SSnapshot snapshot = {0}; SSnapshot snapshot = {0};
if (pMsg->snapBeginIndex > pSyncNode->commitIndex) {
sSError(pSender,
"snapshot begin index is greater than commit index. snapBeginIndex:%" PRId64 ", commitIndex:%" PRId64,
pMsg->snapBeginIndex, pSyncNode->commitIndex);
terrno = TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG;
return -1;
}
taosThreadMutexLock(&pSender->pSndBuf->mutex); taosThreadMutexLock(&pSender->pSndBuf->mutex);
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);