void replica::on_meta_server_disconnected() { ddebug( "%s: meta server disconnected", name()); auto old_status = status(); update_local_configuration_with_no_ballot_change(PS_INACTIVE); // make sure they can be back directly if (old_status == PS_PRIMARY || old_status == PS_SECONDARY) { set_inactive_state_transient(true); } }
void replica::update_configuration_on_meta_server(config_type type, ::dsn::rpc_address node, partition_configuration& newConfig) { newConfig.last_committed_decree = last_committed_decree(); if (type != CT_ASSIGN_PRIMARY && type != CT_UPGRADE_TO_PRIMARY) { dassert (status() == PS_PRIMARY, ""); dassert (newConfig.ballot == _primary_states.membership.ballot, ""); } // disable 2pc during reconfiguration // it is possible to do this only for CT_DOWNGRADE_TO_SECONDARY, // but we choose to disable 2pc during all reconfiguration types // for simplicity at the cost of certain write throughput update_local_configuration_with_no_ballot_change(PS_INACTIVE); set_inactive_state_transient(true); dsn_message_t msg = dsn_msg_create_request(RPC_CM_UPDATE_PARTITION_CONFIGURATION, 0, 0); std::shared_ptr<configuration_update_request> request(new configuration_update_request); request->config = newConfig; request->config.ballot++; request->type = type; request->node = node; ::marshall(msg, *request); if (nullptr != _primary_states.reconfiguration_task) { _primary_states.reconfiguration_task->cancel(true); } rpc_address target(_stub->_failure_detector->get_servers()); _primary_states.reconfiguration_task = rpc::call( target, msg, this, std::bind(&replica::on_update_configuration_on_meta_server_reply, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, request), gpid_to_hash(get_gpid()) ); }