pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6258: Lock Sequence
8+ messages / 5 participants
[nested] [flat]
* BUG #6258: Lock Sequence
@ 2011-10-17 13:08 Laerson Keler <laerson.keler@lkmc.com.br>
0 siblings, 1 reply; 8+ messages in thread
From: Laerson Keler @ 2011-10-17 13:08 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 6258
Logged by: Laerson Keler
Email address: laerson.keler@lkmc.com.br
PostgreSQL version: 8.4.9
Operating system: Ubuntu 10.04 - Kernel 2.6.32-34
Description: Lock Sequence
Details:
Dear Srs, good morning, I did the automatic update postgresql 8.4.9 and
a function stopped working, I used the option select for update
in a sequence and is now giving the following error "can not lock rows in
sequence ...", how can I enable the blocking of the sequence?
Already grateful for the attention.
Thank you.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-17 15:52 Tom Lane <tgl@sss.pgh.pa.us>
parent: Laerson Keler <laerson.keler@lkmc.com.br>
0 siblings, 2 replies; 8+ messages in thread
From: Tom Lane @ 2011-10-17 15:52 UTC (permalink / raw)
To: Laerson Keler <laerson.keler@lkmc.com.br>; +Cc: pgsql-bugs
"Laerson Keler" <laerson.keler@lkmc.com.br> writes:
> Dear Srs, good morning, I did the automatic update postgresql 8.4.9 and
> a function stopped working, I used the option select for update
> in a sequence and is now giving the following error "can not lock rows in
> sequence ...", how can I enable the blocking of the sequence?
Why did you do that, that is what were you trying to accomplish? It
never did block nextval() on the sequence, for example.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-17 18:03 Laerson keler <laerson.keler@lkmc.com.br>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 8+ messages in thread
From: Laerson keler @ 2011-10-17 18:03 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
Tom Lane, good afternoon, I block the sequence not to miss the sequel, for
it not to be skipped if the insert to fail. My logic involves two triggers,
one before and one after. I give the first one in last_value select for
update in the sequence and insert after I run a select next_val ('sequence')
to place in the next issue, so the sequence in my table is no failure.
Already grateful for the attention.
Thank you.
[]Laerson Keler
laerson.keler@lkmc.com.br
Cel: 11 9914-4030
Res: 11 3404-4632
2011/10/17 Tom Lane <tgl@sss.pgh.pa.us>
> "Laerson Keler" <laerson.keler@lkmc.com.br> writes:
> > Dear Srs, good morning, I did the automatic update postgresql 8.4.9 and
> > a function stopped working, I used the option select for update
> > in a sequence and is now giving the following error "can not lock rows in
> > sequence ...", how can I enable the blocking of the sequence?
>
> Why did you do that, that is what were you trying to accomplish? It
> never did block nextval() on the sequence, for example.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-17 19:13 Euler Taveira de Oliveira <euler@timbira.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 8+ messages in thread
From: Euler Taveira de Oliveira @ 2011-10-17 19:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Laerson Keler <laerson.keler@lkmc.com.br>; pgsql-bugs
On 17-10-2011 12:52, Tom Lane wrote:
> "Laerson Keler"<laerson.keler@lkmc.com.br> writes:
>> Dear Srs, good morning, I did the automatic update postgresql 8.4.9 and
>> a function stopped working, I used the option select for update
>> in a sequence and is now giving the following error "can not lock rows in
>> sequence ...", how can I enable the blocking of the sequence?
>
You can't. It was disabled [1].
> Why did you do that, that is what were you trying to accomplish? It
> never did block nextval() on the sequence, for example.
>
Maybe he is using an old pgpool-II version?
[1]
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=21538377ee6a0ee91f756726bd8b3de6d19fd2...
--
Euler Taveira de Oliveira - Timbira http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-17 19:43 Tom Lane <tgl@sss.pgh.pa.us>
parent: Laerson keler <laerson.keler@lkmc.com.br>
0 siblings, 2 replies; 8+ messages in thread
From: Tom Lane @ 2011-10-17 19:43 UTC (permalink / raw)
To: Laerson keler <laerson.keler@lkmc.com.br>; +Cc: pgsql-bugs
Laerson keler <laerson.keler@lkmc.com.br> writes:
> 2011/10/17 Tom Lane <tgl@sss.pgh.pa.us>
>> "Laerson Keler" <laerson.keler@lkmc.com.br> writes:
>> Why did you do that, that is what were you trying to accomplish? It
>> never did block nextval() on the sequence, for example.
> Tom Lane, good afternoon, I block the sequence not to miss the sequel, for
> it not to be skipped if the insert to fail. My logic involves two triggers,
> one before and one after. I give the first one in last_value select for
> update in the sequence and insert after I run a select next_val ('sequence')
> to place in the next issue, so the sequence in my table is no failure.
Well, that's a cute idea, but the fact is that it was always quite
unsafe because it had no interlock against nextval(). Moreover, you
still did not have a guarantee of no holes in the assigned ID values,
because the transaction could still fail after the AFTER trigger runs.
There really is not any way to generate guaranteed-hole-free sequences
using sequence objects. If you have to have that, I'd suggest locking
the table against other writes and then fetching MAX(id) + 1. It's not
very fast, and it's not at all concurrent, but that's the price of
ensuring no holes. Personally I'd rethink how badly you need that
property.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-17 20:55 Jaime Casanova <jaime@2ndquadrant.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 8+ messages in thread
From: Jaime Casanova @ 2011-10-17 20:55 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Laerson keler <laerson.keler@lkmc.com.br>; pgsql-bugs
On Mon, Oct 17, 2011 at 2:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> There really is not any way to generate guaranteed-hole-free sequences
> using sequence objects. If you have to have that, I'd suggest locking
> the table against other writes and then fetching MAX(id) + 1. It's not
> very fast, and it's not at all concurrent, but that's the price of
> ensuring no holes. Personally I'd rethink how badly you need that
> property.
>
another option is to create a table to use as a sequence, and lock
that table everytime you need a new value... is not concurrent also,
but at least faster... unless i'm missing something
--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-18 09:15 Laerson keler <laerson.keler@lkmc.com.br>
parent: Jaime Casanova <jaime@2ndquadrant.com>
0 siblings, 0 replies; 8+ messages in thread
From: Laerson keler @ 2011-10-18 09:15 UTC (permalink / raw)
To: Jaime Casanova <jaime@2ndquadrant.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
good idea. I will try.
Thank you.
[]Laerson Keler
laerson.keler@lkmc.com.br
Cel: 11 9914-4030
Res: 11 3404-4632
2011/10/17 Jaime Casanova <jaime@2ndquadrant.com>
> On Mon, Oct 17, 2011 at 2:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >
> > There really is not any way to generate guaranteed-hole-free sequences
> > using sequence objects. If you have to have that, I'd suggest locking
> > the table against other writes and then fetching MAX(id) + 1. It's not
> > very fast, and it's not at all concurrent, but that's the price of
> > ensuring no holes. Personally I'd rethink how badly you need that
> > property.
> >
>
> another option is to create a table to use as a sequence, and lock
> that table everytime you need a new value... is not concurrent also,
> but at least faster... unless i'm missing something
>
> --
> Jaime Casanova www.2ndQuadrant.com
> Professional PostgreSQL: Soporte 24x7 y capacitación
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: BUG #6258: Lock Sequence
@ 2011-10-18 09:16 Laerson keler <laerson.keler@lkmc.com.br>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 8+ messages in thread
From: Laerson keler @ 2011-10-18 09:16 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
I changed the logic of the trigger, I'm using before and taking the next_val
().
Thank you.
[]Laerson Keler
laerson.keler@lkmc.com.br
Cel: 11 9914-4030
Res: 11 3404-4632
2011/10/17 Tom Lane <tgl@sss.pgh.pa.us>
> Laerson keler <laerson.keler@lkmc.com.br> writes:
> > 2011/10/17 Tom Lane <tgl@sss.pgh.pa.us>
> >> "Laerson Keler" <laerson.keler@lkmc.com.br> writes:
> >> Why did you do that, that is what were you trying to accomplish? It
> >> never did block nextval() on the sequence, for example.
>
> > Tom Lane, good afternoon, I block the sequence not to miss the sequel,
> for
> > it not to be skipped if the insert to fail. My logic involves two
> triggers,
> > one before and one after. I give the first one in last_value select for
> > update in the sequence and insert after I run a select next_val
> ('sequence')
> > to place in the next issue, so the sequence in my table is no failure.
>
> Well, that's a cute idea, but the fact is that it was always quite
> unsafe because it had no interlock against nextval(). Moreover, you
> still did not have a guarantee of no holes in the assigned ID values,
> because the transaction could still fail after the AFTER trigger runs.
>
> There really is not any way to generate guaranteed-hole-free sequences
> using sequence objects. If you have to have that, I'd suggest locking
> the table against other writes and then fetching MAX(id) + 1. It's not
> very fast, and it's not at all concurrent, but that's the price of
> ensuring no holes. Personally I'd rethink how badly you need that
> property.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2011-10-18 09:16 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 13:08 BUG #6258: Lock Sequence Laerson Keler <laerson.keler@lkmc.com.br>
2011-10-17 15:52 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-17 18:03 ` Laerson keler <laerson.keler@lkmc.com.br>
2011-10-17 19:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-17 20:55 ` Jaime Casanova <jaime@2ndquadrant.com>
2011-10-18 09:15 ` Laerson keler <laerson.keler@lkmc.com.br>
2011-10-18 09:16 ` Laerson keler <laerson.keler@lkmc.com.br>
2011-10-17 19:13 ` Euler Taveira de Oliveira <euler@timbira.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox