Re: [ADMIN] sequence numbers under pg concurrence model

From: scorpdaddy(at)hotmail(dot)com <scorpdaddy(at)hotmail(dot)com>
To: Frank Heikens <frankheikens(at)mac(dot)com>, pgsql-admin(at)postgresql(dot)org <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [ADMIN] sequence numbers under pg concurrence model
Date: 2011-02-24 20:05:39
Message-ID: BLU0-SMTP2079F8D94D338173DE7B63FCEDA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Wicked! Great answer. Thanks.

----- Reply message -----
From: "Frank Heikens" <frankheikens(at)mac(dot)com>
Date: Thu, Feb 24, 2011 3:54 pm
Subject: [ADMIN] sequence numbers under pg concurrence model
To: "scorpdaddy(at)hotmail(dot)com" <scorpdaddy(at)hotmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>

Op 24 feb 2011, om 20:49 heeft scorpdaddy(at)hotmail(dot)com het volgende geschreven:

> What is the expected behaviour of sequence numbers under pg > concurrence model?

From the manual:
Important: To avoid blocking concurrent transactions that obtain numbers from the same sequence, a nextval operation is never rolled back; that is, once a value has been fetched it is considered used, even if the transaction that did the nextval later aborts. This means that aborted transactions might leave unused "holes" in the sequence of assigned values. setval operations are never rolled back, either.

http://www.postgresql.org/docs/current/static/functions-sequence.html

> E.g. Uncommitted transaction 1 in progress has inserted 5 tuples > into table foo. Meanwhile uncommitted transaction 2 in progress > inserts 100 tuples into table foo. If the sequence number for the > pk started at 1000 before these transactions, what are the sequence > numbers for transaction 1, 2, and the final sequence number if they > both commit? One rollback's? Both rollback? One hangs open while > the other commits? One hang and one rollback's?
>

Frank Heikens

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2011-02-24 20:56:56 Re: Error stopping postgresql service
Previous Message Scott Mead 2011-02-24 20:02:03 Re: transaction wraparound