diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index e3358b41df07b75d3a1624bbd13f08645b1d66d7..b481f417d9bc811810b19dc1ab1c8495d46db168 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -261,7 +261,8 @@ bool mndIsMaster(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; if (!syncIsReady(pMgmt->sync)) { - terrno = TSDB_CODE_SYN_NOT_LEADER; + // get terrno from syncIsReady + // terrno = TSDB_CODE_SYN_NOT_LEADER; return false; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 42ba2b85b1ec239858119a39e4ed967b4fec2694..041afdb3371ebe73b0064687ece190485e741a30 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -370,6 +370,15 @@ bool syncIsReady(int64_t rid) { ASSERT(rid == pSyncNode->rid); bool b = (pSyncNode->state == TAOS_SYNC_STATE_LEADER) && pSyncNode->restoreFinish; taosReleaseRef(tsNodeRefId, pSyncNode->rid); + + // if false, set error code + if (false == b) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + } else { + terrno = TSDB_CODE_APP_NOT_READY; + } + } return b; }