Unix Technical Forum

2PC-induced lockup

This is a discussion on 2PC-induced lockup within the pgsql Hackers forums, part of the PostgreSQL category; --> Andrew Sullivan wrote: > On Wed, Jul 11, 2007 at 04:44:12PM +0100, Heikki Linnakangas wrote: >> FWIW, deleting the ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

 

LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 04-15-2008, 08:55 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: 2PC-induced lockup

Andrew Sullivan wrote:
> On Wed, Jul 11, 2007 at 04:44:12PM +0100, Heikki Linnakangas wrote:
>> FWIW, deleting the files from pg_twophase is safe when the system is
>> shut down.

>
> Is it safe for the PREPAREd TRANSACTIONs? I assume not. That is, in
> Peter's presumably experimental case, it might be ok to delete the
> files, but on a production system, you'd violate the semantics of 2PC
> by doing this?


It's effectively the same as manually issuing a ROLLBACK PREPARED. It
will brake the atomicity of the global transaction, if some branches of
that global transaction in other resource managers have already been
committed.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-15-2008, 08:55 PM
Andrew Sullivan
 
Posts: n/a
Default Re: 2PC-induced lockup

On Wed, Jul 11, 2007 at 06:15:12PM +0100, Heikki Linnakangas wrote:
> It's effectively the same as manually issuing a ROLLBACK PREPARED. It
> will brake the atomicity of the global transaction, if some branches of
> that global transaction in other resource managers have already been
> committed.


But how do you know which file to delete? Is it keyed to the
transaction identifier or something?

A

--
Andrew Sullivan | ajs@crankycanuck.ca
However important originality may be in some fields, restraint and
adherence to procedure emerge as the more significant virtues in a
great many others. --Alain de Botton

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 04-15-2008, 08:55 PM
Peter Eisentraut
 
Posts: n/a
Default Re: 2PC-induced lockup

Heikki Linnakangas wrote:
> It's not? I agree with Tom here; this is just one of the numerous
> things you can do to screw up your database as a superuser. Why would
> you LOCK the pg_auth table, or any other system table for that
> matter, in the first place? Let alone in a distributed transaction.


Well, my test case arose from a real application scenario, not an
attempt to destroy my database system.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 04-15-2008, 08:55 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: 2PC-induced lockup

Peter Eisentraut wrote:
> Heikki Linnakangas wrote:
>> It's not? I agree with Tom here; this is just one of the numerous
>> things you can do to screw up your database as a superuser. Why would
>> you LOCK the pg_auth table, or any other system table for that
>> matter, in the first place? Let alone in a distributed transaction.

>
> Well, my test case arose from a real application scenario, not an
> attempt to destroy my database system.


Why does the application LOCK pg_auth?

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 04-15-2008, 08:55 PM
Tom Lane
 
Posts: n/a
Default Re: 2PC-induced lockup

Heikki Linnakangas <heikki@enterprisedb.com> writes:
> Peter Eisentraut wrote:
>> Heikki Linnakangas wrote:
>>> It's not? I agree with Tom here; this is just one of the numerous
>>> things you can do to screw up your database as a superuser. Why would
>>> you LOCK the pg_auth table, or any other system table for that
>>> matter, in the first place? Let alone in a distributed transaction.

>>
>> Well, my test case arose from a real application scenario, not an
>> attempt to destroy my database system.


> Why does the application LOCK pg_auth?


Even if there is a reason for a lock, surely it's not necessary to use
AccessExclusiveLock. A lesser lock would synchronize whatever the heck
it's doing without locking out readers.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 04-15-2008, 08:55 PM
Tom Lane
 
Posts: n/a
Default Re: 2PC-induced lockup

Andrew Sullivan <ajs@crankycanuck.ca> writes:
> On Wed, Jul 11, 2007 at 06:15:12PM +0100, Heikki Linnakangas wrote:
>> It's effectively the same as manually issuing a ROLLBACK PREPARED.


> But how do you know which file to delete?


You don't. In extremis you could probably throw together some
inspection tool that could look though the 2PC records to find out which
file mentioned an exclusive lock on pg_authid ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 04-15-2008, 08:55 PM
Peter Eisentraut
 
Posts: n/a
Default Re: 2PC-induced lockup

Heikki Linnakangas wrote:

> Why does the application LOCK pg_auth?


It does it with NOWAIT to determine if some other connection had already
locked it (because it was modifying some roles) in order not to lock up
the program. This (or something like it, because this doesn't work,
after all) is unfortunately necessary because schema changes don't obey
ordinary snapshot rules.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 04-15-2008, 08:55 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: 2PC-induced lockup

Andrew Sullivan wrote:
> On Wed, Jul 11, 2007 at 06:15:12PM +0100, Heikki Linnakangas wrote:
>> It's effectively the same as manually issuing a ROLLBACK PREPARED. It
>> will brake the atomicity of the global transaction, if some branches of
>> that global transaction in other resource managers have already been
>> committed.

>
> But how do you know which file to delete? Is it keyed to the
> transaction identifier or something?


The xid is encoded in the filename. If you can't start up the database
and look at pg_locks, you can't do much other than guess.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 04-15-2008, 08:57 PM
Andrew Sullivan
 
Posts: n/a
Default Re: 2PC-induced lockup

On Wed, Jul 11, 2007 at 09:26:34PM +0100, Heikki Linnakangas wrote:
>
> The xid is encoded in the filename. If you can't start up the database
> and look at pg_locks, you can't do much other than guess.


So then in this sort of case, it isn't _really_ safe to delete those
files, because the commitment you made before crash when you accepted
a PREPARE TRANSACTION is going to be gone, which violates the 2PC
rules.

A

--
And

rew Sullivan | ajs@crankycanuck.ca
When my information changes, I alter my conclusions. What do you do sir?
--attr. John Maynard Keynes

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 04-15-2008, 08:57 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: 2PC-induced lockup

Andrew Sullivan wrote:
> On Wed, Jul 11, 2007 at 09:26:34PM +0100, Heikki Linnakangas wrote:
>> The xid is encoded in the filename. If you can't start up the database
>> and look at pg_locks, you can't do much other than guess.

>
> So then in this sort of case, it isn't _really_ safe to delete those
> files, because the commitment you made before crash when you accepted
> a PREPARE TRANSACTION is going to be gone, which violates the 2PC
> rules.


Yes, though if neither you nor the transaction manager can connect, you
don't have much choice.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:59 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com