Thanks ram_0218,
This page does not have any information on 'S/Row-X (SSX)' or any other lock modes.
I am looking for detailed info on the different lock modes..
Regards,
Vikas
Main Topics
Browse All TopicsExperts,
Can some one tell me the definition and what types of statement will create locks in different modes i.e
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)', ** Specially this one
6, 'Exclusive'
I have a scenario where i am facing blocking lock problem :
An user is modifying MY_TABLE fromFront end, and FE holds lock in "Row-X (SX)" mode. The FE has selected record using "SELECT * FROM MY_TABLE WHERE KEY = :A1 FOR UPDATE NOWAIT "
Now in a different session Application Server trying to delete another record in the same table and Holds lock in "Row-X (SX)" mode because of " SELECT ROWID FROM MY_TABLE WHERE KEY = :B1 FOR UPDATE "
and requeste S/Row-X (SSX), to Execute the statement "DELETE MY_TABLE WHERE ROWID = :B1"
Here's how the dba_dml_locks looks like :
SESSION_ID NAME MODE_HELD MODE_REQUESTED LAST_CONVERT
51 MY_TABLE Row-X (SX) S/Row-X (SSX) 3344
70 MY_TABLE Row-X (SX) None 3688
Now the FE Lock Becomes blocking. Any help in understanding this is much appreciated.
Regards,
Vikas Dixit
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
One of the script we have in our office, for monitoring locks..This may be of your interest,
This script checks the locking activity in an Oracle database. This is very useful for finding out about locking problems, and it gives very detailed information to determine if SQL scripts needs to be optimized for locking issues.
SET PAGESIZE 20
Set linesize 132;
column "B/U" format a3
COLUMN LOCK_ID1 FORMAT A45 heading "Object Name/Lock ID1"
column ctime format 999999
column block format 99999
SELECT
substr(to_char(l.sid),1,4)
substr(s.type,1,1) "B/U",
P.spid "SRVR PID",
s.process "CLNT PID",
substr(s.machine,1,7) "MACHINE",
l.type,
DECODE(L.TYPE,'MR','File_I
'TM', LO.NAME,
'TX','USN: '||to_char(TRUNC(L.ID1/655
L.ID1)
LOCK_ID1,
decode(l.lmode,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
substr(to_char(l.lmode),1,
decode(l.request,
0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
substr(to_char(l.request),
l.ctime,
l.block
FROM v$process P,
v$session S,
v$lock l,
sys.obj$ lo,
sys.obj$ rwo
WHERE l.type != 'MR'
AND l.sid = S.sid (+)
AND S.paddr = P.addr (+)
AND LO.OBJ#(+) = L.ID1
AND RWO.OBJ#(+) = S.ROW_WAIT_OBJ#
order by l.sid;
SET PAGESIZE 14
clear columns
Ok, heres my understanding!!
why your Application server takes S/Row-X (SSX) lock before deleting?? If I'm not mistaken, they obtain this lock by program., If so, you'll have to remove it!!
By default when a DML operation is carried out, Row-X (SX) is lock given to the application!! That is largen than enough to maintain your data integrity!!
In your scenerio, application server puts a SSX on the table that denies any further DMLS be executed on the top of the table which is explicitly understood.
ram_0218,
I don't have any explicit code in my application to put "S/Row-X (SSX) " lock. Only piece of code are "FOR UPDATE" and "FOR UPDATE NO WAIT" to get locks., which are necessary as per application design.
Futher, Application has not put the "S/Row-X (SSX) " lock yet, It's requesting lock in this mode, which it is not able to get, because the FE "Row-X (SX)" becomes blocking.
All I want to know, why my application will request "S/Row-X (SSX) " lock and what can I do to avoid it ?
regards,
Vikas Dixit
Ok.. I got my answer partialy at :
http://www.csee.umbc.edu/h
and
http://www.csee.umbc.edu/h
regards,
Vikas Dixit
A row exclusive table lock (also called a subexclusive table lock, SX) generally indicates that the transaction holding the lock has made one or more updates to rows in the table. A row exclusive table lock is acquired automatically for a table modified by the following types of statements:
INSERT INTO table ... ;
UPDATE table ... ;
DELETE FROM table ... ;
LOCK TABLE table IN ROW EXCLUSIVE MODE;
A row exclusive table lock is slightly more restrictive than a row share table lock.
Permitted Operations: A row exclusive table lock held by a transaction allows other transactions to query, insert, update, delete, or lock rows concurrently in the same table. Therefore, row exclusive table locks allow multiple transactions to obtain simultaneous row exclusive and row share table locks for the same table.
Prohibited Operations: A row exclusive table lock held by a transaction prevents other transactions from manually locking the table for exclusive reading or writing. Therefore, other transactions cannot concurrently lock the table using the following statements:
LOCK TABLE table IN SHARE MODE;
LOCK TABLE table IN SHARE EXCLUSIVE MODE;
LOCK TABLE table IN EXCLUSIVE MODE;
1. How does Oracle handle locking?
==========================
Oracle use enqueues as locking mechanism for managing access to shared
resources. A shared resource can be a table definition, a transaction
or any type of structure that represent something sharable between sessions.
Each type of actions performed by Oracle sessions on those shared resources
will require a certain type of lock or lock mode (e.g. a 'select on a table'
action will require that the executing session has a shared lock on the
resource 'table definition' of the selected table). When conflicting
actions are occuring, Oracle will serialize the processing by putting
a number of sessions in waiting mode until the work of the blocking
session has been completed.
Each enqueue represent a sharable resource. Sessions are acquiring,
converting and releasing locks on resources in function of the work
they need to perform. Releasing locks are performed by the sessions
when they issue a commit or a DDL statement (i.e. implicit commit), or
by SMON if the sessions have been killed. Conversion is the process of
changing a lock from the mode we currently hold to a different mode.
Acquiring a lock is the process of getting a lock on a resource on which we
currently do not have a lock. We are allowed to convert a lock if the mode
we require, is a subset of the mode we hold or is compatible with the
modes already held by other sessions. Otherwise, we wait on the converters
queue of the resource. We are allowed to acquire a lock, if there are no
converters or waiters ahead of us and the mode we require is compatible with
the modes already held by others. Otherwise, we wait on the waiters queue
of the resource. When a session has a lock on a resource, then it stands
in the owner queue of the resource. When a lock is released or converted,
the converters and waiters are re-checked to see if they can be acquired.
The converters are processed first, then the waiters.
Row locking in Oracle is based on the TX enqueues and is known as
transactional locking. When two or more sessions are changing data on one
row of a table (DML statements on the same record), the first session will
lock the row by putting his transaction reference in the block containing
the row header. The other sessions will look at this lock information
and will wait on the transaction (i.e. the TX enqueue of the blocking session)
of the first session before proceeding. When the first session performs a
commit, the TX resource will be released and the waiters will start their
own locking. The waiting sessions are thus waiting on an exclusive TX
resource, but their TM resources they are holding give the objects they are
in fact waiting on.
If a lock has not been acquired or converted, a deadlock check is made by
the waiting session after a timeout. For example, following situation
generates a deadlock: user A gets an S lock on resource 1, then user B
gets an S lock on resource 2; later, A request an X lock on resource 2
and waits, then B requests an X lock on resource 1 and waits; now, A is
waiting for B to release resource 2, which is waiting for A to release
resource 1; A is indirectly waiting for A. It is a deadlock, generating
a tracefile in the user_dump_dest and and ORA-60 in the detecting session.
The lock and resource information stands within the SGA to allow PMON to
recover in the event of process failure. The PMON is responsible for
releasing the locks of the crashed/killed processes.
2. How to find the resource definitions?
==========================
Each resource is represented by an enqueue. An enqueue is identified by
a unique name, also known as the resource name. The name has the form:
<Type, ID1, ID2>. Type has two characters and represent a resource type
(e.g. “TM” for the table definition type). ID1 and ID2 are positive numbers
and identify the resource fully (e.g. ID1 is the object_id of the table
if the resource type is "TM").
The description of most enqueue/resource types can be found in the appendixes
of the Oracle Reference Guide. The most commonly known resource types are
the TM, TX, ST and UL resources.
a. The TM resource, known as the DML enqueue, is acquired during the execution
of a statement when referencing a table so that the table is not dropped or
altered during the execution of it.
b. The TX resource, known as the transaction enqueue, is acquired exclusive
when a transaction initiates its first change and is held until the transaction
does a COMMIT or ROLLBACK. Row locking is based on TX enqueues. SMON will
acquire it when doing recovery of a killed/crashed process.
c. The ST resource is used to serialize space management tasks when a
session's job requires extents to be allocated to objects.
d. The UL resource represent the user-defined locks defined by the DBMS_LOCK
package.
3. Which lock modes are required for which table action?
==========================
The following table describes what lock modes on DML enqueues are actually
gotten for which table operations in a standard Oracle installation.
Operation Lock Mode LMODE Lock Description
------------------------- --------- ----- ----------------
Select NULL 1 null
Select for update SS 2 sub share
Insert SX 3 sub exclusive
Update SX 3 sub exclusive
Delete SX 3 sub exclusive
Lock For Update SS 2 sub share
Lock Share S 4 share
Lock Exclusive X 6 exclusive
Lock Row Share SS 2 sub share
Lock Row Exclusive SX 3 sub exclusive
Lock Share Row Exclusive SSX 5 share/sub exclusive
Alter table X 6 exclusive
Drop table X 6 exclusive
Create Index S 4 share
Drop Index X 6 exclusive
Truncate table X 6 exclusive
--------------------------
The originarl pbm if i'm not mistaken is,
'Row-X (SX)',
denies denies locking in SHARE mode which is being requested by the application., As I see your pbm, if you can do the first update with 'Row-S (SS)', it wont prohibit the share more locking option which is being req by the application., So change your code may be to this, and see what happens.,
instead of select for update,
lock table emp in row share mode;
and then do your update, and release the lock!!
meantime if the application requests for share exclusing lock mode, it'll be granted with no wait!!
Hi all,
Thanks for al your help, found the problem : My this particular table had a self referential integrity constraint and as per the article found at :
http://www.fors.com/orasup
"
1) When your application has referential integrity and attempts to modify
the child table, Oracle will get a TABLE LEVEL SHARE LOCK on the parent
table when there is NO index on the foreign key.
"
I created index on the column that was referencing the primary column and the problem got resloved....
Apparently this problem started happening after a recent Database patch VTM 2003 ( I have no idea about this patch).
Regards,
Vikas Dixit
Business Accounts
Answer for Membership
by: ram_0218Posted on 2005-10-20 at 10:49:31ID: 15126601
check this page
help/oracl e8/server. 815/a67779 / ch4j.htm# 5870
https://www.csee.umbc.edu/