From: | Jeremy Finzel <finzelj(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, pglogical-list(at)2ndquadrant(dot)com |
Subject: | How to only auto-restart BGW only on crash or _PG_init |
Date: | 2020-03-24 18:32:49 |
Message-ID: | CAMa1XUgOYEL1XQ46iHY6ASvtnbw-xPkDF7iYEUB1R+B026xHLA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Good afternoon!
I would be grateful for some direction on how to use Background workers to
have a worker automatically restart *only* in certain cases, i.e. on
postmaster start (_PG_init) or a soft crash. I run into all sorts of
trouble if I set bgw_restart_time to actually restart on sigterm, because
in most cases I don't want it to restart (i.e. it was launched with invalid
config, the SQL becomes invalid...). But I *do* want it to auto-restart in
any kind of crash. If I set bgw_restart_time to never restart, then it
doesn't restart after a soft crash, which I want.
This is for my extension pglogical_ticker, and specifically within this
main function where a sigterm might happen:
https://github.com/enova/pglogical_ticker/blob/ef9b68fd6b5b99787034520009577f8cfec0049c/pglogical_ticker.c#L85-L201
I have tried several things unsuccessfully (checking result of SPI_execute
or SPI_connect) , usually resulting in a constantly restarting and failing
worker. So, is there a straightforward way to only have the worker
auto-restart in a very narrow range of cases?
Many thanks!
Jeremy
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-03-24 18:45:55 | Re: [PATCH] Implement INSERT SET syntax |
Previous Message | Peter Eisentraut | 2020-03-24 18:26:52 | Re: Add A Glossary |