Re: Can a long running procedure detect when smart shutdown is pending?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: dwhite(at)seawardmoon(dot)com
Cc: Achilleas Mantzios <a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Can a long running procedure detect when smart shutdown is pending?
Date: 2024-07-06 05:39:38
Message-ID: CAFj8pRD7WHhsUkOyxw-fCBnPTShQxOeJSTzqa5zt-nzqSU2Rwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

so 6. 7. 2024 v 1:36 odesílatel Dennis White <dwhite(at)seawardmoon(dot)com>
napsal:

> Thanks for responding.
> This will be a stored procedure written in plpgsql that's kicked off by
> pg_cron.
> I wasn't sure a normal smart shutdown would stop it.
>

shutdown try to cancel any query. The plpgsql routine should be canceled
without problems.

>
> Thanks
>
> On Fri, Jul 5, 2024 at 4:57 PM Achilleas Mantzios <
> a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com> wrote:
>
>> Στις 5/7/24 21:12, ο/η Dennis White έγραψε:
>>
>> My project's DB has a mutli-step stored procedure using Transaction
>> Control that may take 30 minutes or more to complete.
>> I am curious if there is a way to make it more smart shutdown friendly so
>> it can stop between steps?
>>
>> We are using both PG 14 and PG 16 on Rhel 8.
>> Pardon me if it's obvious but is there a function to call or a table that
>> could be checked after a commit within the procedure to determine a
>> shutdown is pending?
>>
>> Maybe somehow checking the log for a message like :
>>
>> received smart shutdown request
>>
>> Or use tail_n_mail against the log and then implement some logic using
>> NOTIFY , ideally you want your procedure to be interrupted rather than do
>> polling.
>>
>>
>> Thanks,
>> Dennis
>>
>> --
>> Achilleas Mantzios
>> IT DEV - HEAD
>> IT DEPT
>> Dynacom Tankers Mgmt (as agents only)
>>
>>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2024-07-06 05:59:26 Re: Can a long running procedure detect when smart shutdown is pending?
Previous Message Krishnakant Mane 2024-07-06 05:39:23 Re: confused about material view locks please explain