Problems with sequences - Mailing list pgsql-hackers

From Dave Cramer
Subject Problems with sequences
Date
Msg-id 004701c17444$63f7b1e0$8201a8c0@inspiron
Whole thread Raw
In response to Re: Benchmarks  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Problems with sequences
List pgsql-hackers
Hi,

I am running PostgreSQL 7.0.3 on a linux box.

My application uses java/persistence layer/jdbc which does the following
when inserting a row

1) gets a connection from the pool and gets a new id for the row using
select nextval('sequence');
2) returns the connection to the pool
3) gets another connection from the pool and inserts the data into the
row using the id retrieved in step 1
4) returns the connection to the pool

Recently we have had instances where the postmaster has 'crashed' and it
appears that the sequence numbers were not written to disk

After the postmaster restarts we have instances where there are rows in
the database with id's greater than the current sequence value. The
interesting part is that values are always different by 4?

In other words there is a row with an id 1004 and the sequence is
currently 1000?

We are running with fsync on. One thing that has changed lately is we
are running with quite a few buffers?

Any insight would be appreciated,

Dave



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: v7.2b3 packages rebuilt ...
Next
From: Lamar Owen
Date:
Subject: Re: v7.2b3 packaged, but not announced beyond here yet ...