/*callback*/ void replication_app_client_base::replica_rw_reply( error_code err, dsn_message_t request, dsn_message_t response, request_context_ptr& rc ) { { zauto_lock l(rc->lock); if (rc->completed) { //dinfo("already time out before replica reply"); err.end_tracking(); return; } } if (err != ERR_OK) { goto Retry; } ::unmarshall(response, err); // // some error codes do not need retry // if (err == ERR_OK || err == ERR_HANDLER_NOT_FOUND) { end_request(rc, err, response); return; } // retry else { dsn::rpc_address adr = dsn_msg_from_address(response); } Retry: dinfo("%s.client: get error %s from replica with index %d", _app_name.c_str(), err.to_string(), rc->partition_index ); // clear partition configuration as it could be wrong { zauto_write_lock l(_config_lock); _config_cache.erase(rc->partition_index); } // then retry call(rc.get(), false); }
void meta_service::on_request(dsn_message_t msg) { meta_request_header hdr; ::unmarshall(msg, hdr); meta_response_header rhdr; bool is_primary = _state->get_meta_server_primary(rhdr.primary_address); if (is_primary) is_primary = (primary_address() == rhdr.primary_address); rhdr.err = ERR_OK; ::dsn::rpc_address faddr; dsn_msg_from_address(msg, faddr.c_addr_ptr()); dinfo("recv meta request %s from %s:%hu", dsn_task_code_to_string(hdr.rpc_tag), faddr.name(), faddr.port() ); dsn_message_t resp = dsn_msg_create_response(msg); if (!is_primary) { rhdr.err = ERR_TALK_TO_OTHERS; ::marshall(resp, rhdr); } else if (!_started) { rhdr.err = ERR_SERVICE_NOT_ACTIVE; ::marshall(resp, rhdr); } else if (hdr.rpc_tag == RPC_CM_QUERY_NODE_PARTITIONS) { configuration_query_by_node_request request; configuration_query_by_node_response response; ::unmarshall(msg, request); query_configuration_by_node(request, response); ::marshall(resp, rhdr); ::marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_QUERY_PARTITION_CONFIG_BY_INDEX) { configuration_query_by_index_request request; configuration_query_by_index_response response; unmarshall(msg, request); query_configuration_by_index(request, response); ::marshall(resp, rhdr); ::marshall(resp, response); } else if (hdr.rpc_tag == RPC_CM_UPDATE_PARTITION_CONFIGURATION) { update_configuration(msg, resp); rhdr.err.end_tracking(); return; } else { dassert(false, "unknown rpc tag %x (%s)", hdr.rpc_tag, dsn_task_code_to_string(hdr.rpc_tag)); } dsn_rpc_reply(resp); }