Setting libpq TCP keepalive parameters from environment

Поиск
Список
Период
Сортировка
От Oleksandr Shulgin
Тема Setting libpq TCP keepalive parameters from environment
Дата
Msg-id CACACo5SBUUiXcL6pPyNV8-V5YSjs1KidScD0mHuD7aub9oAwKg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Setting libpq TCP keepalive parameters from environment  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
Hi Hackers,

I didn't find the original discussion which led to introduction of the client-side set of keepalive parameters back in [1].

The issue I'm facing is that it doesn't seem to be possible to set these parameters from the environment variables.  The block of option definitions[2] added for these parameters doesn't specify any corresponding env var names.

I wonder if this is an oversight or was there a conscious decision not to allow it?

To give a specific example, I have a (legacy) Python script which talks to the database in two ways: by directly using psycopg2.connect(host=..., ) and also by running some shell commands with psql's \copy + gzip, mainly for convenience.

Now when I needed to tune the keepalives_idle value, I had to include it everywhere a database connection is made:
- For psycopg2 it's straightforward: you just add an extra keyword parameter to connect().
- For psql it's trickier, since the only way to achieve this seems to pack it together with -d as: -d 'dbname=mydb keepalives_idle=NNN'.

In case of a binary that would amount to recompiling, I guess.  I have no permission to tweak sysctl directly on the host, unfortunately.

It would be much more convenient to just set the environment variable when running the script and let it affect the whole process and its children.

Would a patch be welcome?

Regards,
--
Alex


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

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: Expression errors with "FOR UPDATE" and postgres_fdw withpartition wise join enabled.
Следующее
От: Pavlo Golub
Дата:
Сообщение: Re: Porting PG Extension from UNIX to Windows