From 9f3b2e3d97b2cfb96f345359f4092b478cc54282 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Wed, 26 Jun 2024 09:57:24 +0800 Subject: [PATCH] fix --- src/meta/meta_split_service.cpp | 2 +- src/meta/server_state.cpp | 9 ++++----- src/meta/test/json_compacity.cpp | 13 ++++--------- src/meta/test/meta_partition_guardian_test.cpp | 1 + src/replica/split/replica_split_manager.cpp | 2 +- src/replica/storage/simple_kv/test/checker.cpp | 1 - .../detect_hotspot/test_detect_hotspot.cpp | 1 + 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/meta/meta_split_service.cpp b/src/meta/meta_split_service.cpp index e934379264..df0c642a2d 100644 --- a/src/meta/meta_split_service.cpp +++ b/src/meta/meta_split_service.cpp @@ -308,7 +308,7 @@ void meta_split_service::on_add_child_on_remote_storage_reply(error_code ec, SET_OBJ_IP_AND_HOST_PORT(*update_child_request, node, request, primary); // TODO(yingchun): should use conference? - auto &child_pc = app->pcs[child_gpid.get_partition_index()]; + auto child_pc = app->pcs[child_gpid.get_partition_index()]; child_pc.secondaries = request.child_config.secondaries; child_pc.__set_hp_secondaries(request.child_config.hp_secondaries); _state->update_configuration_locally(*app, update_child_request); diff --git a/src/meta/server_state.cpp b/src/meta/server_state.cpp index 1195caba3d..2c5019cb9a 100644 --- a/src/meta/server_state.cpp +++ b/src/meta/server_state.cpp @@ -2566,8 +2566,8 @@ bool server_state::check_all_partitions() continue; } for (unsigned int i = 0; i != app->partition_count; ++i) { - partition_configuration &pc = app->pcs[i]; - config_context &cc = app->helpers->contexts[i]; + const auto &pc = app->pcs[i]; + const auto &cc = app->helpers->contexts[i]; // partition is under re-configuration or is child partition if (cc.stage != config_status::pending_remote_sync && pc.ballot != invalid_ballot) { configuration_proposal_action action; @@ -3259,8 +3259,7 @@ template bool server_state::check_max_replica_count_consistent(const std::shared_ptr &app, Response &response) const { - for (int i = 0; i < static_cast(app->pcs.size()); ++i) { - const auto &pc = app->pcs[i]; + for (const auto &pc : app->pcs) { if (pc.max_replica_count == app->max_replica_count) { continue; } @@ -3270,7 +3269,7 @@ bool server_state::check_max_replica_count_consistent(const std::shared_ptrmax_replica_count, - i); + pc.pid); return false; } diff --git a/src/meta/test/json_compacity.cpp b/src/meta/test/json_compacity.cpp index e5528fb8a1..de01ec52a5 100644 --- a/src/meta/test/json_compacity.cpp +++ b/src/meta/test/json_compacity.cpp @@ -86,20 +86,15 @@ void meta_service_test_app::json_compacity() // 4. old pc version const char *json3 = "{\"pid\":\"1.1\",\"ballot\":234,\"max_replica_count\":3," - "\"primary\":\"127.0.0.1:1\",\"secondaries\":[\"127.0.0.1:6\"]," - "\"hp_primary\":\"localhost:1\",\"hp_secondaries\":[\"localhost:6\"]," + "\"primary\":\"invalid address\",\"secondaries\":[\"127.0.0.1:6\"]," + "\"hp_primary\":\"invalid host_port\",\"hp_secondaries\":[\"localhost:6\"]," "\"last_drops\":[],\"last_committed_decree\":157}"; dsn::partition_configuration pc; dsn::json::json_forwarder::decode( dsn::blob(json3, 0, strlen(json3)), pc); ASSERT_EQ(234, pc.ballot); - // As how we do in src/meta/server_state.cpp, we have to set the '__isset' fields manually. - ASSERT_FALSE(pc.__isset.hp_primary); - ASSERT_TRUE(pc.hp_primary); - ASSERT_TRUE(pc.primary); - ASSERT_STREQ("127.0.0.1:1", pc.primary.to_string()); - ASSERT_EQ("localhost:1", pc.hp_primary.to_string()); - ASSERT_FALSE(pc.__isset.hp_secondaries); + ASSERT_TRUE(!pc.hp_primary); + ASSERT_TRUE(!pc.primary); ASSERT_EQ(1, pc.hp_secondaries.size()); ASSERT_EQ(1, pc.secondaries.size()); ASSERT_STREQ("127.0.0.1:6", pc.secondaries[0].to_string()); diff --git a/src/meta/test/meta_partition_guardian_test.cpp b/src/meta/test/meta_partition_guardian_test.cpp index 6ccb7cb9c9..927d26ea09 100644 --- a/src/meta/test/meta_partition_guardian_test.cpp +++ b/src/meta/test/meta_partition_guardian_test.cpp @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +// IWYU pragma: no_include #include #include #include diff --git a/src/replica/split/replica_split_manager.cpp b/src/replica/split/replica_split_manager.cpp index 4020dd444a..e59096e4d4 100644 --- a/src/replica/split/replica_split_manager.cpp +++ b/src/replica/split/replica_split_manager.cpp @@ -987,7 +987,7 @@ void replica_split_manager::register_child_on_meta(ballot b) // on primary paren return; } - partition_configuration child_pc = _replica->_primary_states.pc; + auto child_pc = _replica->_primary_states.pc; child_pc.ballot++; child_pc.last_committed_decree = 0; CLEAR_IP_AND_HOST_PORT(child_pc, last_drops); diff --git a/src/replica/storage/simple_kv/test/checker.cpp b/src/replica/storage/simple_kv/test/checker.cpp index 448dc121c9..de6e52c552 100644 --- a/src/replica/storage/simple_kv/test/checker.cpp +++ b/src/replica/storage/simple_kv/test/checker.cpp @@ -332,7 +332,6 @@ bool test_checker::get_current_config(parti_config &config) // the rDSN's //"enqueue,dequeue and lock..." - // meta->_service->_state->query_configuration_by_gpid(g_default_gpid, pc); const meta_view view = meta->_service->_state->get_meta_view(); config.convert_from(*get_config(*(view.apps), g_default_gpid)); return true; diff --git a/src/test/function_test/detect_hotspot/test_detect_hotspot.cpp b/src/test/function_test/detect_hotspot/test_detect_hotspot.cpp index 712915fd76..3c549d4cf6 100644 --- a/src/test/function_test/detect_hotspot/test_detect_hotspot.cpp +++ b/src/test/function_test/detect_hotspot/test_detect_hotspot.cpp @@ -26,6 +26,7 @@ #include "client/replication_ddl_client.h" #include "common/gpid.h" +#include "dsn.layer2_types.h" #include "gtest/gtest.h" #include "include/pegasus/client.h" #include "include/pegasus/error.h"