From b0f7355d113f5f069f7993ab9c5997c34939a6bf Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Mon, 6 May 2024 16:57:22 +0800 Subject: [PATCH] enh: check snap begin index against commit index on leader --- source/libs/sync/src/syncSnapshot.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 973eb8aaa5..8dab694975 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -1100,6 +1100,14 @@ static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSend int32_t code = -1; 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); pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);