AW: timeout on lock feature

Поиск
Список
Период
Сортировка
Искать

AW: timeout on lock feature

От:
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>
Дата:

> I was thinking SET because UPDATE does an auto-lock.

Optimal would imho be a SET that gives a maximum amount of time in seconds 
the client is willing to wait for any lock. But I liked the efficiency of Henryk's code.

> 
> > Bruce Momjian  writes:
> > > I can imagine some people wanting this.  However, 7.1 has new deadlock
> > > detection code, so I would you make a 7.1 version and send it over.  We
> > > can get it into 7.2.
> > 
> > I object strongly to any such "feature" in the low-level form that
> > Henryk proposes, because it would affect *ALL* locking.  Do you really
> > want all your other transactions to go belly-up if, say, someone vacuums
> > pg_class?

Yes, if a non batch client already blocked for over x seconds. Of course a more
sophisticated client can send querycancel() but that involves a more complicated
program (threads, timer ...).

> > 
> > A variant of LOCK TABLE that explicitly requests a timeout might make
> > sense, though.

I do not think that a solution for one particular lock is very helpful. If your dml then 
blocks on some unforseen lock (parse, plan ...) , the client is in exactly the situation 
it tried to avoid in the first place.

Andreas

Re: AW: timeout on lock feature

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Added to TODO:
* Add SET parameter to timeout if waiting for lock too long                   
> 
> > I was thinking SET because UPDATE does an auto-lock.
> 
> Optimal would imho be a SET that gives a maximum amount of time in seconds 
> the client is willing to wait for any lock. But I liked the efficiency of Henryk's code.
> 
> > 
> > > Bruce Momjian  writes:
> > > > I can imagine some people wanting this.  However, 7.1 has new deadlock
> > > > detection code, so I would you make a 7.1 version and send it over.  We
> > > > can get it into 7.2.
> > > 
> > > I object strongly to any such "feature" in the low-level form that
> > > Henryk proposes, because it would affect *ALL* locking.  Do you really
> > > want all your other transactions to go belly-up if, say, someone vacuums
> > > pg_class?
> 
> Yes, if a non batch client already blocked for over x seconds. Of course a more
> sophisticated client can send querycancel() but that involves a more complicated
> program (threads, timer ...).
> 
> > > 
> > > A variant of LOCK TABLE that explicitly requests a timeout might make
> > > sense, though.
> 
> I do not think that a solution for one particular lock is very helpful. If your dml then 
> blocks on some unforseen lock (parse, plan ...) , the client is in exactly the situation 
> it tried to avoid in the first place.
> 
> Andreas
> 


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

Re: AW: timeout on lock feature

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> Added to TODO:
> 	* Add SET parameter to timeout if waiting for lock too long

I repeat my strong objection to any global (ie, affecting all locks)
timeout.  Such a "feature" will have unpleasant consequences.
		regards, tom lane

Re: AW: timeout on lock feature

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> I envisioned:

> 	SET TIMEOUT TO 10;
> 	UPDATE tab SET col = 3;
> 	RESET TIMEOUT

> Can't we get that work work properly?  Let the timeout only apply to the
> 'tab' table and none of the others.

As Henryk has implemented it, it WON'T only apply to the 'tab' table;
it'll affect all locks grabbed anywhere, including those that the system
locks internally.  That scares the heck out of me, Andreas' objections
notwithstanding.

> Can't we exclude system tables from being affected by the timeout?

How will you do that?  The lock manager makes a point of not knowing the
semantics associated with any particular lock tag.  It's even less
likely to know the difference between a "system" grab and a "user" grab
on what might be the very same lock (consider an "UPDATE pg_class"
command).

> Requiring a LOCK statement that matches
> the UPDATE/DELETE and wrapping the whole thing in a transaction seems
> needlessly complex to me.

As opposed to your three-step proposal above?  That doesn't look
very much simpler to me...
		regards, tom lane

RE: AW: timeout on lock feature

От:
Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
Дата:

Sorry for my forgetfulness (and a search through geocrawler didn't turn up anything useful), but what was the problem with something like NOWAIT?

e.g.: SELECT * FROM a FOR UPDATE NOWAIT;

where, if the required lock could not be obtained immediately, this statement would raise an error.

Cheers...

MikeA

>> -----Original Message-----
>> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>> Sent: 17 April 2001 15:49
>> To: Bruce Momjian
>> Cc: Zeugswetter Andreas SB; Henryk Szal; pgsql-hackers@postgresql.org
>> Subject: Re: AW: [HACKERS] timeout on lock feature
>>
>>
>> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> > Added to TODO:
>> >    * Add SET parameter to timeout if waiting for lock too long
>>
>> I repeat my strong objection to any global (ie, affecting all locks)
>> timeout.  Such a "feature" will have unpleasant consequences.
>>
>>                      regards, tom lane
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 5: Have you checked our extensive FAQ?
>>
>> http://www.postgresql.org/users-lounge/docs/faq.html
>>

_________________________________________________________________________
This e-mail and any attachments are confidential and may also be privileged and/or copyright
material of Intec Telecom Systems PLC (or its affiliated companies). If you are not an
intended or authorised recipient of this e-mail or have received it in error, please delete
it immediately and notify the sender by e-mail. In such a case, reading, reproducing,
printing or further dissemination of this e-mail is strictly prohibited and may be unlawful.
Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free
from computer viruses or other defects. The opinions expressed in this e-mail and any
attachments may be those of the author and are not necessarily those of Intec Telecom
Systems PLC.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
__________________________________________________________________________

Re: AW: timeout on lock feature

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Michael Ansley  writes:
> Sorry for my forgetfulness (and a search through geocrawler didn't turn up
> anything useful), but what was the problem with something like NOWAIT?
> e.g.: SELECT * FROM a FOR UPDATE NOWAIT;
> where, if the required lock could not be obtained immediately, this
> statement would raise an error.

I have no objection to that ... it does not cover anything except FOR
UPDATE, though, which is probably less general than some of the other
folks want.
		regards, tom lane

RE: AW: timeout on lock feature

От:
"Mikheev, Vadim" <vmikheev@SECTORBASE.COM>
Дата:
> > Added to TODO:
> > 	* Add SET parameter to timeout if waiting for lock too long
> 
> I repeat my strong objection to any global (ie, affecting all locks)
> timeout.  Such a "feature" will have unpleasant consequences.

But LOCK TABLE T IN ROW EXCLUSIVE MODE WITH TIMEOUT X will not give
required results not only due to parser/planner locks - what if
UPDATE T will have to wait for other transactions commit/abort
(same row update)? Lock on pseudo-table is acquired in this case...

Vadim

Re: AW: timeout on lock feature

От:
"Henryk Szal" <szal@doctorq.com.pl>
Дата:
This option will be OPTIONAL.

Tom Lane wrote in message <23613.987518927@sss.pgh.pa.us>...
>Bruce Momjian  writes:
>> Added to TODO:
>> * Add SET parameter to timeout if waiting for lock too long
>
>I repeat my strong objection to any global (ie, affecting all locks)
>timeout.  Such a "feature" will have unpleasant consequences.
>
> regards, tom lane
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
>http://www.postgresql.org/users-lounge/docs/faq.html



FAQ