fix: do not process query and fetch msg until vnode restore finished

This commit is contained in:
Shengliang Guan 2022-09-29 14:24:45 +08:00
parent f14d00a5d6
commit 4df3303514
2 changed files with 7 additions and 12 deletions

View File

@ -797,18 +797,10 @@ bool vnodeIsLeader(SVnode *pVnode) {
}
bool vnodeIsReadyForRead(SVnode *pVnode) {
if (!pVnode->restored) {
vDebug("vgId:%d, vnode restore not finished", pVnode->config.vgId);
terrno = TSDB_CODE_APP_NOT_READY;
return false;
}
if (syncIsReady(pVnode->sync)) {
return true;
}
if (syncIsReadyForRead(pVnode->sync)) {
return true;
if (pVnode->restored) {
return true;
}
}
vDebug("vgId:%d, vnode not ready for read, state:%s, last:%ld, cmt:%ld", pVnode->config.vgId,

View File

@ -405,7 +405,10 @@ bool syncIsReadyForRead(int64_t rid) {
// TODO: last not noop?
SyncIndex lastIndex = syncNodeGetLastIndex(pSyncNode);
bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && (pSyncNode->commitIndex >= lastIndex - SYNC_MAX_READ_RANGE);
bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && pSyncNode->restoreFinish;
if (!b) {
b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && (pSyncNode->commitIndex >= lastIndex - SYNC_MAX_READ_RANGE);
}
taosReleaseRef(tsNodeRefId, pSyncNode->rid);
// if false, set error code