SQLSTATE for Hot Standby cancellation

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Greg Smith <greg(at)2ndquadrant(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: SQLSTATE for Hot Standby cancellation
Date: 2010-05-06 13:58:34
Message-ID: 1273154314.12659.422.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2010-05-06 at 12:08 +0200, Yeb Havinga wrote:

> That's funny because when I was reading this thread, I was thinking the
> exact opposite: having max_standby_delay always set to 0 so I know the
> standby server is as up-to-date as possible. The application that
> accesses the hot standby has to be 'special' anyway because it might
> deliver not-up-to-date data. If that information about specialties
> regarding querying the standby server includes the warning that queries
> might get cancelled, they can opt for a retry themselves (is there a
> special return code to catch that case? like PGRES_RETRY_LATER) or a
> message to the user that their report is currently unavailable and they
> should retry in a few minutes.

Very sensible. Kevin Grittner already asked for that and I alread
agreed, yet it has not been implemented that way
http://archives.postgresql.org/pgsql-hackers/2008-12/msg01691.php

Can anyone remember a specific objection to that 'cos it still sounds
very sensible to me and is a quick, low impact change.

Currently the SQLSTATE is ERRCODE_ADMIN_SHUTDOWN or
ERRCODE_QUERY_CANCELED if not idle. That makes it even harder to
determine the retryability, since it can come back in one of two states.

Proposed SQLSTATE for HS cancellation is
case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN:
case PROCSIG_RECOVERY_CONFLICT_LOCK:
case PROCSIG_RECOVERY_CONFLICT_SNAPSHOT:
case PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK:
recovery_conflict_errcode = ERRCODE_T_R_SERIALIZATION_FAILURE;
break;
case PROCSIG_RECOVERY_CONFLICT_DATABASE:
case PROCSIG_RECOVERY_CONFLICT_TABLESPACE:
recovery_conflict_errcode = ERRCODE_ADMIN_SHUTDOWN;
break;

We don't have a retryable SQLSTATE, so perhaps we should document that
serialization_failure and deadlock_detected are both retryable error
conditions. As the above implies HS can throw some errors that are
non-retyable, so we use ERRCODE_ADMIN_SHUTDOWN.

Comments?

--
Simon Riggs www.2ndQuadrant.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2010-05-06 14:09:57 Re: max_standby_delay considered harmful
Previous Message Simon Riggs 2010-05-06 13:56:38 SQLSTATE for Hot Standby cancellation