[pgpool-hackers: 46] Re: Implementing SERIAL rewriting
Tatsuo Ishii
ishii at postgresql.org
Wed Mar 21 18:11:47 JST 2012
>> One problem I could forsee is:
>>
>> Suppose we have two different session A and B to pgpool. It is
>> possible that following order of SQL execution could happen:
>>
>> A: SELECT nextval('t1_i_seq'); -- suppose this returns 100
>> B: SELECT nextval('t1_i_seq'); -- suppose this returns 101
>> A: INSERT INTO t1 VALUES(100, 1); -- on the master and slaves
>> B: INSERT INTO t1 VALUES(101, 1); -- on the master and slaves
>> B: SELECT setval('t1_i_seq', 101); -- on the slaves
>> A: SELECT setval('t1_i_seq', 100); -- on the slaves
>>
>> In this scenario, the sequence' value results in 101 on the master, on
>> the other hand 100 on the slaves. Any idea how to prevent this?
>
>
> My idea is, at slave, before set the value, check if current value is
> bigger than the given one.
How do you get the current sequence value without
incrementing(i.e. nextval()) the sequence value?
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
More information about the pgpool-hackers
mailing list