How to only auto-restart BGW only on crash or _PG_init
| От | Jeremy Finzel | 
|---|---|
| Тема | How to only auto-restart BGW only on crash or _PG_init | 
| Дата | |
| Msg-id | CAMa1XUgOYEL1XQ46iHY6ASvtnbw-xPkDF7iYEUB1R+B026xHLA@mail.gmail.com обсуждение исходный текст  | 
		
| Ответы | 
                	
            		Re: How to only auto-restart BGW only on crash or _PG_init
            		
            		 | 
		
| Список | 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:
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
В списке pgsql-hackers по дате отправления: