From 128fde08f1f26dca8c1cf40a4b6b3bef2fc94cc1 Mon Sep 17 00:00:00 2001 From: laiyingchun Date: Thu, 28 Nov 2024 00:18:59 +0800 Subject: [PATCH 1/3] fix: fix some build errors on the latest MacOS --- src/meta/meta_state_service_simple.cpp | 4 ++-- src/meta/meta_state_service_simple.h | 2 +- src/meta/test/balancer_validator.cpp | 4 ++-- src/replica/prepare_list.cpp | 2 -- src/test/bench_test/benchmark.cpp | 2 -- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/meta/meta_state_service_simple.cpp b/src/meta/meta_state_service_simple.cpp index f875699d53..2655d02721 100644 --- a/src/meta/meta_state_service_simple.cpp +++ b/src/meta/meta_state_service_simple.cpp @@ -94,7 +94,7 @@ void meta_state_service_simple::write_log(blob &&log_blob, __err_cb_bind_and_enqueue(task, internal_operation(), 0); })); auto continuation_task_ptr = continuation_task.get(); - _task_queue.emplace(move(continuation_task)); + _task_queue.emplace(std::move(continuation_task)); _log_lock.unlock(); file::write(_log, @@ -525,7 +525,7 @@ task_ptr meta_state_service_simple::get_children(const std::string &node, result.push_back(child_pair.first); } return tasking::enqueue( - cb_code, tracker, [=]() mutable { cb_get_children(ERR_OK, move(result)); }); + cb_code, tracker, [=]() mutable { cb_get_children(ERR_OK, std::move(result)); }); } } diff --git a/src/meta/meta_state_service_simple.h b/src/meta/meta_state_service_simple.h index c4e9298ed5..9a5a6b395e 100644 --- a/src/meta/meta_state_service_simple.h +++ b/src/meta/meta_state_service_simple.h @@ -123,7 +123,7 @@ class meta_state_service_simple : public meta_state_service { bool done; std::function cb; - operation(bool done, std::function &&cb) : done(done), cb(move(cb)) {} + operation(bool done, std::function &&cb) : done(done), cb(std::move(cb)) {} }; #pragma pack(push, 1) diff --git a/src/meta/test/balancer_validator.cpp b/src/meta/test/balancer_validator.cpp index 2543b28935..a0a5dbb15b 100644 --- a/src/meta/test/balancer_validator.cpp +++ b/src/meta/test/balancer_validator.cpp @@ -118,8 +118,8 @@ static void check_cure(app_mapper &apps, node_mapper &nodes, ::dsn::partition_co CHECK(node != nodes.end(), ""); ns = &node->second; SET_OBJ_IP_AND_HOST_PORT(pc, primary, act, node); - std::remove(pc.secondaries.begin(), pc.secondaries.end(), pc.primary); - std::remove(pc.hp_secondaries.begin(), pc.hp_secondaries.end(), pc.hp_primary); + (void)std::remove(pc.secondaries.begin(), pc.secondaries.end(), pc.primary); + (void)std::remove(pc.hp_secondaries.begin(), pc.hp_secondaries.end(), pc.hp_primary); CHECK_EQ(ns->served_as(pc.pid), partition_status::PS_SECONDARY); ns->put_partition(pc.pid, true); } diff --git a/src/replica/prepare_list.cpp b/src/replica/prepare_list.cpp index d2fdff2334..e7b1e8b21b 100644 --- a/src/replica/prepare_list.cpp +++ b/src/replica/prepare_list.cpp @@ -186,14 +186,12 @@ void prepare_list::commit(decree d, commit_type ct) if (d != last_committed_decree() + 1) return; - int count = 0; mutation_ptr mu = get_mutation_by_decree(last_committed_decree() + 1); while (mu != nullptr && mu->is_ready_for_commit() && mu->data.header.ballot >= last_bt) { _last_committed_decree++; last_bt = mu->data.header.ballot; _committer(mu); - count++; mu = mutation_cache::get_mutation_by_decree(_last_committed_decree + 1); } diff --git a/src/test/bench_test/benchmark.cpp b/src/test/bench_test/benchmark.cpp index 321c56f86a..23ff78bd24 100644 --- a/src/test/bench_test/benchmark.cpp +++ b/src/test/bench_test/benchmark.cpp @@ -172,7 +172,6 @@ void benchmark::write_random(thread_arg *thread) { // do write operation num times uint64_t bytes = 0; - int count = 0; for (int i = 0; i < FLAGS_benchmark_num; i++) { // generate hash key and sort key std::string hashkey, sortkey, value; @@ -185,7 +184,6 @@ void benchmark::write_random(thread_arg *thread) int ret = _client->set(hashkey, sortkey, value, FLAGS_pegasus_timeout_ms); if (ret == ::pegasus::PERR_OK) { bytes += FLAGS_value_size + FLAGS_hashkey_size + FLAGS_sortkey_size; - count++; break; } else if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) { fmt::print(stderr, "Set returned an error: {}\n", _client->get_error_string(ret)); From 90ece7d162d5d5a734d215c432bebf87392677ed Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Fri, 29 Nov 2024 09:34:24 +0800 Subject: [PATCH 2/3] tidy --- src/meta/meta_state_service_simple.cpp | 4 ++-- src/replica/prepare_list.cpp | 3 ++- src/test/bench_test/benchmark.cpp | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/meta/meta_state_service_simple.cpp b/src/meta/meta_state_service_simple.cpp index 2655d02721..010e2ee807 100644 --- a/src/meta/meta_state_service_simple.cpp +++ b/src/meta/meta_state_service_simple.cpp @@ -93,7 +93,7 @@ void meta_state_service_simple::write_log(blob &&log_blob, CHECK(log_succeed, "we cannot handle logging failure now"); __err_cb_bind_and_enqueue(task, internal_operation(), 0); })); - auto continuation_task_ptr = continuation_task.get(); + auto* continuation_task_ptr = continuation_task.get(); _task_queue.emplace(std::move(continuation_task)); _log_lock.unlock(); @@ -525,7 +525,7 @@ task_ptr meta_state_service_simple::get_children(const std::string &node, result.push_back(child_pair.first); } return tasking::enqueue( - cb_code, tracker, [=]() mutable { cb_get_children(ERR_OK, std::move(result)); }); + cb_code, tracker, [=]() mutable { cb_get_children(ERR_OK, result); }); } } diff --git a/src/replica/prepare_list.cpp b/src/replica/prepare_list.cpp index e7b1e8b21b..2663c8932a 100644 --- a/src/replica/prepare_list.cpp +++ b/src/replica/prepare_list.cpp @@ -183,8 +183,9 @@ void prepare_list::commit(decree d, commit_type ct) return; } case COMMIT_ALL_READY: { - if (d != last_committed_decree() + 1) + if (d != last_committed_decree() + 1) { return; + } mutation_ptr mu = get_mutation_by_decree(last_committed_decree() + 1); diff --git a/src/test/bench_test/benchmark.cpp b/src/test/bench_test/benchmark.cpp index 23ff78bd24..bd705ddb4b 100644 --- a/src/test/bench_test/benchmark.cpp +++ b/src/test/bench_test/benchmark.cpp @@ -174,7 +174,9 @@ void benchmark::write_random(thread_arg *thread) uint64_t bytes = 0; for (int i = 0; i < FLAGS_benchmark_num; i++) { // generate hash key and sort key - std::string hashkey, sortkey, value; + std::string hashkey; + std::string sortkey; + std::string value; generate_kv_pair(hashkey, sortkey, value); // write to pegasus @@ -185,7 +187,8 @@ void benchmark::write_random(thread_arg *thread) if (ret == ::pegasus::PERR_OK) { bytes += FLAGS_value_size + FLAGS_hashkey_size + FLAGS_sortkey_size; break; - } else if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) { + } + if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) { fmt::print(stderr, "Set returned an error: {}\n", _client->get_error_string(ret)); dsn_exit(1); } else { From ece0c52e7b1a329c0813de088b57b5b3dc39f123 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Fri, 29 Nov 2024 09:36:29 +0800 Subject: [PATCH 3/3] fmt --- src/meta/meta_state_service_simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meta/meta_state_service_simple.cpp b/src/meta/meta_state_service_simple.cpp index 010e2ee807..3ce5453e2d 100644 --- a/src/meta/meta_state_service_simple.cpp +++ b/src/meta/meta_state_service_simple.cpp @@ -93,7 +93,7 @@ void meta_state_service_simple::write_log(blob &&log_blob, CHECK(log_succeed, "we cannot handle logging failure now"); __err_cb_bind_and_enqueue(task, internal_operation(), 0); })); - auto* continuation_task_ptr = continuation_task.get(); + auto *continuation_task_ptr = continuation_task.get(); _task_queue.emplace(std::move(continuation_task)); _log_lock.unlock();