On 17 March 2015 at 19:12, Robert Haas <robertmh...@gmail.com> wrote:

> On Tue, Mar 17, 2015 at 1:33 AM, Amit Khandekar <amitdkhan...@gmail.com>
> wrote:
> > I think we either have to retain the knowledge that the worker has
> crashed
> > using some new field, or else, we should reset the crash time only if it
> is
> > not flagged BGW_NEVER_RESTART.
>
> I think you're right, and I think we should do the second of those.
> Thanks for tracking this down.
>

Thanks. Attached a patch accordingly. Put this into the June 2015
commitfest.
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 85a3b3a..1536691 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -397,9 +397,9 @@ BackgroundWorkerStopNotifications(pid_t pid)
 /*
  * Reset background worker crash state.
  *
- * We assume that, after a crash-and-restart cycle, background workers should
- * be restarted immediately, instead of waiting for bgw_restart_time to
- * elapse.
+ * We assume that, after a crash-and-restart cycle, background workers without
+ * the never-restart flag should be restarted immediately, instead of waiting
+ * for bgw_restart_time to elapse.
  */
 void
 ResetBackgroundWorkerCrashTimes(void)
@@ -411,7 +411,14 @@ ResetBackgroundWorkerCrashTimes(void)
 		RegisteredBgWorker *rw;
 
 		rw = slist_container(RegisteredBgWorker, rw_lnode, iter.cur);
-		rw->rw_crashed_at = 0;
+
+		/*
+		 * For workers that should not be restarted, we don't want to loose
+		 * the information that they have crashed, otherwise they would be
+		 * treated as new workers.
+		 */
+		if (rw->rw_worker.bgw_restart_time != BGW_NEVER_RESTART)
+			rw->rw_crashed_at = 0;
 	}
 }
 
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to