From a0e5146e865fd9ba289d2ee48f7fc0e042937870 Mon Sep 17 00:00:00 2001 From: "hs.zhang" <22708345+cangfengzhs@users.noreply.github.com> Date: Tue, 24 Aug 2021 17:11:03 +0800 Subject: [PATCH] 1. format 2. change mod to bitand --- src/clients/meta/MetaClient.cpp | 8 ++++++-- src/storage/test/KillQueryTest.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index f0385d42e72..5f4f5d8469c 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -29,7 +29,7 @@ DEFINE_int32(meta_client_retry_times, 3, "meta client retry times, 0 means no re DEFINE_int32(meta_client_retry_interval_secs, 1, "meta client sleep interval between retry"); DEFINE_int32(meta_client_timeout_ms, 60 * 1000, "meta client timeout"); DEFINE_string(cluster_id_path, "cluster.id", "file path saved clusterId"); -DEFINE_int32(check_plan_killed_frequency, 10, ""); +DEFINE_int32(check_plan_killed_frequency, 8, "check plan killed every 1<> MetaClient::ingest(GraphSpaceID spaceId) { }; return folly::async(func); } + bool MetaClient::loadSessions() { auto session_list = listSessions().get(); if (!session_list.ok()) { @@ -3503,6 +3504,7 @@ bool MetaClient::loadSessions() { folly::rcu_retire(old_session_map); return true; } + StatusOr MetaClient::getSessionFromCache(const nebula::SessionID& session_id) { if (!ready_) { return Status::Error("Not ready!"); @@ -3515,15 +3517,17 @@ StatusOr MetaClient::getSessionFromCache(const nebula::SessionID& } return Status::SessionNotFound(); } + bool MetaClient::checkIsPlanKilled(SessionID sessionId, ExecutionPlanID planId) { static thread_local int check_counter = 0; // Inaccurate in a multi-threaded environment, but it is not important - check_counter = (check_counter + 1) % FLAGS_check_plan_killed_frequency; + check_counter = (check_counter + 1) & ((1 << FLAGS_check_plan_killed_frequency) - 1); if (check_counter != 0) { return false; } folly::rcu_reader guard; return killedPlans_.load()->count({sessionId, planId}); } + } // namespace meta } // namespace nebula diff --git a/src/storage/test/KillQueryTest.cpp b/src/storage/test/KillQueryTest.cpp index f3b0537b172..8bfa64ac119 100644 --- a/src/storage/test/KillQueryTest.cpp +++ b/src/storage/test/KillQueryTest.cpp @@ -32,7 +32,7 @@ namespace storage { class KillQueryTest : public ::testing::Test { protected: void SetUp() override { - FLAGS_check_plan_killed_frequency = 1; + FLAGS_check_plan_killed_frequency = 0; storagePath_ = new fs::TempDir("/tmp/KillQueryTest.storage.XXXXXX"); cluster_ = new mock::MockCluster{}; cluster_->initStorageKV(storagePath_->path());