Summary:ASTERISK-14805: idle odbc connections are not cleaned up
Reporter:Mark Murawski (kobaz)Labels:
Date Opened:2009-09-09 09:49:29Date Closed:2009-09-10 18:07:29
Versions:Frequency of
Description:When using queries defined in func_odbc, asterisk will periodically 'forget' about connections it's already made, and will think it's disconnected with the database.

The query will fail for some reason, even though a connection is already present.  A new connection will be made.  The old connection is not cleaned up.  And after a while the max connection limit on the server is hit and asterisk can't make any more odbc connections.

I'm not sure if this is a problem with the unixodbc driver, or with asterisk.  My short term fix is a script that runs around killing old idle postgres connections from asterisk.
Comments:By: Tilghman Lesher (tilghman) 2009-09-10 13:40:08

With no output, no debugging, no information at all, I cannot even begin to diagnose a problem here.

By: Mark Murawski (kobaz) 2009-09-10 13:43:47

Yeah. I know how it goes.  But I really have nothing to go on.

What would be a starting point for debugging... are there extra odbc verbosity options I can turn on?

By: Tilghman Lesher (tilghman) 2009-09-10 16:50:05

Perhaps we should start with the statement "The query will fail for some reason,".  Let's see the messages output when the query fails for some reason.

By: Mark Murawski (kobaz) 2009-09-10 16:55:52

[Sep 10 17:01:06] VERBOSE[12259] logger.c:     -- Executing [s@macro-pickup:1] Set("DAHDI/26-1", "ODBC_CALLS_CalleePickup(159788,"DAHDI/26-1",1252616458.32424)=1") in new stack
[Sep 10 17:01:06] NOTICE[12259] res_odbc.c: Re-connecting pbx
[Sep 10 17:01:06] WARNING[12259] res_odbc.c: res_odbc: Error SQLConnect=-2 errno=136042096 \201\266^K^C\304\267\364\277\325\267
[Sep 10 17:01:06] WARNING[12259] func_odbc.c: SQL Alloc Handle failed!
[Sep 10 17:01:06] WARNING[12259] res_odbc.c: SQL Exec Direct failed.  Attempting a reconnect...
[Sep 10 17:01:06] WARNING[12259] res_odbc.c: Unable to deallocate database handle? 0 errno=-1233010716 \276\267(\277\201\266^A
[Sep 10 17:01:06] NOTICE[12259] res_odbc.c: Connecting pbx
[Sep 10 17:01:06] NOTICE[12259] res_odbc.c: res_odbc: Connected to pbx [pbx]

By: Mark Murawski (kobaz) 2009-09-10 16:57:15

I'll get an error like that every few hours.  A new odbc connection is made, and then the old one is left dangling.

By: Tilghman Lesher (tilghman) 2009-09-10 18:07:29

That is very clearly a database driver issue, not something that we can address in Asterisk.