Hi,

I am using core ODBC for MySQL connect.

Trying to implement failover using 2 servers - main and backup.
If main server is not responding, it should try to query backup server.

The following is used in my module:

if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, my_func_callback, &pdata, NULL) != SWITCH_ODBC_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(***)Error running query on master database: [%s]\n", sql);

switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(***)Trying backup database: [%s]\n", globals.backup_odbc);


if (switch_odbc_handle_callback_exec(globals.backup_odbc, sql, my_func_callback, &pdata, NULL) != SWITCH_ODBC_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "(***)Error running query on master and backup database: [%s]\n", sql);
} 
}
...



Right now it tries to reconnect to main server 120 times before it gives up and goes to backup server.

I found the following in the switch_odbc.c:
int max_tries = 120;


Is there is a way to disable this check, so if it will not be able to connect to master, it will immediate go to backup server?
I know I can change the source, but this will be already "customized core" - don't want to go in this direction.


Or maybe there is a better way to handle database fail over in my module?


Thank you,
Vitalie