From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | "Aya Iwata (Fujitsu)" <iwata(dot)aya(at)fujitsu(dot)com> |
Cc: | 'Peter Smith' <smithpb2250(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE |
Date: | 2025-10-16 03:54:31 |
Message-ID: | aPBsd2e2SqLs0Kdk@paquier.xyz |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Abhishek Chanda | 2025-10-16 03:56:47 | Re: Adding error messages to a few slash commands |
Previous Message | Michael Paquier | 2025-10-16 03:37:01 | Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE |