diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index dfe4fa69304..a86c7cdd22e 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -305,11 +305,6 @@ bool MetaClient::loadData() { } localDataLastUpdateTime_.store(metadLastUpdateTime_.load()); - - diff(oldCache, localCache_); - listenerDiff(oldCache, localCache_); - loadRemoteListeners(); - auto newMetaData = new MetaData(); folly::RWSpinLock::ReadHolder holder(localCacheLock_); @@ -340,6 +335,9 @@ bool MetaClient::loadData() { auto oldMetaData = metadata_.load(); metadata_.store(newMetaData); folly::rcu_retire(oldMetaData); + diff(oldCache, localCache_); + listenerDiff(oldCache, localCache_); + loadRemoteListeners(); ready_ = true; return true; } diff --git a/src/storage/test/ChainTestUtils.h b/src/storage/test/ChainTestUtils.h index 13da0bf8473..57a53e7ee05 100644 --- a/src/storage/test/ChainTestUtils.h +++ b/src/storage/test/ChainTestUtils.h @@ -193,14 +193,14 @@ class MetaClientTestUpdater { static void addLocalCache(meta::MetaClient& mClient, GraphSpaceID spaceId, std::shared_ptr spInfoCache) { - mClient.localCache_[spaceId] = spInfoCache; + mClient.metadata_.load()->localCache_[spaceId] = spInfoCache; } static meta::SpaceInfoCache* getLocalCache(meta::MetaClient* mClient, GraphSpaceID spaceId) { - if (mClient->localCache_.count(spaceId) == 0) { + if (mClient->metadata_.load()->localCache_.count(spaceId) == 0) { return nullptr; } - return mClient->localCache_[spaceId].get(); + return mClient->metadata_.load()->localCache_[spaceId].get(); } static void addPartTerm(meta::MetaClient* mClient,