Re: Streaming replication: sequences on slave seemingly ahead of sequences on master

From: Michael Nolan <htfoot(at)gmail(dot)com>
To: Vincent de Phily <vincent(dot)dephily(at)mobile-devices(dot)fr>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-general(at)postgresql(dot)org, benjamin(dot)vialle(at)mobile-devices(dot)fr
Subject: Re: Streaming replication: sequences on slave seemingly ahead of sequences on master
Date: 2012-05-07 13:52:56
Message-ID: CAOzAqu+yuSTFgp41PQ4KSrP5x+CO+y+m7d7dh5Qa-bPEp8ybbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 7, 2012 at 4:01 AM, Vincent de Phily <
vincent(dot)dephily(at)mobile-devices(dot)fr> wrote:

> On Sunday 06 May 2012 10:29:17 Simon Riggs wrote:
> > On 4 May 2012 14:55, Vincent de Phily <vincent(dot)dephily(at)mobile-devices(dot)fr
> >
> wrote:
>
>
> Would be nice to see it added to the documentation (unless I just didn't
> find
> it ?), as it is quite surprising, and might lead to problems if people
> expect
> to be able to read sequence values from the slave.
>

What people need to understand is that there is no way to 'read' a sequence
value from a slave. 'SELECT * from sequence_name' will not reliably give
you either the most recently assigned or the next sequence value. This is
currently covered in the documentation for sequences, but could probably be
improved upon and mentioned somewhere in the documentation on setting up
slave servers. (I will look at adding it to the binary replication
tutorial wiki page.)

Since 'nextval' cannot be called on a sequence on a slave (because a slave
can only support read-only transactions), 'currval' will by definition
return an error.

To cross-pollinate with another thread, if temporary tables (and
insert/delete/update transactions to them) are to be supported on a slave,
will the applications using those temporary tables expect to be able to use
'nextval' on inserts to temporary tables as well?

> As a bonus question, I guess it would be the same if using synchroneous
> replication ?
>

Yes.
--
Mike Nolan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fujii Masao 2012-05-07 13:59:24 Re: Streaming replication: sequences on slave seemingly ahead of sequences on master
Previous Message Tom Lane 2012-05-07 13:33:45 Re: Streaming replication: sequences on slave seemingly ahead of sequences on master