diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 3a0e6edeee3447b865b1d736d23ddb6d4aafbbb9..da6d869611661bf0684fc1e2095651e587501768 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2160,7 +2160,7 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) { int32_t ret = 0; ASSERT(ths->state == TAOS_SYNC_STATE_LEADER); - SyncIndex index = ths->pLogStore->getLastIndex(ths->pLogStore) + 1; + SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); SyncTerm term = ths->pRaftStore->currentTerm; SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index, ths->vgId); ASSERT(pEntry != NULL); @@ -2188,7 +2188,7 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) { static int32_t syncNodeAppendNoop(SSyncNode* ths) { int32_t ret = 0; - SyncIndex index = ths->pLogStore->getLastIndex(ths->pLogStore) + 1; + SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); SyncTerm term = ths->pRaftStore->currentTerm; SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index, ths->vgId); ASSERT(pEntry != NULL); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 9a4d47ee85b4726ea67fd6ec07c490128913ed71..0f6e8a28d983a2064d756ab49f82f58461139ea7 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -143,7 +143,10 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr SWal* pWal = pData->pWal; SyncIndex writeIndex = raftLogWriteIndex(pLogStore); - ASSERT(pEntry->index == writeIndex); + if (pEntry->index != writeIndex) { + sError("raftLogAppendEntry error, pEntry->index:%ld update to writeIndex:%ld", pEntry->index, writeIndex); + pEntry->index = writeIndex; + } int code = 0; SSyncLogMeta syncMeta;