[Devel] Postgres reconnect patch

Michael Ulitskiy mdu113 at acedsl.com
Thu Aug 4 20:43:52 CEST 2005

Hi Klaus,

I've seen the problem described by Klaus too, but first of all I was 
concerned that postgres module cannot reconnect to db after connection 
failure. It crashed openser.
I've done some research on the module source code and I  believe
I've found a logical mistake in it.
The issue is that parse_sql_url() function is supplied with the only copy
of sql url and it corrupts it. So if the connection fails and module
tries to reparse url it fails as CON_SQLURL(_h) is corrupted by first
I've created a simple patch that corrects the problem. What it does it
it introduce a temporary buffer with sql url string for parse_sql_url to work
on. Also it makes so that original sql url is not deleted from connection structure
until db_close() is called.
Patch is attached.
Also if in dbase.c in db_init() function you comment out the following:

        if (connect_db(res) < 0)
                PLOG("db_init", "Error while trying to open database, FATAL\n")
                return((db_con_t *) 0);

you'll get a "delay connect until used" feature that can be usefull due to lack
of connection pool for postgres.
Could please some of developers review this patch?


On Thursday 04 August 2005 11:39 am, Klaus Darilion wrote:
> Hi!
> I had several situations in which openser crashed if the DB lookup 
> fails, e.g:
> table does not exist (acc module)
> wrong SQL query (lcr module)
> Whereas is some cases (wrong table permissions, avpops module) openser 
> keeps running.
> I do not know if these problems also occurs with mysql. If not, the 
> postgresql module would really need some review.
> regards,
> klaus
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postgres-reconnect.patch
Type: text/x-diff
Size: 4427 bytes
Desc: not available
Url : http://openser.org/pipermail/devel/attachments/20050804/c59c51b6/postgres-reconnect.bin

More information about the Devel mailing list