From: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
---|---|
To: | "Aya Iwata (Fujitsu)" <iwata(dot)aya(at)fujitsu(dot)com>, 'Peter Smith' <smithpb2250(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE |
Date: | 2025-10-07 11:49:13 |
Message-ID: | OSCPR01MB14966250768B6E74CE5207864F5E0A@OSCPR01MB14966.jpnprd01.prod.outlook.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Dear Iwata-san,
Thanks for updating the patch. Comments:
```
+ /* Check worker slot. */
+ if (!slot->in_use)
+ continue;
```
The comment has less meaning. How about:
"Skip if the slot is not used"
```
+ /* 1st, check cancel flags. */
+ if (slot->worker.bgw_flags & BGWORKER_EXIT_AT_DATABASE_DROP)
```
Missing update 2b [1]. Also, since cancel flag does not exist anymore, the comment should be
Updated. How about something like:
"Skip if the background worker does not want to exit"
```
+ /* 2nd, compare databaseId. */
+ if (proc && proc->databaseId == databaseId)
```
Here should describes what are you trying to do. How about something like:
Checks the connecting database of the worker, and instruct the postmaster to terminate it if needed
```
+ /*
+ * Cancel background workers by admin commands.
+ */
+ CancelBackgroundWorkers(databaseId);
```
Since we removed the flag, the comment is outdated.
```
-
typedef void (*bgworker_main_type) (Datum main_arg);
```
This change is not related with this patch.
```
@@ -361,7 +361,8 @@ _PG_init(void)
/* set up common data for all our workers */
memset(&worker, 0, sizeof(worker));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |
- BGWORKER_BACKEND_DATABASE_CONNECTION;
+ BGWORKER_BACKEND_DATABASE_CONNECTION |
+ BGWORKER_EXIT_AT_DATABASE_DROP;
```
The new flag was added to both static and dynamic background workers. So, how about
testing both? I think it is enough to use one of case, like ALTER DATABASE SET TABLESPACE.
Best regards,
Hayato Kuroda
FUJITSU LIMITED
From | Date | Subject | |
---|---|---|---|
Next Message | Hayato Kuroda (Fujitsu) | 2025-10-07 11:53:34 | RE: Newly created replication slot may be invalidated by checkpoint |
Previous Message | shveta malik | 2025-10-07 11:43:17 | Re: Improve pg_sync_replication_slots() to wait for primary to advance |