void replica::handle_remote_failure(partition_status st, const end_point& node, int error) { ddebug( "%s: handle remote failure error %u, status = %s, node = %s:%d", name(), error, enum_to_string(st), node.name.c_str(), static_cast<int>(node.port) ); dassert (status() == PS_PRIMARY, ""); dassert(node != primary_address(), ""); switch (st) { case PS_SECONDARY: dassert (_primary_states.check_exist(node, PS_SECONDARY), ""); { configuration_update_request request; request.node = node; request.type = CT_DOWNGRADE_TO_INACTIVE; request.config = _primary_states.membership; downgrade_to_inactive_on_primary(request); } break; case PS_POTENTIAL_SECONDARY: // potential secondary failure does not lead to ballot change // therefore, it is possible to have multiple exec here if (_primary_states.learners.erase(node) > 0) { if (_primary_states.check_exist(node, PS_INACTIVE)) _primary_states.statuses[node] = PS_INACTIVE; else _primary_states.statuses.erase(node); } break; case PS_INACTIVE: case PS_ERROR: break; default: dassert (false, ""); break; } }
void replica::handle_remote_failure(partition_status st, ::dsn::rpc_address node, error_code error) { derror( "%s: handle remote failure error %s, status = %s, node = %s", name(), error.to_string(), enum_to_string(st), node.to_string() ); error.end_tracking(); dassert (status() == PS_PRIMARY, ""); dassert (node != _stub->_primary_address, ""); switch (st) { case PS_SECONDARY: dassert (_primary_states.check_exist(node, PS_SECONDARY), ""); { configuration_update_request request; request.node = node; request.type = CT_DOWNGRADE_TO_INACTIVE; request.config = _primary_states.membership; downgrade_to_inactive_on_primary(request); } break; case PS_POTENTIAL_SECONDARY: // potential secondary failure does not lead to ballot change // therefore, it is possible to have multiple exec here _primary_states.learners.erase(node); _primary_states.statuses.erase(node); break; case PS_INACTIVE: case PS_ERROR: break; default: dassert (false, ""); break; } }
void replica::on_config_proposal(configuration_update_request& proposal) { check_hashed_access(); ddebug( "%s: on_config_proposal %s for %s", name(), enum_to_string(proposal.type), proposal.node.to_string() ); if (proposal.config.ballot < get_ballot()) { dwarn( "%s: on_config_proposal is out-dated, %lld vs %lld", name(), proposal.config.ballot, get_ballot() ); return; } if (_primary_states.reconfiguration_task != nullptr) { dinfo( "%s: reconfiguration on the way, skip the incoming proposal", name() ); return; } if (proposal.config.ballot > get_ballot()) { if (!update_configuration(proposal.config)) { // is closing or update failed return; } } switch (proposal.type) { case CT_ASSIGN_PRIMARY: case CT_UPGRADE_TO_PRIMARY: assign_primary(proposal); break; case CT_ADD_SECONDARY: add_potential_secondary(proposal); break; case CT_DOWNGRADE_TO_SECONDARY: downgrade_to_secondary_on_primary(proposal); break; case CT_DOWNGRADE_TO_INACTIVE: downgrade_to_inactive_on_primary(proposal); break; case CT_REMOVE: remove(proposal); break; default: dassert (false, ""); } }