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

From: Achilleas Mantzios <a(dot)mantzios(at)cloud(dot)gatewaynet(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Can a long running procedure detect when smart shutdown is pending?
Date: 2024-07-05 20:57:31
Message-ID: 7b98efa8-9a3e-4012-8dd9-d980b5e40609@cloud.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Στις 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 David Rowley 2024-07-05 22:26:01 Re: Planning of sub partitions
Previous Message Tom Lane 2024-07-05 20:19:58 Re: Removing the default grant of EXECUTE on functions/procedures to PUBLIC