Path: news.cambrium.nl!textnews.cambrium.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!postnews.google.com!h30g2000vbr.googlegroups.com!not-for-mail
From: Mark D Powell <Mark.Powell@eds.com>
Newsgroups: comp.databases.oracle.misc
Subject: Re: dbms_lock
Date: Sat, 8 Aug 2009 11:19:21 -0700 (PDT)
Organization: http://groups.google.com
Lines: 63
Message-ID: <7400b753-8483-4ac6-a3b6-5cb2a0fb745d@h30g2000vbr.googlegroups.com>
References: <4a7d5920$0$1465$586efd2@news.usenetserver.com>
NNTP-Posting-Host: 67.167.134.14
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1249755561 1249 127.0.0.1 (8 Aug 2009 18:19:21 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 8 Aug 2009 18:19:21 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h30g2000vbr.googlegroups.com; posting-host=67.167.134.14; 
 posting-account=qJFqbQkAAACYQSLN0-cvP6ydkRfuOu6u
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 
 Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET 
 CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 
 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0),gzip(gfe),gzip(gfe)
Xref:  news.cambrium.nl

On Aug 8, 6:53=A0am, m...@pixar.com wrote:
> I have a server program that should run in active/standby mode:
>
> =A0 =A0- a copy of the program is running on two different computers
> =A0 =A0- only one copy should be active
> =A0 =A0- if the active copy exits, fails, etc, the standby should take
> =A0 =A0 =A0over and become the active
> =A0 =A0- when the original active resumes, it is now the standby
>
> Using a dbms_lock makes this quite simple, put this code
> at the top of the program:
>
> =A0 =A0 dbms_lock.allocate_unique('myserver', v_lockhandle);
> =A0 =A0 v_result :=3D dbms_lock.request(v_lockhandle, dbms_lock.x_mode);
>
> 1. =A0Is there any problem with holding a lock for a long time? =A0The
> =A0 =A0 active may stay active for months on end.
>
> 2. =A0If there is a problem with holding a lock for a long time,
> =A0 =A0 what is a "reasonable" time to keep a lock open?
>
> 3. =A0The most common way this lock will be released is for the
> =A0 =A0 process or the computer to die. =A0Are there any problems
> =A0 =A0 related to this?
>
> Many TIA,
> Mark
>
> --
> Mark Harrison
> Pixar Animation Studios

We have used user locks since Oracle introduced them, usually to
prevent concurrent running of a business process that cannot support
concurrent use.  Most of our single-threaded processes use the timeout
parameter to notify the running program that the lock is in use,
meaning the process is already running, so the second execution
usually terminates.  In cases where we just want to single thread the
process we either do not use the timeout or the program loops and
tries again a few seconds latter.

In theory you can wait forever though I have to wonder if a program
that was blocked for months would not get swapped out or otherwise be
subject to some type of network/OS timeout depending on your
environment.

I would say try it and see how it works.  You could always change the
program(s) to poll for the lock, sleep, and try again so it is an
active process.  This second approach would be my approach to the
problem.

I do not see any issue with a session holding the UL for as long as
the instance is running even if it is months.  Oracle does the same
with file recovery locks.

HTH -- Mark D Powell --




Is the standby process going to be lock waited this entire time, or
are you going to use the timeout parameters so the second session will
be notified the lock is being held and it will cycle through logic
