Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
| От | Michael Paquier |
|---|---|
| Тема | Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE |
| Дата | |
| Msg-id | aPBsd2e2SqLs0Kdk@paquier.xyz обсуждение исходный текст |
| Ответ на | RE: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE ("Aya Iwata (Fujitsu)" <iwata.aya@fujitsu.com>) |
| Ответы |
RE: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
|
| Список | pgsql-hackers |
On Wed, Oct 15, 2025 at 02:48:43AM +0000, Aya Iwata (Fujitsu) wrote: > Thank you for your comments. I updated this patch to v0007. + * Exit the bgworker when its database is dropped, renamed, moved to a + * different tablespace, or used as a template for CREATE DATABASE. I don't think that we need to list all these operations in details here. We could just say "if its database is involved in a CREATE, ALTER or DROP database command". The docs should provide these details, of course. +#define BGWORKER_EXIT_AT_DATABASE_CHANGE 0x0004 Flag name works here. # XXX This spends more than 5 seconds because the backend retries counting # number of connecting processes 50 times. See CountOtherDBBackends(). And that's annoying. Let's activate what I call the cheat mode for this one: an injection point that, if defined, enforces a lower number of tries when we loop over the workers to stop. That would make the test much faster when using a worker that should not be stopped, without impacting the coverage. I suspect that your new test 002_worker_terminate.pl has a race condition in run_db_command(): are you sure that the bgworker has enough time to be reported as stopped in the server logs once safe_psql() finishes to run the database command given by the caller? On very slow and/or loaded machines, particularly, that could hurt the stability. It seems to me that this should use a wait_for_log() instead of a log_contains(), waiting for the worker to be reported as stopped depending on the command executed. Shouldn't this test also check that worker 0 (the one that does not have the flag set) is still running at the end of the test? I assume that querying pg_stat_activity would be enough at the end of the script. -- Michael
Вложения
В списке pgsql-hackers по дате отправления: