From c7691590be6580bc21dd5bcf5216377883bea6d4 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 23 May 2022 23:53:15 +0800 Subject: [PATCH] enh(sync) add syncIsRestoreFinish --- include/libs/sync/sync.h | 1 + source/libs/sync/src/syncMain.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 1eed353f33..2bf678fa48 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -146,6 +146,7 @@ int32_t syncGetVgId(int64_t rid); int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak); bool syncEnvIsStart(); const char* syncStr(ESyncState state); +bool syncIsRestoreFinish(int64_t rid); #ifdef __cplusplus } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 821ed364e8..b5315e33c8 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -157,6 +157,18 @@ ESyncState syncGetMyRole(int64_t rid) { return state; } +bool syncIsRestoreFinish(int64_t rid) { + SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + if (pSyncNode == NULL) { + return false; + } + assert(rid == pSyncNode->rid); + bool b = pSyncNode->restoreFinish; + + taosReleaseRef(tsNodeRefId, pSyncNode->rid); + return b; +} + const char* syncGetMyRoleStr(int64_t rid) { const char* s = syncUtilState2String(syncGetMyRole(rid)); return s; -- GitLab