Обсуждение: replication_timeout does not seem to be working

Поиск
Список
Период
Сортировка

replication_timeout does not seem to be working

От
A J
Дата:
On 9.1, Beta3 I set the following on master
replication_timeout = 10s       # in milliseconds; 0 disables

With no slaves running, I expect a failure in about 10s. But any Insert just hangs. Any idea ?

Thanks.

Re: replication_timeout does not seem to be working

От
Fujii Masao
Дата:
On Fri, Jul 22, 2011 at 5:14 AM, A J <s5aly@yahoo.com> wrote:
> On 9.1, Beta3 I set the following on master
> replication_timeout = 10s       # in milliseconds; 0 disables
> With no slaves running, I expect a failure in about 10s. But any Insert just
> hangs. Any idea ?

If you set up synchronous replication but there is no standby server,
all the write transactions are blocked infinitely whether replication_timeout
is enabled or not. If you want to cause those transactions to end, you need
to disable synchronous replication by, for example, emptying
synchronous_standby_names or need to set up new standby.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Re: replication_timeout does not seem to be working

От
A J
Дата:
I am still not clear. Can you explain what replication_timeout parameter accomplishes and when ?

Basically I wish my synchronous write transaction to not wait indefinitely when the synchronous standby servers are not available. But rather a response returned back to client that write could not be successful, after trying for 'n' seconds. How can that be accomplished ?

Thanks.




From: Fujii Masao <masao.fujii@gmail.com>
To: A J <s5aly@yahoo.com>
Cc: PG Admin <pgsql-admin@postgresql.org>
Sent: Friday, July 22, 2011 9:19 AM
Subject: Re: [ADMIN] replication_timeout does not seem to be working

On Fri, Jul 22, 2011 at 5:14 AM, A J <s5aly@yahoo.com> wrote:
> On 9.1, Beta3 I set the following on master
> replication_timeout = 10s       # in milliseconds; 0 disables
> With no slaves running, I expect a failure in about 10s. But any Insert just
> hangs. Any idea ?

If you set up synchronous replication but there is no standby server,
all the write transactions are blocked infinitely whether replication_timeout
is enabled or not. If you want to cause those transactions to end, you need
to disable synchronous replication by, for example, emptying
synchronous_standby_names or need to set up new standby.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


Re: replication_timeout does not seem to be working

От
Fujii Masao
Дата:
On Sat, Jul 23, 2011 at 1:11 AM, A J <s5aly@yahoo.com> wrote:
> I am still not clear. Can you explain what replication_timeout parameter
> accomplishes and when ?

If no reply is returned from the standby in replication_timeout, the
master thinks
that the connected standby is inactive, and terminates the replication
connection.
This is useful for the master to detect a standby crash or network outage.

> Basically I wish my synchronous write transaction to not wait indefinitely
> when the synchronous standby servers are not available. But rather a
> response returned back to client that write could not be successful, after
> trying for 'n' seconds. How can that be accomplished ?

There is no parameter for that purpose. You would need to implement
something like the monitor daemon which disable synchronous replication
when it detects a standby crash or network outage.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Re: replication_timeout does not seem to be working

От
Greg Smith
Дата:
On 07/22/2011 12:11 PM, A J wrote:
Basically I wish my synchronous write transaction to not wait indefinitely when the synchronous standby servers are not available. But rather a response returned back to client that write could not be successful, after trying for 'n' seconds. How can that be accomplished ?

You might be able to get what you want here by setting statement_timeout to 'n' seconds when doing a write transaction.

-- 
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us

Re: replication_timeout does not seem to be working

От
Fujii Masao
Дата:
On Wed, Jul 27, 2011 at 3:47 PM, Greg Smith <greg@2ndquadrant.com> wrote:
> On 07/22/2011 12:11 PM, A J wrote:
>
> Basically I wish my synchronous write transaction to not wait indefinitely
> when the synchronous standby servers are not available. But rather a
> response returned back to client that write could not be successful, after
> trying for 'n' seconds. How can that be accomplished ?
>
> You might be able to get what you want here by setting statement_timeout to
> 'n' seconds when doing a write transaction.

No. statement_timeout cannot cancel the transaction whose commit record has
already been written to local disk.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Re: replication_timeout does not seem to be working

От
alexondi
Дата:
>If no reply is returned from the standby in replication_timeout, the master
thinks
>that the connected standby is inactive, and terminates the replication
connection.
>This is useful for the master to detect a standby crash or network outage.

After that master commit current transaction with "local" synchronous_commit
or rollback?

And why I setup this parameter replication_timeout = 2s and my wal's thread
(on master and server are restarted within 2s)?

--
View this message in context:
http://postgresql.1045698.n5.nabble.com/replication-timeout-does-not-seem-to-be-working-tp4620827p4726014.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.

Re: replication_timeout does not seem to be working

От
Fujii Masao
Дата:
On Tue, Aug 23, 2011 at 5:49 PM, alexondi <alexondi@rambler.ru> wrote:
>>If no reply is returned from the standby in replication_timeout, the master
> thinks
>>that the connected standby is inactive, and terminates the replication
> connection.
>>This is useful for the master to detect a standby crash or network outage.
>
> After that master commit current transaction with "local" synchronous_commit
> or rollback?

Even after the timeout terminates replication connection, a transaction on the
master waits for its WAL to be replicated to at least one standby. If you want
to finish such a transaction, you have to disable synchronous replication (by
changing synchronous_commit or synchronous_standby_names), or start new
standby and wait for WAL to be replicated to that new standby.

> And why I setup this parameter replication_timeout = 2s and my wal's thread
> (on master and server are restarted within 2s)?

You are asking whether the master and standby are automatically restarted
within 2s after they crash? If so, No.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center