Hi,<div><br></div><div>I am using core ODBC for MySQL connect.</div><div><br></div><div>Trying to implement failover using 2 servers - main and backup.</div><div>If main server is not responding, it should try to query backup server.</div>
<div><br></div><div>The following is used in my module:</div><div><br></div><div><div>if (switch_odbc_handle_callback_exec(<b>globals.master_odbc</b>, sql, my_func_callback, &amp;pdata, NULL) != SWITCH_ODBC_SUCCESS) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;(***)Error running query on master database: [%s]\n&quot;, sql);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;(***)Trying backup database: [%s]\n&quot;, globals.backup_odbc);</div>
<div><br></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (switch_odbc_handle_callback_exec(<b>globals.backup_odbc</b>, sql, my_func_callback, &amp;pdata, NULL) != SWITCH_ODBC_SUCCESS) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;(***)Error running query on master and backup database: [%s]\n&quot;, sql);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>} </div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
</div><div>...</div><div><br></div><div><br></div><div><br></div><div>Right now it tries to reconnect to main server 120 times before it gives up and goes to backup server.</div><div><br></div><div>I found the following in the switch_odbc.c:</div>
<div>int max_tries = 120;</div><div><br></div><div><br></div><div>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?</div><div>I know I can change the source, but this will be already &quot;customized core&quot; - don&#39;t want to go in this direction.</div>
<div><br></div><div><br></div><div>Or maybe there is a better way to handle database fail over in my module?</div><div><br></div><div><br></div><div>Thank you,</div><div>Vitalie</div>