[asterisk-dev] [Code Review] res_config_pgsql needs db reconnection support

kobaz reviewboard at asterisk.org
Sat Dec 25 23:38:57 UTC 2010

This is an automatically generated e-mail. To reply, visit:

(Updated 2010-12-25 17:38:57.678344)

Review request for Asterisk Developers.


Renamed Postgres in log messages to PostgreSQL.
Added text 'Realtime' to appropriate realtime related log messages (example line 451, processing config data... the error thrown is a local processing error, not a postgres error)


If your postgres connection died suddenly in between res_config_pgsql queries, the query will fail because the query is executed on a disconnected/disconnecting handle.

Reviewboard patch adds support for reconnecting and retrying the failed query if the connection was closed while executing the query. The patch also removes lots of duplication of checking for handling query errors.

Ideally there should be a centralized res module for postgres connections that cdr_pgsql and res_config_pgsql (and any other pgsql dependent module) can use for a centralized db abstraction module.

But I believe fixing up res_config_pgsql is the first step.

Diffs (updated)

  trunk/res/res_config_pgsql.c 295123 

Diff: https://reviewboard.asterisk.org/r/944/diff



voicemail => pgsql,pbx,asterisk.v_asterisk_voicemail_config


Start asterisk
(kill all current connections, replace pbx with appropriate database name)
kill `ps aux | grep postgres | grep pbx | awk {'print $2'}`

Launch voicemail (or something else that uses res_config_pgsql)

[Sep 28 16:02:31] ERROR[23650]: res_config_pgsql.c:167 _pgsql_exec: PostgreSQL RealTime: Failed to query 'asterisk.v_asterisk_voicemail_config at pbx'.
[Sep 28 16:02:31] ERROR[23650]: res_config_pgsql.c:168 _pgsql_exec: PostgreSQL RealTime: Query Failed: SELECT * FROM asterisk.v_asterisk_voicemail_config WHERE mailbox = '2702' AND context = 'internal'
[Sep 28 16:02:31] ERROR[23650]: res_config_pgsql.c:169 _pgsql_exec: PostgreSQL RealTime: Query Failed because: FATAL:  terminating connection due to administrator command
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
[Sep 28 16:02:31] NOTICE[23650]: res_config_pgsql.c:230 pgsql_exec: PostgreSQL RealTime: Query finally succeeded: SELECT * FROM asterisk.v_asterisk_voicemail_config WHERE mailbox = '2702' AND context = 'internal'
    -- <SIP/2701-00000005> Playing 'vm-theperson.ulaw' (language 'en')
    -- <SIP/2701-00000005> Playing 'digits/2.ulaw' (language 'en')
    -- <SIP/2701-00000005> Playing 'digits/7.ulaw' (language 'en')
    -- <SIP/2701-00000005> Playing 'digits/0.ulaw' (language 'en')
    -- <SIP/2701-00000005> Playing 'digits/2.ulaw' (language 'en')



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20101225/57ee19c5/attachment.htm>

More information about the asterisk-dev mailing list