Re: How to deinitialize a connection for background worker - Mailing list pgsql-hackers

From Tom Lane
Subject Re: How to deinitialize a connection for background worker
Date
Msg-id 3357370.1737479891@sss.pgh.pa.us
Whole thread Raw
In response to How to deinitialize a connection for background worker  ("ISHAN CHHANGANI ." <f20200230h@alumni.bits-pilani.ac.in>)
List pgsql-hackers
"ISHAN CHHANGANI ." <f20200230h@alumni.bits-pilani.ac.in> writes:
> I am working on a project which requires me to create a background worker. This worker checks some array(shared
memory)every second and then connects to the database mentioned within the array. That is I want to connect to
differentdatabases using the same background worker without killing it. 

You can't really.  There is no part of our catalog-access
infrastructure that is designed to support this, and there are bits of
cached state all over the system that will misbehave if you try.
You found some of it, but there is plenty more.

I'd suggest letting the worker process die and spawning a new one
if you need to redirect its efforts to a new database.  If that
seems too expensive, rethink the design that requires you to do it.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Orphaned users in PG16 and above can only be managed by Superusers
Next
From: Marcos Pegoraro
Date:
Subject: Re: Year of first commit