acelyc111 commented on code in PR #2093:
URL:
https://github.com/apache/incubator-pegasus/pull/2093#discussion_r1711186377
##########
src/meta/duplication/meta_duplication_service.cpp:
##########
@@ -535,79 +599,78 @@ void
meta_duplication_service::check_follower_app_if_create_completed(
dsn::message_ex *msg =
dsn::message_ex::create_request(RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX);
dsn::marshall(msg, meta_config_request);
- rpc::call(dsn::dns_resolver::instance().resolve_address(meta_servers),
- msg,
- _meta_svc->tracker(),
- [=](error_code err, query_cfg_response &&resp) mutable {
- FAIL_POINT_INJECT_NOT_RETURN_F("create_app_ok",
[&](std::string_view s) -> void {
- err = ERR_OK;
- int count = dup->partition_count;
- while (count-- > 0) {
- const host_port primary("localhost", 34801);
- const host_port secondary1("localhost", 34802);
- const host_port secondary2("localhost", 34803);
-
- partition_configuration pc;
- SET_IP_AND_HOST_PORT_BY_DNS(pc, primary, primary);
- SET_IPS_AND_HOST_PORTS_BY_DNS(pc, secondaries,
secondary1, secondary2);
- resp.partitions.emplace_back(pc);
- }
- });
-
- // - ERR_INCONSISTENT_STATE: partition count of response
isn't equal with local
- // - ERR_INACTIVE_STATE: the follower table hasn't been
healthy
- error_code query_err = err == ERR_OK ? resp.err : err;
- if (query_err == ERR_OK) {
- if (resp.partitions.size() != dup->partition_count) {
- query_err = ERR_INCONSISTENT_STATE;
- } else {
- for (const auto &pc : resp.partitions) {
- if (!pc.hp_primary) {
- query_err = ERR_INACTIVE_STATE;
- break;
- }
-
- if (pc.hp_secondaries.empty()) {
- query_err = ERR_NOT_ENOUGH_MEMBER;
- break;
- }
-
- for (const auto &secondary : pc.hp_secondaries) {
- if (!secondary) {
- query_err = ERR_INACTIVE_STATE;
- break;
- }
- }
- }
- }
- }
-
- error_code update_err = ERR_NO_NEED_OPERATE;
- if (query_err == ERR_OK) {
- update_err =
dup->alter_status(duplication_status::DS_LOG);
- }
-
- FAIL_POINT_INJECT_F("persist_dup_status_failed",
- [&](std::string_view s) -> void {
return; });
- if (update_err == ERR_OK) {
- blob value = dup->to_json_blob();
- // Note: this function is `async`, it may not be
persisted completed
- // after executing, now using `_is_altering` to judge
whether `updating` or
- // `completed`, if `_is_altering`, dup->alter_status()
will return `ERR_BUSY`
-
_meta_svc->get_meta_storage()->set_data(std::string(dup->store_path),
- std::move(value),
- [dup]() {
dup->persist_status(); });
- } else {
- LOG_ERROR(
- "query follower app[{}.{}] replica configuration
completed, result: "
+ rpc::call(
+ dsn::dns_resolver::instance().resolve_address(meta_servers),
+ msg,
+ _meta_svc->tracker(),
+ [dup, this](error_code err, query_cfg_response &&resp) mutable {
+ FAIL_POINT_INJECT_NOT_RETURN_F(
+ "create_app_ok",
+ std::bind(
+ mock_create_app, std::placeholders::_1, dup,
std::ref(resp), std::ref(err)));
+
+ // - ERR_INCONSISTENT_STATE: partition count of response isn't
equal with local
+ // - ERR_INACTIVE_STATE: the follower table hasn't been healthy
+ error_code query_err = err == ERR_OK ? resp.err : err;
+ if (query_err == ERR_OK) {
+ if (resp.partitions.size() != dup->partition_count) {
+ query_err = ERR_INCONSISTENT_STATE;
Review Comment:
How about `continue` here to reduce the depth of the following code?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]