diff --git a/driver/failover_handler.cc b/driver/failover_handler.cc index b4a3cd5dd..1e2479f3a 100644 --- a/driver/failover_handler.cc +++ b/driver/failover_handler.cc @@ -359,6 +359,8 @@ bool FAILOVER_HANDLER::should_connect_to_new_writer(const char* host) { return false; } + MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] writer->get_port() = %d", writer->get_port()); + std::string writer_host = writer->get_host(); MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] writer->get_host() = %s", writer_host.c_str()); if (is_cluster(writer_host.c_str())) { @@ -372,18 +374,18 @@ bool FAILOVER_HANDLER::should_connect_to_new_writer(const char* host) { return false; } - MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] Replacing server '%s' with '%s'.", dbc->ds->server8, writer_host.c_str()); + MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] Replacing server '%s' with '%s'.", ds->server8, writer_host.c_str()); // DNS must have resolved the cluster endpoint to a wrong writer // so we should reconnect to a proper writer node. const sqlwchar_string writer_host_wstr = to_sqlwchar_string(writer_host); - ds_set_wstrnattr(&dbc->ds->server, (SQLWCHAR*)writer_host_wstr.c_str(), writer_host_wstr.size()); - ds_set_strnattr(&dbc->ds->server8, (SQLCHAR*)writer_host.c_str(), writer_host.size()); + ds_set_wstrnattr(&ds->server, (SQLWCHAR*)writer_host_wstr.c_str(), writer_host_wstr.size()); + ds_set_strnattr(&ds->server8, (SQLCHAR*)writer_host.c_str(), writer_host.size()); std::string suffix = ".proxied"; if (writer_host.compare(writer_host.length() - suffix.length(), suffix.length(), suffix) == 0) { MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] Updating port to 8666"); - dbc->ds->port = 8666; + ds->port = 8666; } MYLOG_TRACE(init_log_file().get(), 0, "[FAILOVER_HANDLER] returning true");