Re: Patch: Implement failover on libpq connect level.

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Patch: Implement failover on libpq connect level.
Дата
Msg-id CAMsr+YHujWgtQQohY1d_iEVaX2WvW9jDE4R+iWZrY0J9-7dnXg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Patch: Implement failover on libpq connect level.  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Patch: Implement failover on libpq connect level.
Список pgsql-hackers
On 17 November 2016 at 10:57, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Nov 16, 2016 at 9:00 PM, Tsunakawa, Takayuki
> <tsunakawa.takay@jp.fujitsu.com> wrote:
>> Do we really want to enable libpq failover against pre-V10 servers?  I don't think so, as libpq is a part of
PostgreSQLand libpq failover is a new feature in PostgreSQL 10.  At least, as one user, I don't want PostgreSQL to
sacrificeanother round trip to establish a connection.  As a developer, I don't want libpq code more complex than
necessary(the proposed patch adds a new state to the connection state machine.)  And I think it's natural for the
serverto return the server attribute (primary/standby, writable, etc.) as a response to the Startup message like
server_version,standard_conforming_strings and server_encoding. 
>
> Well, generally speaking, a new feature that works against older
> server is better than one that doesn't.  Of course, if that entails
> making other compromises then you have to decide whether it's worth
> it, but SELECT pg_is_in_recovery() and SHOW transaction_read_only
> exist in older versions so if we pick either of those methods then it
> will just work.  If we decide to invent some completely new method of
> distinguishing masters from standbys, then it might not, but that
> would be a drawback of such a choice, not a benefit.

We can and probably should have both.

If the server tells us on connect whether it's a standby or not, use that.

Otherwise, ask it.

That way we don't pay the round-trip cost and get the log spam when
talking to newer servers that send us something useful in the startup
packet, but we can still query it on older servers. Graceful fallback.

Every round trip is potentially very expensive. Having libpq do them
unnecessarily is bad.

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Use procsignal_sigusr1_handler and RecoveryConflictInterrupt() from walsender?
Следующее
От: Etsuro Fujita
Дата:
Сообщение: Re: Push down more UPDATEs/DELETEs in postgres_fdw