Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> Re: RE: Has anyone done any scalability work on dbms_lock?

Re: RE: Has anyone done any scalability work on dbms_lock?

From: Jonathan Lewis <>
Date: Thu, 22 Jan 2004 09:09:25 -0800
Message-ID: <>

I came across a very nice example a while ago where there were 4 concurrent sessions feeding data into a holding table, and one session consuming from the table.

The rules said that the consumer could not run while the producers were loading the table, but multiple producers were allowed to run.

It was easy to implement using dbms_lock - the producers ran a pl/sql loop that requested a share lock (mode 4) on a named resource, and committed at the end of each loop; the consumer also ran a loop but requested an exclusive lock (mode 6) on the same named resource and committed at the end of each loop.

Both programs had a little sleep time built in to the loops after the commit.

When the consumer got its lock, the producers waited. When the consumer committed, the producers got in, and the the consumer queued on them when it next asked for its lock.


Jonathan Lewis

  The educated person is not the person
  who can answer the questions, but the
  person who can question the answers -- T. Schick Jr

Next public appearances:
 Jan 29th 2004 UKOUG Unix SIG - v$ and x$  March 2004 Hotsos Symposium - The Burden of Proof  March 2004 Charlotte NC OUG - CBO Tutorial  April 2004 Iceland

One-day tutorials:

Three-day seminar:
see ____UK___February

The Co-operative Oracle Users' FAQ

> Well, I don't know about anyone else, but I make use of it to synchronize
data upload programs for our testers. Can't have two instances of the upload program processing the same tester, they'd duplicate data. Anyhow, we normally run 4 instances of this program & the dbms_lock package works absolutely fantastically.
> Dick Goulet
> Senior Oracle DBA
> Oracle Certified 8i DBA

Please see the official ORACLE-L FAQ:
Author: Jonathan Lewis

Fat City Network Services    -- 858-538-5051
San Diego, California        -- Mailing list and web hosting services
To REMOVE yourself from this mailing list, send an E-Mail message
to: (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Jan 22 2004 - 11:09:25 CST

Original text of this message