It's actually odbx_result() that's returning -1 while odbx_error_type() returns 
1 in the scenario described, which fails to trigger the reconnect attempt.  The 
call to odbx_query() appears to be returning 0.

Versions: opendbx 1.4.5, postgresql and pqlib 9.0.2

-MSK

From: Murray S. Kucherawy [mailto:m...@cloudmark.com]
Sent: Wednesday, January 12, 2011 1:54 PM
To: libopendbx-devel@lists.sourceforge.net
Subject: [opendbx] odbx_error_type() issue

I have an application using opendbx that tries the sequence suggested by the 
opendbx documentation to do a query; specifically, I have a "get" function that 
basically does this:

err = odbx_query(db, ...);
if (err < 0)
{
   if (odbx_error_type(db, err) < 0)
   {
      odbx_unbind(db);
      odbx_finish(db);
      odbx_init(&db, ...);
      odbx_bind(db, ...);
      err = odbx_query(db, ...);
      if (err < 0)
        return err;
   }
   else
   {
      return err;
   }
   parse_result(db, ...);
}

I've got a user reporting that a connection lost to a postgresql server results 
in an error from our application.  The postgresql error we get back is:

FATAL:  terminating connection due to administrator command

A web search suggests this is the result of a deliberate server shutdown.  An 
odbx_query() then, predictably, fails, but should run through the reconnect 
attempt described above.  In a test with MySQL, a first "get" succeeds, then 
after I terminated and restart MySQL, a second "get" runs through the reconnect 
logic and the inner odbx_query() then succeeds.

In a similar restart-after-query test with postgresql, the "get" returns the 
above error.  I'm waiting for more data from the reporting user but it would 
appear the fatal error reported by that backend isn't causing odbx_error_type() 
to return -1, so the reconnect isn't attempted and an error is returned.  When 
I can confirm this I'll follow-up.  I also don't yet have the versions of 
postgresql library or server, or the version of opendbx, in use in this 
scenario.

In the interim, does this ring any bells?  Is this a known issue, or am I doing 
something wrong with my use of the API?

Thanks,
-MSK
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
libopendbx-devel mailing list
libopendbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopendbx-devel
http://www.linuxnetworks.de/doc/index.php/OpenDBX

Reply via email to