pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Takahashi, Ryohei <r.takahashi_2@jp.fujitsu.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: 'Andreas Kretschmer' <andreas@a-kretschmer.de>
Cc: 'Francisco Olarte' <folarte@peoplecall.com>
Subject: Re: SQLSTATE when PostgreSQL crashes during COMMIT statement
Date: Tue, 16 Apr 2019 10:31:14 -0400
Message-ID: <26881.1555425074@sss.pgh.pa.us> (raw)
In-Reply-To: <EE586BE92A4AFB45B03310C2A0C0565D7BB6BB90@G01JPEXMBKW03>
References: <EE586BE92A4AFB45B03310C2A0C0565D7BB6B2F2@G01JPEXMBKW03>
	<CA+bJJbzfaN2N-33FiaPVyovT_Ey2F4eON2FmemVbe7EndyT5=Q@mail.gmail.com>
	<0edda023-5788-7971-50de-d5fca6208b6c@a-kretschmer.de>
	<EE586BE92A4AFB45B03310C2A0C0565D7BB6BB90@G01JPEXMBKW03>

"Takahashi, Ryohei" <r.takahashi_2@jp.fujitsu.com> writes:
>> So, if the library gives you an error ( "I have not received the commit
>> confirmation" , not something like "commit failed" ), you will still
>> need to test the data, if you can, to know how the server come back up.

> Yes.
> I want to know what error does library give to the application on such case.
> I supposed it is certain SQLSTATE.

libpq, at least, doesn't produce SQLSTATEs for errors that it detects.
(It probably should, but that's been a TODO item for a couple of
decades now ... so don't hold your breath.)  So the best you can do here
is to check the error message spelling.

A crude but possibly sufficient approach is to assume that once you've
got a working connection, *any* error that lacks a SQLSTATE is indicative
of connection loss.  This idea could fail for cases like out-of-memory,
but if your app is at the edge of OOM then giving up might be wise anyway.

			regards, tom lane





view thread (5+ messages)

Message-ID: <26881.1555425074@sss.pgh.pa.us>
Permalink:  ../26881.1555425074@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26881.1555425074@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, r.takahashi_2@jp.fujitsu.com, andreas@a-kretschmer.de, folarte@peoplecall.com
  Subject: Re: SQLSTATE when PostgreSQL crashes during COMMIT statement
  In-Reply-To: <26881.1555425074@sss.pgh.pa.us>
  References: <EE586BE92A4AFB45B03310C2A0C0565D7BB6B2F2@G01JPEXMBKW03> <CA+bJJbzfaN2N-33FiaPVyovT_Ey2F4eON2FmemVbe7EndyT5=Q@mail.gmail.com> <0edda023-5788-7971-50de-d5fca6208b6c@a-kretschmer.de> <EE586BE92A4AFB45B03310C2A0C0565D7BB6BB90@G01JPEXMBKW03> <26881.1555425074@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox