agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Álvaro Herrera <[email protected]>
Subject: [PATCH v7 3/3] Fixup: assign backend type earlier
Date: Tue, 9 Dec 2025 09:53:01 +0100

---
 src/backend/postmaster/launch_backend.c | 3 +++
 src/backend/utils/error/elog.c          | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/backend/postmaster/launch_backend.c b/src/backend/postmaster/launch_backend.c
index 35420b8c9fb..96624e08b5a 100644
--- a/src/backend/postmaster/launch_backend.c
+++ b/src/backend/postmaster/launch_backend.c
@@ -588,6 +588,8 @@ SubPostmasterMain(int argc, char *argv[])
 	IsPostmasterEnvironment = true;
 	whereToSendOutput = DestNone;
 
+	MyBackendType = B_BACKEND;
+
 	/*
 	 * Capture the end of process creation for logging. We don't include the
 	 * time spent copying data from shared memory and setting up the backend.
@@ -611,6 +613,7 @@ SubPostmasterMain(int argc, char *argv[])
 		if (strcmp(child_process_kinds[idx].name, child_kind) == 0)
 		{
 			child_type = (BackendType) idx;
+			MyBackendType = child_type;
 			found = true;
 			break;
 		}
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 15d771a16c9..d7f4a44c5a7 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2779,7 +2779,12 @@ get_backend_type_for_log(void)
 	if (MyProcPid == PostmasterPid)
 		backend_type_str = "postmaster";
 	else if (MyBackendType == B_BG_WORKER)
-		backend_type_str = MyBgworkerEntry->bgw_type;
+	{
+		if (MyBgworkerEntry && MyBgworkerEntry->bgw_type[0] != '\0')
+			backend_type_str = MyBgworkerEntry->bgw_type;
+		else
+			backend_type_str = "early bgworker";
+	}
 	else
 		backend_type_str = GetBackendTypeDesc(MyBackendType);
 
-- 
2.47.3


--grg2fqqi6tkdt5me--





view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v7 3/3] Fixup: assign backend type earlier
  In-Reply-To: <no-message-id-32861@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox