v1-0002-Fix-bgw-not-starting-after-restart_after_crash.patch

text/x-patch

Filename: v1-0002-Fix-bgw-not-starting-after-restart_after_crash.patch
Type: text/x-patch
Part: 1
Message: Fix background workers not restarting with restart_after_crash = on

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: format-patch
Series: patch v1-0002
Subject: Fix bgw not starting after restart_after_crash
File+
src/backend/postmaster/postmaster.c 1 1
From 4b01649d52fac9b01566a7a569f27bf3e06841bb Mon Sep 17 00:00:00 2001
From: Andrey Rudometov <unlimitedhikari@gmail.com>
Date: Wed, 11 Jun 2025 11:18:45 +0700
Subject: [PATCH v1 2/2] Fix bgw not starting after restart_after_crash

If postgres assumes child as crashed and said child is background
worker, and restart_after_crash is set - this bgw's local data
won't be cleared; p.e. rw_pid will remain set, so this bgw won't
be restarted later.
---
 src/backend/postmaster/postmaster.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 2d99f9d670d..b6d46cd84a7 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2633,7 +2633,7 @@ CleanupBackend(PMChild *bp,
 	if (crashed)
 	{
 		HandleChildCrash(bp_pid, exitstatus, procname);
-		return;
+		logged = true;
 	}
 
 	/*
-- 
2.43.0