From 46dcfa551dcea7e05d0a226e709f58982499c632 Mon Sep 17 00:00:00 2001 From: "hs.zhang" <22708345+cangfengzhs@users.noreply.github.com> Date: Thu, 23 Dec 2021 19:18:01 +0800 Subject: [PATCH] fix storage exit crash --- src/clients/meta/MetaClient.cpp | 8 +++----- src/storage/test/ChainTestUtils.h | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index f7d3d236051..4003c6ea726 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -300,11 +300,6 @@ bool MetaClient::loadData() { } localDataLastUpdateTime_.store(metadLastUpdateTime_.load()); - - diff(oldCache, localCache_); - listenerDiff(oldCache, localCache_); - loadRemoteListeners(); - auto newMetaData = new MetaData(); folly::RWSpinLock::ReadHolder holder(localCacheLock_); @@ -335,6 +330,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 e59d04aa8e4..887a157ba22 100644 --- a/src/storage/test/ChainTestUtils.h +++ b/src/storage/test/ChainTestUtils.h @@ -191,14 +191,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,