Re: Client query hangs when network connection is lost to the server.

From: Steve Rosenberry <smrosenberry(at)electronicsolutionsco(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Client query hangs when network connection is lost to the server.
Date: 2013-04-10 13:37:24
Message-ID: CA+g9Fpw_GEoZ+P+JvsCqUj29A9Ob0i_R7J-Ms8bR=NnCLHW4SQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

For others who may stumble upon this looking for an answer. This seems to
be working as expected.

Another person at work found sample code showing how to mimic the PQexec()
functionality such that one has a chance to break out of waiting for the
server response. The new code uses the PQsendQuery(), PQisBusy(),
PQconsumeInput(), and PQgetResult() functions and is based upon example
code from page 342 of "PostgreSQL: A Comprehensive Guide to Building,
Programming, and Administering PostgreSQL Databases" by Korry Douglas and
Susan P. Douglas, 1st Edition, February 2003.

Basically I added a flag to the wait loop that indicates the query should
be cancelled, breaks the loop, and returns a NULL PGresult*. The flag is
set by an independent mechanism (in our simplistic case, a simple system
ping) that determines the PostgreSQL server is no longer available through
the network.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kevin Grittner 2013-04-11 23:02:13 Re: about view privileges
Previous Message kobolds 2013-04-10 12:41:31 about view privileges