Re: [PATCH] Slight improvement of worker_spi.c example - Mailing list pgsql-hackers

From Julien Rouhaud
Subject Re: [PATCH] Slight improvement of worker_spi.c example
Date
Msg-id 20230603122803.jqp3iyv62yfzls4z@jrouhaud
Whole thread Raw
In response to Re: [PATCH] Slight improvement of worker_spi.c example  (Aleksander Alekseev <aleksander@timescale.com>)
Responses Re: [PATCH] Slight improvement of worker_spi.c example
List pgsql-hackers
On Sat, Jun 03, 2023 at 02:38:26PM +0300, Aleksander Alekseev wrote:
> Hi Julien,
>
> > I'm pretty sure that this is intentional.  The worker can be launched
> > dynamically and in that case it still needs a GUC for the naptime.
>
> The dynamic worker also is going to need worker_spi_database, however
> the corresponding GUC declaration is placed below the check.

Yes, and that's because that GUC is declared as PGC_POSTMASTER so you can't
declare such a GUC dynamically.
>
> Perhaps we should just say that the extension shouldn't be used
> without shared_preload_libraies. We are not testing whether it works
> in such a case anyway.

The patch that added the database name clearly was committed without bothering
testing that scenario, but it would be better to fix it and add some coverage
rather than remove some example of how to use dynamic bgworkers.  Maybe with a
assign hook to make sure it's never changed once assigned or something along
those lines.

That being said this module is really naive and has so many problems that I
don't think it's actually helpful as coding guidelines for anyone who wants to
create a non toy extension using bgworkers.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL 16 Beta 1 Released!
Next
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Slight improvement of worker_spi.c example