refactor(sync): calculate index after append entry
This commit is contained in:
parent
363c98e9ed
commit
4381c3620d
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue