Re: [HACKERS] Slony-I goes BETA (possible bug)

From: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: Slony-I Mailing List <slony1-general(at)gborg(dot)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL advocacy <pgsql-advocacy(at)postgresql(dot)org>
Subject: Re: [HACKERS] Slony-I goes BETA (possible bug)
Date: 2004-06-06 09:21:14
Message-ID: 1086513674.13110.405.camel@jeff
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general pgsql-hackers


I have two nodes, node 1 and node 2.

Both are working with node 1 as the master, and data from subscribed
tables is being properly replicated to node 2.

However, it looks like there's a possible bug with sequences. First let
me explain that I don't entirely understand how a replicated sequence is
expected to behave, but as far as this report is concerned, I assume
that if you do a nextval() on node 1, than "SELECT last_value FROM
test_seq" on node 2 will return the updated value.

It looks like the sequence value is not updated on node 2, until some
other event happens, like doing an UPDATE on a replicated table on node
1.

I already have a table "t2" which is properly replicating.

So, here's what I give to slonik to add the sequence to set 1:
slonik <<_EOF_
cluster name = $CLUSTER;

node 1 admin conninfo = 'dbname=$DBNAME1 host=$HOST1 user=$SLONY_USER';
node 2 admin conninfo = 'dbname=$DBNAME2 host=$HOST2 user=$SLONY_USER';

create set (id=34, origin=1, comment='set 34');
set add sequence (set id = 34, origin = 1, id = 35, full qualified
name='public.test_seq', comment = 'sequence test');

subscribe set (id=34,provider=1,receiver=2,forward=no);

merge set (id=1,add id = 34, origin=1);

subscribe set (id=1,provider=1,receiver=2,forward=no);
_EOF_

Note: results of the query are put after the "--" following the query
for easier readability.

node1=> SELECT last_value FROM test_seq; -- 1
node2=> SELECT last_value FROM test_seq; -- 1
node1=> SELECT nextval('test_seq'); -- 1
node1=> SELECT nextval('test_seq'); -- 2
node1=> SELECT nextval('test_seq'); -- 3
node1=> SELECT last_value FROM test_seq; -- 3
node2=> SELECT last_value FROM test_seq; -- 1
node2=> -- wait for a long time, still doesn't update
node2=> SELECT last_value FROM test_seq; -- 1
node1=> INSERT INTO t2(a) VALUES('string');
node2=> SELECT last_value FROM test_seq; -- 3
node2=> -- now it's updated!

So, that looks like a possible bug where a nextval() call doesn't
trigger the replication. But it does appear to replicate after an
unrelated event triggers the replication (in this case an update to t2,
an unrelated table).

If not, what is the expected behavior of replicated sequences anyway? It
seems you couldn't call nextval() from a slave node, and because of that
you also can't make use of currval(). It looks like the slaves can
really only get the "SELECT last_value FROM test_seq". So is there a
particular use case someone had in mind when implementing the "SET ADD
SEQUENCE" for slonik?

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Jan Wieck 2004-06-06 17:32:12 Re: [HACKERS] Slony-I goes BETA (possible bug)
Previous Message David Garamond 2004-06-06 06:42:52 Re: [HACKERS] Not 7.5, but 8.0 ?

Browse pgsql-general by date

  From Date Subject
Next Message pgsql 2004-06-06 14:02:06 Re: Why hash indexes suck
Previous Message zhicheng wang 2004-06-06 09:17:55 Re: pg_class could not be found

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2004-06-06 09:34:01 pgsql 7.5 frontend changes wrapup
Previous Message David Garamond 2004-06-06 06:42:52 Re: [HACKERS] Not 7.5, but 8.0 ?