Re: Bug #613: Sequence values fall back to previously checkpointed

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Bug #613: Sequence values fall back to previously checkpointed
Дата
Msg-id 200203122346.g2CNkpD20962@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: Bug #613: Sequence values fall back to previously checkpointed  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Bug #613: Sequence values fall back to previously checkpointed  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > bgrimm@zaeon.com wrote:
> >> the sequence again.  Kill -9 the postmaster.  Tried to insert into the
> >> table, but to no avail... duplicate key.  currval of the sequence and
> >> it matched the value right after the checkpoint.  I've been able to
> >> duplicate that scenario several times.
>
> > I just tested it here by doing a similar test of several nextval()
> > calls, but then doing an INSERT and kill, and on restart, the sequence
> > counter did have the proper value.
>
> There have been prior reports of similar problems --- all quite
> unrepeatable in my testing, and despite considerable study of the source
> code I can't see how it could happen.  A reproducible test case would be
> a tremendous help.


I can confirm repeatable case!

---------------------------------------------------------------------------

test=> create table test (x serial, y varchar(255));
NOTICE:  CREATE TABLE will create implicit sequence 'test_x_seq' for SERIAL column 'test.x'
NOTICE:  CREATE TABLE / UNIQUE will create implicit index 'test_x_key' for table 'test'
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32951 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32951 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32951 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32951 1
...

test=> select nextval('test_x_seq');
 nextval
---------
      41
(1 row)

test=> checkpoint;
CHECKPOINT
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32991 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32992 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32992 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32992 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');
INSERT 32992 1
test=> insert into test (y) values ('lkjasdflkja sdfl;kj asdfl;kjasdf');


[ kill -9 backend ]


$ sql test
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

test=> select nextval('test_x_seq');
 nextval
---------
      42
(1 row)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug #613: Sequence values fall back to previously checkpointed
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Bug #613: Sequence values fall back to previously checkpointed