ODBC Voicemail Storage - Crashing on Start

I’m running Asterisk 13.14 on Debian 9 (Stretch). I had the package asterisk-voicemail installed, but wanted to have voice mail messages stored in MySQL, so I replaced it with asterisk-voicemail-odbcstorage. I’ve configured ODBC, my tests show that ODBC connects properly to my MariaDB, and the Asterisk logs show that it’s successfully connecting.

However, I’m getting some oddities when I try to actually use it. For instance, when I first installed the package, Asterisk would crash on start. I’ve narrowed it down to some parameters in voicemail.conf. If either pollmailboxes is defined, or even a single mailbox is defined, then Asterisk crashes on start, then it attempts to restart. When it crashes, it puts nothing in the logs other than the normal startup process. Here’s an example:

[2017-09-23 16:58:54] VERBOSE[14286] config.c: Parsing '/etc/asterisk/voicemail.conf': Found
[2017-09-23 16:58:54] VERBOSE[14286] config.c: Parsing '/etc/asterisk/users.conf': Found
[2017-09-23 16:58:56] Asterisk 13.14.1~dfsg-2+deb9u1 built by a2824ck @ BADWLRZ-CLBSC01 on a x86_64 running Linux on 2017-09-04 08:27:12 UTC

The first two lines are the last lines entered before the crash, and the third line is the process restarting. It will continue in a loop until I kill the the process (systemctl stop asterisk.service).

If I comment out pollmailboxes and don’t actually create any mailboxes, then Asterisk will start properly. Or, if I remove asterisk-voicemail-odbcstorage and replace it with the file-based asterisk-voicemail, it will work fine then too.

I’m not really sure how to troubleshoot this, since I’m not getting anything useful in the logs (which are turned all the way, including debug).

Some additional information.

As mentioned earlier, without those options in voicemail.conf defined, Asterisk will start properly. What I’ve found out since posting the above is that Asterisk crashes as soon as a SIP peer successfully registers when asterisk-voicemail-odbcstorage is installed. So I’ve removed that and reinstalled asterisk-voicemail, and Asterisk works fine again without crashing… but obviously with the big problem being that I can’t store voice messages in my MariaDB.

Also, I’ve done further tests with ODBC to make sure that it’s working properly.

$ asterisk -rx 'odbc show'

ODBC DSN Settings

  Name:   asterisk
  DSN:    asterisk
    Last connection attempt: 1969-12-31 17:00:00
    Number of active connections: 1 (out of 1)

I defined a function in func_odbc.conf

asterisk -rx 'odbc read ODBC_TEST "" exec'

Ooops! Looks like that crashes Asterisk. This is with ODBC configured and installed, but not specifically the ODBC storage for voicemail, so it looks like this is an ODBC issue, whether it be configuration or a bug. If anyone has suggestions, that would be wonderful. In the meantime, I’m going to see what other tests I can run.

I’ve tried with various versions of the MariaDB ODBC connector, and one version of the MySQL ODBC connector, and here’s the result in each case when trying to execute a query via one defined in func_odbc.conf:

2.0.10 - Shows this error in the log: func_odbc.c:462 execute: SQL Alloc Handle failed (-1)!
2.0.11 - Shows this error in the log: func_odbc.c:462 execute: SQL Alloc Handle failed (-1)!
2.0.12 - Crashes Asterisk and restarts.
2.0.13 - Crashes Asterisk and restarts.
2.0.14 - Crashes Asterisk and restarts.
2.0.15 - Crashes Asterisk and restarts.
3.0.1 - Claims that it can’t find the library file on load, despite it being there.
MySQL ODBC 5.3.9 - Crashes Asterisk and restarts.

isql tests work with all of these, except 3.0.1, which claims “file not found” for the library, even though it very clearly is there.

I had a similar issue (although isql segfaulted for me, and on CentOS instead of debian) with Percona, the following thread helped me work it out:

Try changing the libmysqlclient.so symlink and see if it helps.

Interesting thread. It was helpful in giving me some additional thoughts, such as being able to identify the segfault in /var/log/messages:

Sep 23 23:04:32 localhost kernel: [429926.920353] asterisk[25865]: segfault at 8 ip 00007fd9c58d3d8e sp 00007fd9a46af950 error 4 in libmariadbclient.so.18.0.0[7fd9c58aa000+37c000]

However, it looks like version 18.0.0 is the only version that exists in any version of Debian, so I can’t so easily just swap this out. It also happens to match the version of the working version of the OP in the other thread. Other than taking shots in the dark (which it looks like the other poster did, and he got very lucky with that), I’m not sure how to approach this further.

But I did find someone who appears to have the same setup as me on this thread who posted last month, so I’ve asked him for additional details on how he got his setup working.