From eb21f5bc67a02eb6f7de1bd2f07acdd471a4d320 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 2 Jul 2024 20:14:40 +0300 Subject: [PATCH] Remove redundant SetProcessingMode(InitProcessing) calls After several refactoring iterations, auxiliary processes are no longer initialized from the bootstrapper. Using the InitProcessing mode for initializing auxiliary processes is more appropriate. Since the global variable Mode is initialized to InitProcessing, we can just remove the redundant calls of SetProcessingMode(InitProcessing). Author: Xing Guo Discussion: https://www.postgresql.org/message-id/CACpMh%2BDBHVT4xPGimzvex%3DwMdMLQEu9PYhT%2BkwwD2x2nu9dU_Q%40mail.gmail.com --- src/backend/postmaster/autovacuum.c | 4 ++-- src/backend/postmaster/auxprocess.c | 3 ++- src/backend/postmaster/bgworker.c | 2 +- src/backend/replication/logical/slotsync.c | 2 +- src/backend/tcop/postgres.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 9a925a10cd..928754b51c 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -380,7 +380,7 @@ AutoVacLauncherMain(char *startup_data, size_t startup_data_len) if (PostAuthDelay) pg_usleep(PostAuthDelay * 1000000L); - SetProcessingMode(InitProcessing); + Assert(GetProcessingMode() == InitProcessing); /* * Set up signal handlers. We operate on databases much like a regular @@ -1373,7 +1373,7 @@ AutoVacWorkerMain(char *startup_data, size_t startup_data_len) MyBackendType = B_AUTOVAC_WORKER; init_ps_display(NULL); - SetProcessingMode(InitProcessing); + Assert(GetProcessingMode() == InitProcessing); /* * Set up signal handlers. We operate on databases much like a regular diff --git a/src/backend/postmaster/auxprocess.c b/src/backend/postmaster/auxprocess.c index 78f4263eeb..b21eae7136 100644 --- a/src/backend/postmaster/auxprocess.c +++ b/src/backend/postmaster/auxprocess.c @@ -54,7 +54,8 @@ AuxiliaryProcessMainCommon(void) init_ps_display(NULL); - SetProcessingMode(BootstrapProcessing); + Assert(GetProcessingMode() == InitProcessing); + IgnoreSystemIndexes = true; /* diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index 13dc2cf064..77707bb384 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -746,7 +746,7 @@ BackgroundWorkerMain(char *startup_data, size_t startup_data_len) MyBackendType = B_BG_WORKER; init_ps_display(worker->bgw_name); - SetProcessingMode(InitProcessing); + Assert(GetProcessingMode() == InitProcessing); /* Apply PostAuthDelay */ if (PostAuthDelay > 0) diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c index e7738f2ea6..fe2f07cf44 100644 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@ -1342,7 +1342,7 @@ ReplSlotSyncWorkerMain(char *startup_data, size_t startup_data_len) init_ps_display(NULL); - SetProcessingMode(InitProcessing); + Assert(GetProcessingMode() == InitProcessing); /* * Create a per-backend PGPROC struct in shared memory. We must do this diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index adf71c6902..e39c6804a7 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4161,7 +4161,7 @@ PostgresMain(const char *dbname, const char *username) Assert(dbname != NULL); Assert(username != NULL); - SetProcessingMode(InitProcessing); + Assert(GetProcessingMode() == InitProcessing); /* * Set up signal handlers. (InitPostmasterChild or InitStandaloneProcess