Ast18.20 + ODBC: why check ODBC backup connection every time?

Hello

Using Asterisk 18.20.0 on CentOS 7.9

Using realtime for SIP peers and dialplan.
I have an ODBC config with failover. Full config below this question.
There is a MAIN MySQL server (google cloud SQL) and a backup MySQL server (google cloud SQL).
Only if MAIN is down, the backup should be tried.

I see that with every call that comes in, the backup ODBC connection (mysqlgcp2) is also “polled”. But why ?! The main database connection (mysqlgcp1) is up and working !

Console on incoming call :

[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1060 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=2003 [unixODBC][MySQL][ODBC 8.2(a) Driver]Can't connect to MySQL server on '99.88.77.1:3306' (110)
[Dec  6 16:10:00] ERROR[29829][C-0000000b]: res_config_odbc.c:203 realtime_odbc: No database handle available with the name of 'mysqlgcp2' (check res_odbc.conf)
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00] ERROR[29829][C-0000000b]: res_config_odbc.c:203 realtime_odbc: No database handle available with the name of 'mysqlgcp2' (check res_odbc.conf)
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00] ERROR[29829][C-0000000b]: res_config_odbc.c:203 realtime_odbc: No database handle available with the name of 'mysqlgcp2' (check res_odbc.conf)
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00] ERROR[29829][C-0000000b]: res_config_odbc.c:203 realtime_odbc: No database handle available with the name of 'mysqlgcp2' (check res_odbc.conf)
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00] ERROR[29829][C-0000000b]: res_config_odbc.c:203 realtime_odbc: No database handle available with the name of 'mysqlgcp2' (check res_odbc.conf)
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:529 ast_odbc_print_errors: SQL Prepare returned an error: 42S22: [MySQL][ODBC 8.2(a) Driver][mysqld-5.7.43-google-log]Unknown column 'insecure' in 'where clause'
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_config_odbc.c:125 custom_prepare: SQL Prepare failed! [SELECT * FROM sip_buddies WHERE host = ? AND insecure LIKE ? ORDER BY host]
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:529 ast_odbc_print_errors: SQL Prepare returned an error: 42S22: [MySQL][ODBC 8.2(a) Driver][mysqld-5.7.43-google-log]Unknown column 'insecure' in 'where clause'
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_config_odbc.c:125 custom_prepare: SQL Prepare failed! [SELECT * FROM sip_buddies WHERE ipaddr = ? AND insecure LIKE ? ORDER BY ipaddr]
[Dec  6 16:10:00] WARNING[29829][C-0000000b]: res_odbc.c:1034 odbc_obj_connect: Not connecting to mysqlgcp2. Negative connection cache for 10 seconds
[Dec  6 16:10:00]   == Using SIP RTP TOS bits 184
[Dec  6 16:10:00]   == Using SIP RTP CoS mark 5
[Dec  6 16:10:00]        > 0x7f722012b830 -- Strict RTP learning after remote address set to: 11.12.13.14:12806
[Dec  6 16:10:00]     -- Executing [3291234567@from-carrier:1] NoOp("SIP/incoming-00000010", "from-carrier - DID 3291234567")

odbc.ini :

[asteriskconnector]
Driver       = /usr/lib64/libmyodbc8a.so
Description  = MySQL connection to 'asterisk' database
Database     = asterisk
SERVER       = 99.88.77.1
USER         = asteriskuser
Password     = astpwd
PORT         = 3306
OPTION       = 3
SOCKET       =
#Socket      = /var/lib/mysql/mysql.sock

[asteriskconnector2]
Driver       = /usr/lib64/libmyodbc8a.so
Description  = MySQL connection to 'asterisk' database
Database     = asterisk
SERVER       = 99.88.77.2
USER         = asteriskuser
Password     = astpwd
PORT         = 3306
OPTION       = 3
SOCKET       =
#Socket      = /var/lib/mysql/mysql.sock

res_odbc.conf :

[mysqlgcp]
enabled => yes
dsn => asteriskconnector
username => asteriskuser
password => astpwd
;max_connections => 20
connect_timeout => 3
pre-connect => yes
negative_connection_cache => 10

[mysqlgcp2]
enabled => yes
dsn => asteriskconnector2
username => asteriskuser
password => astpwd
;max_connections => 20
connect_timeout => 3
pre-connect => no

extconfig.conf :

sipusers => odbc,mysqlgcp,sip_buddies,1
sipusers => odbc,mysqlgcp2,sip_buddies,2
sippeers => odbc,mysqlgcp,sip_buddies,1
sippeers => odbc,mysqlgcp2,sip_buddies,2
realtime_incoming => odbc,mysqlgcp,extensions_incoming,1
realtime_incoming => odbc,mysqlgcp2,extensions_incoming,2

An alternative might be to add the second host in to your “asteriskconnector” SERVER string and drop the “asteriskconnector2” entirely.

Per MariaDB documentation:

[::1]:3306,192.168.0.1:3307,test.example.com

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.