Re: archive_command during database shutdown

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: rod(at)iol(dot)ie
Cc: Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: archive_command during database shutdown
Date: 2016-05-25 21:56:54
Message-ID: CAMkU=1y_iYi0kHQrp-QYpwsOBxvz-Gcu3ZmQiz68SYrzkROcXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 25, 2016 at 1:36 PM, Raymond O'Donnell <rod(at)iol(dot)ie> wrote:
> On 25/05/16 20:57, Jeff Janes wrote:
>>
>> On Wed, May 25, 2016 at 10:31 AM, Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com>
>> wrote:
>>>
>>>
>>>
>>> On Thu, 26 May 2016, 1:25 a.m. Jeff Janes, <jeff(dot)janes(at)gmail(dot)com> wrote:
>>>>
>>>>
>>>> I've recently wanted to run a different archive_command during
>>>> database shutdown than during normal operations. In particular, if
>>>> the normal archive process fails during normal operations, I want it
>>>> to be retried later (as it currently does). But if it fails during
>>>> shutdown, I want it to run a fallback archive_command.
>>>
>>>
>>>
>>> What version of PostgreSQL are you using?
>>
>>
>> 9.2, 9.4, 9.5, 9.6beta.
>>
>>>
>>>>
>>>> The only way I can see to accomplish this is to have the
>>>> archive_command try to connect back to the database and see if it gets
>>>> an error. That seems pretty ugly. Is there a better way?
>>>
>>>
>>>
>>> What's your goal here?
>>
>>
>> I want my database to shut down cleanly when I tell it to.
>>
>>>
>>> During a shutdown, if you don't so much care about checkpoint and fsync
>>> of
>>> buffers to disk, you can do an immediate shutdown.
>>
>>
>> But I do care about the checkpoint. Otherwise you lose all your
>> unlogged tables. And probably other unfortunate things happen, as
>
>
> Isn't that the point of unlogged tables? Or rather, isn't that the risk you
> knowingly take with them - you trade reliability for speed?

Sure. And I have rebuilt them. But when the firemen pack up and
leave, I've got better things to be doing with my time (and limited IO
capacity on a half crippled system) than rebuilding unlogged tables
for no particular reason. The purpose of the database is to be a tool,
not a moral scold.

But now I think the problem is not when the archive_command fails, but
when it hangs and never returns at all. That means the solution has
to look somewhat different, but I still don't know exactly what.

Cheers,

Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lucas Possamai 2016-05-25 22:34:02 gin index postgres 9.2
Previous Message Andrej Vanek 2016-05-25 21:22:30 empty pg_stat_replication when replication works fine?