Re: Extensibility of the PostgreSQL wire protocol

Jan Wieck <jan@wi3ck.info>

From: Jan Wieck <jan@wi3ck.info>
To: Heikki Linnakangas <hlinnaka@iki.fi>, Damir Simunic <damir.simunic@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, "Jonah H. Harris" <jonah.harris@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-02-24T15:46:54Z
Lists: pgsql-hackers
On 2/19/21 10:13 AM, Jan Wieck wrote:

> Give the function, that postmaster is calling to accept a connection
> when a server_fd is ready, a return code that it can use to tell
> postmaster "forget about it, don't fork or do anything else with it".
> This function is normally calling StreamConnection() before the
> postmaster then forks the backend. But it could instead hand over the
> socket to the pool background worker (I presume Jonah is transferring
> them from process to process via UDP packet). The pool worker is then
> launching the actual backends which receive a requesting client via the
> same socket transfer to perform one or more transactions, then hand the
> socket back to the pool worker.

The function in question, which is StreamConnection() and with this 
patch can be replaced with an extension funtion via the fn_accept 
pointer, already has that capability. If StreamConnection() or its 
replacement returns a NULL pointer, the postmaster just skips calling 
BackendStartup(). So everything is already in place for the above to work.


Regards, Jan

-- 
Jan Wieck
Principle Database Engineer
Amazon Web Services