Re: Sequencing Problem in Transaction..

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bhuvan A <bhuvansql(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sequencing Problem in Transaction..
Date: 2002-02-12 17:16:57
Message-ID: 200202121716.g1CHGvr26397@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bhuvan A wrote:
>
>
> On Feb 12, Christopher Kings-Lynne wrote:
>
> > Ummm...this is not a bug - it is utterly essential that sequences are not
> > rolled back!!!
> >
> > Think about this:
> >
> > Sequence counter is 9
> > Transaction 1 gets sequence no. 10
> > Transaction 2 gets sequence no. 11
> > transaction 1 rolls back, sequence no. reset to 9
> > Transaction 3 gets sequence number 10
> > Transaction 4 gets sequence number 11 - BAM!!!
> >
> Good and Thankx!!!

Believe it or not, this _wasn't_ in the FAQ, though it certainly is
asked enough times. Added now as item 4.15.4:

4.15.4) Why aren't my sequence numbers reused on transaction abort? Why are
there gaps in the numbering of my sequence/SERIAL column?

To improve concurrency, sequence values are given out to running
transactions as needed and are not locked until the transaction
completes. This causes gaps in numbering from aborted transactions.

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew G. Hammond 2002-02-12 17:40:10 Re: SQL request to retrieve the type of columns
Previous Message Josh Berkus 2002-02-12 16:22:54 Re: Storing text data in databases.