fix: return error on failing to truncate raft log
This commit is contained in:
parent
0c4ade9373
commit
2890a8cb96
|
@ -316,29 +316,6 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn
|
||||||
SSyncLogStoreData* pData = pLogStore->data;
|
SSyncLogStoreData* pData = pLogStore->data;
|
||||||
SWal* pWal = pData->pWal;
|
SWal* pWal = pData->pWal;
|
||||||
|
|
||||||
// need not truncate
|
|
||||||
SyncIndex wallastVer = walGetLastVer(pWal);
|
|
||||||
if (fromIndex > wallastVer) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// need not truncate
|
|
||||||
SyncIndex walCommitVer = walGetCommittedVer(pWal);
|
|
||||||
if (fromIndex <= walCommitVer) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete from cache
|
|
||||||
for (SyncIndex index = fromIndex; index <= wallastVer; ++index) {
|
|
||||||
SLRUCache* pCache = pData->pSyncNode->pLogStore->pCache;
|
|
||||||
LRUHandle* h = taosLRUCacheLookup(pCache, &index, sizeof(index));
|
|
||||||
if (h) {
|
|
||||||
sNTrace(pData->pSyncNode, "cache delete index:%" PRId64, index);
|
|
||||||
|
|
||||||
taosLRUCacheRelease(pData->pSyncNode->pLogStore->pCache, h, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = walRollback(pWal, fromIndex);
|
int32_t code = walRollback(pWal, fromIndex);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
int32_t err = terrno;
|
int32_t err = terrno;
|
||||||
|
|
|
@ -105,7 +105,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||||
wInfo("vgId:%d, wal rollback for version %" PRId64, pWal->cfg.vgId, ver);
|
wInfo("vgId:%d, wal rollback for version %" PRId64, pWal->cfg.vgId, ver);
|
||||||
int64_t code;
|
int64_t code;
|
||||||
char fnameStr[WAL_FILE_LEN];
|
char fnameStr[WAL_FILE_LEN];
|
||||||
if (ver > pWal->vers.lastVer || ver < pWal->vers.commitVer || ver <= pWal->vers.snapshotVer) {
|
if (ver > pWal->vers.lastVer || ver <= pWal->vers.commitVer || ver <= pWal->vers.snapshotVer) {
|
||||||
terrno = TSDB_CODE_WAL_INVALID_VER;
|
terrno = TSDB_CODE_WAL_INVALID_VER;
|
||||||
taosThreadMutexUnlock(&pWal->mutex);
|
taosThreadMutexUnlock(&pWal->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue