[Home]

Summary:ASTERISK-07496: [patch] func_odbc does not return correct value at first request after ODBC connection has been down
Reporter:Morten Isaksen (misaksen)Labels:
Date Opened:2006-08-09 08:07:45Date Closed:2006-08-20 10:46:30
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_odbc
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20060812__bug7693.diff.txt
( 1) func_odbc.c.patch
( 2) res_odbc.c.patch
( 3) trace.txt
Description:func_odbc returns nothing due to a SQL Execute error the first time the function is called after a database connection failure. The write part is working fine after a database connection failure.

I have copied the "retry" code from acf_odbc_write to acf_odbc_read.

Patch file is included.
Comments:By: Serge Vecher (serge-v) 2006-08-09 10:13:12

Please get a disclaimer on file (see bottom of http://bugs.digium.com/main_page.php) and cofirm with a note here when done.

Thanks!

By: Morten Isaksen (misaksen) 2006-08-10 01:11:51

Disclaimer has been faxed...

By: Serge Vecher (serge-v) 2006-08-10 08:49:37

thanks, misaksen.

By: Tilghman Lesher (tilghman) 2006-08-12 23:20:45

What this really calls for is to use the existing generic facilities to do this same thing in a nice way (i.e. without using labels and goto).

By: Serge Vecher (serge-v) 2006-08-14 09:04:37

misaksen: please feel free to test Corydon76's patch and report back on the results. Thanks.

By: Morten Isaksen (misaksen) 2006-08-16 13:30:56

The patch Corydon76 submitted does not work. It is only able to reconnect to the database if there has been no request to the database while it has been down.

You can make it fail like this:

- Start Mysql
- Start Asterisk
- Stop Mysql
- Dial an extension that calls func_odbc
- Start Mysql

Now func_odbc fails for all queries.

By: Morten Isaksen (misaksen) 2006-08-16 13:33:41

Forgot the console output:

[Aug 16 22:40:23] WARNING[13090]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13090]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: func_odbc.c:79 generic_prepare: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: func_odbc.c:79 generic_prepare: SQL Alloc Handle failed!
[Aug 16 22:40:23] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '(null)'
   -- Executing [080000@udland:1] Set("SIP/079999-08601d08", "qw=") in new stack
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:23] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:25] WARNING[13158]: res_config_odbc.c:92 realtime_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:25] WARNING[13158]: res_config_odbc.c:243 realtime_multi_odbc: SQL Alloc Handle failed!
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '"sipsrv1" <079999>'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '079999'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '080000'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'udland'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'SIP/079999-08601d08'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is ''
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'Set'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'qw='
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '2006-08-16 22:40:23'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is ''
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '2006-08-16 22:40:25'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '2'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '0'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'NO ANSWER'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is 'DOCUMENTATION'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is ''
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is '1155760823.5'
[Aug 16 22:40:25] DEBUG[13158]: pbx.c:1529 pbx_substitute_variables_helper_full: Function result is ''

The dialed extension is:

exten => 080000,1,set(qw=${ODBC_ASTDB(test,test)})

By: Morten Isaksen (misaksen) 2006-08-16 14:16:34

I have submitted a patch (res_odbc.c.patch) that solves the problem with the reconnect issue.

But now asterisk sometimes crashes. I do not now if it related to this patch. I have uploaded a trace. Do you need the core file also?

By: Tilghman Lesher (tilghman) 2006-08-16 19:42:22

The crash is not related (see that it's crashing in cdr_odbc, which doesn't use the res_odbc facility).

By: Tilghman Lesher (tilghman) 2006-08-16 20:14:40

You may want to file that crash under a separate bug, and get a backtrace from gdb (which will have a bit more information than what you had posted).

By: Morten Isaksen (misaksen) 2006-08-17 01:06:56

I did some more debugging...

Asterisk also crashes in odbc_smartexecute as well as cdr_odbc. As far as I can tell from gdb it is the call to SQLFreeHandle that makes it crash.

I will file a seperate bug about this.

By: Tilghman Lesher (tilghman) 2006-08-20 10:46:30

Committed to trunk.