diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index e15783d92b49d9f903486e91d9695701a30f7085..a5e2726bbfc0d7b8dbd77d1dcea8628be5a1b7db 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -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, diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 3d79c6c46477f17f59e35a259fcea21329bcda3d..dc9bc6cbdc3b2c25316894aff0a35354e49045fc 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -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