smart_shutdown_bugfix_v1.patch

application/octet-stream

Filename: smart_shutdown_bugfix_v1.patch
Type: application/octet-stream
Part: 0
Message: Re: pending patch: Re: HS/SR and smart shutdown

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
Series: patch v1
File+
src/backend/postmaster/postmaster.c 15 0
*** a/src/backend/postmaster/postmaster.c
--- b/src/backend/postmaster/postmaster.c
***************
*** 2163,2168 **** pmdie(SIGNAL_ARGS)
--- 2163,2183 ----
  			ereport(LOG,
  					(errmsg("received smart shutdown request")));
  
+ 			/*
+ 			 * If there is no WAL file available in the standby, walreceiver
+ 			 * might be invoked before we have reached the PM_RECOVERY state.
+ 			 * In this case, since it's guaranteed that we have no regular
+ 			 * backend, we can kill walreceiver right now and don't need to
+ 			 * switch to the PM_WAIT_READONLY state.
+ 			 */
+ 			if (pmState == PM_INIT || pmState == PM_STARTUP)
+ 			{
+ 				if (StartupPID != 0)
+ 					signal_child(StartupPID, SIGTERM);
+ 				if (WalReceiverPID != 0)
+ 					signal_child(WalReceiverPID, SIGTERM);
+ 			}
+ 
  			if (pmState == PM_RUN || pmState == PM_RECOVERY ||
  				pmState == PM_RECOVERY_CONSISTENT)
  			{