From: | Shichao Jin <jsc0218(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Spawned Background Process Knows the Exit of Client Process? |
Date: | 2020-05-15 18:22:49 |
Message-ID: | CABCoBcLgtY5TtW-S5s4WZUA0jXUXWAHEQ8Qu_4QUGeebGDx5eA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Postgres Hackers,
I am wondering is there any elegant way for self-spawned background process
(forked by us) to get notified when the regular client-connected process
exit from the current database (switch db or even terminate)?
The background is that we are integrating a thread-model based storage
engine into Postgres via foreign data wrapper. The engine is not allowed to
have multiple processes to access it. So we have to spawn a background
process to access the engine, while the client process can communicate with
the spawned process via shared memory. In order to let the engine recognize
the data type in Postgres, the spawned process has to access catalog such
as relcache, and It must connect to the target database
via BackgroundWorkerInitializeConnection to get the info. Unfortunately, it
is not possible to switch databases for background process. So it has to
get notified when client process switches db or terminate, then we can
correspondingly close the spawned process. Please advise us if there are
alternative approaches.
Best,
Shichao
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2020-05-15 18:36:20 | Re: calling procedures is slow and consumes extra much memory against calling function |
Previous Message | Alvaro Herrera | 2020-05-15 17:43:11 | Re: pg_stat_wal_receiver and flushedUpto/writtenUpto |