Skip to content

Commit

Permalink
1. format
Browse files Browse the repository at this point in the history
2. change mod to bitand
  • Loading branch information
cangfengzhs committed Aug 24, 2021
1 parent 97a43e8 commit a0e5146
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<n times");
namespace nebula {
namespace meta {

Expand Down Expand Up @@ -3478,6 +3478,7 @@ folly::Future<StatusOr<bool>> MetaClient::ingest(GraphSpaceID spaceId) {
};
return folly::async(func);
}

bool MetaClient::loadSessions() {
auto session_list = listSessions().get();
if (!session_list.ok()) {
Expand All @@ -3503,6 +3504,7 @@ bool MetaClient::loadSessions() {
folly::rcu_retire(old_session_map);
return true;
}

StatusOr<cpp2::Session> MetaClient::getSessionFromCache(const nebula::SessionID& session_id) {
if (!ready_) {
return Status::Error("Not ready!");
Expand All @@ -3515,15 +3517,17 @@ StatusOr<cpp2::Session> 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
2 changes: 1 addition & 1 deletion src/storage/test/KillQueryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a0e5146

Please sign in to comment.