Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
justing-bq committed Apr 24, 2023
1 parent cecdb38 commit cee11a9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions driver/failover_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -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");
Expand Down

0 comments on commit cee11a9

Please sign in to comment.