Spawned Background Process Knows the Exit of Client Process?

Поиск
Список
Период
Сортировка
От Shichao Jin
Тема Spawned Background Process Knows the Exit of Client Process?
Дата
Msg-id CABCoBcLgtY5TtW-S5s4WZUA0jXUXWAHEQ8Qu_4QUGeebGDx5eA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Spawned Background Process Knows the Exit of Client Process?  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Список 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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pg_stat_wal_receiver and flushedUpto/writtenUpto
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: calling procedures is slow and consumes extra much memory againstcalling function