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

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Dennis White <dwhite(at)seawardmoon(dot)com>, pgsql-general <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:59:26
Message-ID: 7e8b6d1951cf55c534966eb4a346add6fa420da7.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2024-07-05 at 14:12 -0400, Dennis White wrote:
> 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?

I don't think there is a direct way to do that in SQL; that would require a new
system function that exposes canAcceptConnections() in SQL.

What you could do is use the dblink extension to connect to the local database.
If you get an error "the database system is shutting down", there is a smart
shutdown in progress.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2024-07-06 06:06:13 Re: Can a long running procedure detect when smart shutdown is pending?
Previous Message Pavel Stehule 2024-07-06 05:39:38 Re: Can a long running procedure detect when smart shutdown is pending?