<h3>Description</h3>
<p>I am testing how kamailio reacts to various database conditions.   One such condition is if the database engine is simply shut down (that is, database server process no longer running, tcp listening socket closed, etc...)</p>
<p>I am utilizing the db_unixodbc module to connect to an Informix database engine.</p>
<p>I am currently running on Kamailio version 5.0.1.</p>
<p>I have a test query that executes against the database engine every 10 seconds.</p>
<p>Here is what i have noticed if i shut down the database engine at some point after i run Kamailio.</p>
<p>The first test query that attempts to run against the db engine fails;  it tries to reconnect and fails.</p>
<p>The second test query (10 seconds after the 1st) results in a SIGCHILD and shuts down the entire Kamailio process.</p>
<p>I communicated this info to the mailing list and was asked to open an issue regarding this and to also test the more recent version 5 releases.</p>
<p>Here is the update on said tests:</p>
<p>I have tested the master branch and 5.3.0-dev2 and neither branch resolves the issue.</p>
<p>However I did notice in the master branch that there is new code that is related to this issue.</p>
<p><a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="371741553" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/1681" data-hovercard-type="issue" data-hovercard-url="/kamailio/kamailio/issues/1681/hovercard" href="https://github.com/kamailio/kamailio/issues/1681">#1681</a></p>
<p>In issue 1681 there is code that allows Kamailio to start even if a database connection can not be established.  Queries attempting to run against the offline database fail gracefully.  And once the database is back online, a connection is established and queries against it are successful.</p>
<p>However, if at some later point I shut down the database, we're back to the original issue that i reported.  Kamailio crashes with the same output as listed before except the first query that is attempted against the offline db causes the crash in this master branch unlike previously (branch 5.series) the first attempt fails, tries again and fails, and the second attempt causes the crash.  Regardless, the output is more or less the same and Kamailio is down.</p>
<p>I suspect this might be the same behavior even if one is not using an odbc driver; but maybe not.</p>
<h3>Troubleshooting</h3>
<h4>Reproduction</h4>
<p>Start Kamailio;  kill the database engine;  run test query from kamailo to said database engine;  Kamailio crashes.  This can be replicated using the db_unixodbc module;  not sure if it's the same for other types of database drivers.</p>
<h4>Log Messages</h4>
<p>Jan 17 20:07:25 [29297]: INFO: (s)  SQL query: FIRST TEST QUERY<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [dbase.c:135]: db_unixodbc_submit_query(): rv=-1. Query= FIRST TEST QUERY<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [connection.c:220]: db_unixodbc_extract_error(): unixodbc:SQLExecDirect=08S01:1:-11020:[Informix][Informix ODBC Driver]Communication link failure.<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [dbase.c:59]: reconnect(): Attempting DB reconnect<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [dbase.c:74]: reconnect(): failed to connect<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [connection.c:220]: db_unixodbc_extract_error(): unixodbc:SQLDriverConnect=08002:1:0:[unixODBC][Driver Manager]Connection name in use<br>
Jan 17 20:07:25 [29297]: ERROR: db_unixodbc [connection.c:220]: db_unixodbc_extract_error(): unixodbc:SQLDriverConnect=HY010:2:-11067:[Informix][Informix ODBC Driver]Function sequence error.<br>
Jan 17 20:07:25 [29297]: ERROR:  [db_query.c:181]: db_do_raw_query(): error while submitting query<br>
Jan 17 20:07:25 [29297]: ERROR: sqlops [sql_api.c:265]: sql_do_query(): cannot do the query FIRST TEST QUERY<br>
Jan 17 20:07:25 [29297]: INFO: (s) [123] SQL ret: fail (-1)<br>
Jan 17 20:07:25 [29297]: INFO: (s) [123] SQL res: no rows<br>
Jan 17 20:07:35 [29297]: INFO: (s) [123] SQL query: 10 seconds later the SECOND TEST QUERY (it's the same query as the first one)<br>
Jan 17 20:07:35 [29301]: CRITICAL:  [core/pass_fd.c:277]: receive_fd(): EOF on 28<br>
Jan 17 20:07:35 [29283]: ALERT:  [main.c:744]: handle_sigs(): child process 29297 exited by a signal 11<br>
Jan 17 20:07:35 [29283]: ALERT:  [main.c:747]: handle_sigs(): core was not generated<br>
Jan 17 20:07:35 [29283]: INFO:  [main.c:759]: handle_sigs(): terminating due to SIGCHLD<br>
Jan 17 20:07:35 [29301]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29295]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29291]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29288]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29300]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29284]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29286]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29293]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29289]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29287]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29292]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29296]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29298]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29299]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29285]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29294]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29290]: INFO:  [main.c:814]: sig_usr(): signal 15 received<br>
Jan 17 20:07:35 [29283]: INFO:  [core/sctp_core.c:53]: sctp_core_destroy(): SCTP API not initialized</p>
<h3>Additional Information</h3>
<p>version: kamailio 5.0.1 (x86_64/linux)<br>
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES<br>
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.<br>
id: unknown<br>
compiled on 11:25:09 May  2 2018 with gcc 4.1.2</p>
<p>version: kamailio 5.3.0-dev2 (x86_64/linux) 30857d-dirty<br>
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES<br>
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.<br>
id: 30857d -dirty<br>
compiled on 14:30:54 Jan 22 2019 with gcc 4.1.2</p>
<ul>
<li><strong>Operating System</strong>:<br>
Red Hat Enterprise Linux Server release 5.11 (Tikanga)<br>
Linux 2.6.18-404.el5 <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="31891578" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/1" data-hovercard-type="issue" data-hovercard-url="/kamailio/kamailio/issues/1/hovercard" href="https://github.com/kamailio/kamailio/issues/1">#1</a> SMP Sat Mar 7 04:14:13 EST 2015 x86_64 x86_64 x86_64 GNU/Linux</li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1821">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZdLeCWp7r1YjK149j6B_EslrHwbaks5vGLxpgaJpZM4aPgQx">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZT4DDn960MmyQNBGNYJKeyN6NQXoks5vGLxpgaJpZM4aPgQx.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"kamailio crashes when attempting to query offline database (#1821)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1821"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1821",
"url": "https://github.com/kamailio/kamailio/issues/1821",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>