UnitOfWork doesn't release pessimistic row lock???

I have an application that polls a DB table for new "submissions", then forwards them to another server to handle them asynchronously. When the asynchronous response comes back, my application verifies that all response have been received from the server, then sends a combined response. My problem is that the asynchronous response listener threads appear to deadlock when pessimistically locking the submission row, even though the transaction that locked it has been closed for ~1s.
Some psuedocode may help explain the problem. This is my DB polling thread
while( true ) {
Submission s = getNextSubmissionAndLockPessimistically();
if( s == null )
return null;
Server s2 = getServerCapableOfRunning( s );
if( s2 != null )
return s2;
uow.revertAndResume();
I am worried that in the instance that a server capable of running the submission could not be found, or is too full, the UnitOfWork#revertAndResume method does not release the row lock for the submission. Are there any scenarios where this can occur?
On another note, I occasionally receive "Query sent to unactivated UnitOfWork" exceptions during the uow.revertAndResume() call. My code only uses the first UnitOfWork returned by EntityManager#getUnitOfWork(). Could the two be related? Does anyone have any ideas on how to fix this exception?
Thanks,
Dan

Thank you for the detailed description of how the locks are released; I mistakenly assumed the revertObject/revertAndResume would release them. I will refactor my code to create EntityManager/UnitOfWork instances in loop and release/close them instead of reverting.
As for the "unactivated UnitOfWork" exception, here is one of my stack traces:
Exception [TOPLINK-6027] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Query sent to a unactivated UnitOfWork.
Query: ReadAllQuery(my.package.ServerLimits)
at oracle.toplink.essentials.exceptions.QueryException.querySentToInactiveUnitOfWork(QueryException.java:893)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2217)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:86)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:76)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:193)
at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:315)
at oracle.toplink.essentials.indirection.IndirectList.size(IndirectList.java:640)
at oracle.toplink.essentials.internal.queryframework.CollectionContainerPolicy.sizeFor(CollectionContainerPolicy.java:184)
at oracle.toplink.essentials.internal.indirection.TransparentIndirectionPolicy.getRealAttributeValueFromObject(TransparentIndirectionPolicy.java:252)
at oracle.toplink.essentials.mappings.ForeignReferenceMapping.getRealAttributeValueFromObject(ForeignReferenceMapping.java:370)
at oracle.toplink.essentials.mappings.CollectionMapping.getRealAttributeValueFromObject(CollectionMapping.java:559)
at oracle.toplink.essentials.mappings.CollectionMapping.getRealCollectionAttributeValueFromObject(CollectionMapping.java:574)
at oracle.toplink.essentials.mappings.CollectionMapping.mergeIntoObject(CollectionMapping.java:734)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:2114)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:2096)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChangesOfOriginalIntoWorkingCopy(MergeManager.java:450)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChanges(MergeManager.java:251)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.revertAndResume(UnitOfWorkImpl.java:3527)
at my.package.DbInterface.getNextSubmissionAndServer(DbInterface.java:460)
at my.package.PollingThread.waitForNextSubmission(PollingThread.java:175)
at my.package.PollingThread.run(PollingThread.java:122)
This particular error could be related to the DB lock obtained on the Server object, which has a One-To-Many relationship to the ServerLimits.
However, there is another exception that I am worried about:
Exception [TOPLINK-6027] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: Query sent to a unactivated UnitOfWork.
Query: ReadAllQuery(my.package.Submission)
at oracle.toplink.essentials.exceptions.QueryException.querySentToInactiveUnitOfWork(QueryException.java:893)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2217)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:86)
at oracle.toplink.essentials.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:76)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:160)
at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:232)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:90)
at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:193)
at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:315)
at oracle.toplink.essentials.indirection.IndirectList.add(IndirectList.java:140)
at my.package.db.Transaction.addSubmission(Transaction.java:422)
at my.package.DbInterface.createNewSubmission(DbInterface.java:284)
at my.package.EngineInterface.executeObjectFn(EngineInterface.java:446)
at my.package.EngineInterface.executeBooleanFn(EngineInterface.java:412)
at my.package.EngineInterface.search(EngineInterface.java:252)
at my.package.mdb.RequestListenerBean.onMessage(RequestListenerBean.java:457)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
at oracle.j2ee.connector.messageinflow.MessageEndpointImpl.OC4J_invokeMethod(MessageEndpointImpl.java:297)
at RequestListenerBean_EndPointProxy_44242m8.onMessage(Unknown Source)
at oracle.j2ee.ra.jms.generic.WorkConsumer.run(WorkConsumer.java:268)
at oracle.j2ee.connector.work.WorkWrapper.runTargetWork(WorkWrapper.java:242)
at oracle.j2ee.connector.work.WorkWrapper.doWork(WorkWrapper.java:215)
at oracle.j2ee.connector.work.WorkWrapper.run(WorkWrapper.java:190)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:819)
at java.lang.Thread.run(Thread.java:595)
The code that caused this error is about as simple as it can get:
EntityManager em = (EntityManager) emf.createEntityManager();
UnitOfWork uow = em.getUnitOfWork();
try
// locate owning transaction and the RECEIVED_FROM_ESB type
Transaction tx = locate( Transaction.class, em, uow, txId );
ServerFunction fn = locate( ServerFunction.class, em, uow, fnId );
TrackingType trackingType = locate( TrackingType.class, em, uow, TrackingType.RECEIVED_FROM_ESB );
// create submission
Submission submission = new Submission();
submission.setPriority( priority );
submission.setRequestId( requestId );
submission.setNistId( nistId );
submission.setFunction( fn );
// create RECEIVED_FROM_ESB tracking status
TrackingStatus status = new TrackingStatus();
status.setTrackingType( trackingType );
status.setStatusTime( new Timestamp( System.currentTimeMillis() ) );
submission.addTrackingStatus( status );
tx.addSubmission( submission );
em.persist( submission );
uow.commit();
em.close();
return submission.getId();
finally
if( uow.isActive() )
uow.release();
if( em.isOpen() )
em.close();
There is a One-To-Many mapping from Transaction to Submission, and a One-To-Many mapping from Submission to TrackingStatus.
If anyone can offer any insight into what I'm doing wrong, I'd appreciate it!
Thanks,
Dan

Similar Messages

  • How and when the database release a row lock?

    Dear experts,
    We are using the following statement to obtain a row lock in a table in the database(ORACLE of course),
    SELECT * FROM {TABLE_NAME} WHERE ID = 1 for update
    and if we succeed grabbing the row lock we will continue to issue a update statement every 30 seconds to preserve the lock as far as possible.
    here is the update statement to preserve the lock,
    UPDATE {TABLE_NAME} SET time = ? WHERE ID = 1.
    As you see more longer we keep holding the row lock , more update statements are submitted in the pending transaction.
    In normal case our application can grab the exclusive row lock and works for a long time,however sometimes a connection reset exception is thrown
    and our application will close the connection(I assume the pending transaction will be rolled back by the database) and exit the JVM.
    Since other applications will keep trying to grab the same row lock to become the master role,
    we expect one of them can succeed but they are all failed because the database has not released the row lock as expected.
    Can someone explain more details about how and when the row lock can get released in our use case?
    Thanks,
    SuoNayi
    Edited by: SuoNayi on 2013-5-30 上午8:12

    Hm. Is this part of an XA transaction by any chance? I know that Oracle maintains separate bookkeeping for such transactions which can cause rows to stay 'locked' even when the regular DBA views will indicate there is no user currently locking the record at all. I have no idea about the actual details and what you need to do to clean up such a situation, that is something a DBA should know and do.
    If not... well this is more of a question for people who know the DBMS, which makes it a target for the Oracle DBMS forums. Java developers don't tend to have DBA-level knowledge of the database, you should ask the question where you have more chance of people with expertise answering stuff:
    General Database Discussions

  • How to release row lock by using jdbc

    hi, currently we are using jdbc to create a connection and create a row lock , is there anyway to release the row lock? right now i am using resultset.close(), but this cause me problem since it release other resultset's row lock too. please help.

    hi, from your post, i understood that u know how to do row locking..
    How was it done ??
    I'm currently looking for answer to do row locking in Microsoft Access...
    These are the SQL stmt i've done without success..
    SELECT * FROM BSPerson WITH UPDLOCK WHERE ID = 'P001';
    SELECT * FROM BSPerson WHERE ID = 'P001' FOR UPDATE;
    Both stmt having error........
    Please help !
    A miliion thanks....

  • Identifying deadlocked resources in graph with 1 row lock and 1 table lock

    Hi, I have run into repeated occurrences of the deadlock graph at the bottom of this post and have a few questions about it:
    1. It appears that proc 44, session 548 is holding a row lock (X). Is the waiter, proc 30, session 542, trying to acquire a row lock (X) also or an exclusive table lock (X) on the table containing that row?
    2. Under what circumstances would something hold a row exclusive table lock (SX) and want to upgrade that to a share row exclusive table lock (SSX)?
    3. Our table cxml_foldercontent has a column 'structuredDataId' with a FK to cxml_structureddata.id and an ON DELETE SET NULL trigger. Would this help explain why an "update" to one table (i.e.g cxml_foldercontent) would also need to acquire a lock in a foreign table, cxml_structureddata?
    4. What is the difference between "Current SQL statement:" and "Current SQL statement for this session:"? That terminology is confusing. Is session 542 executing the "update" or the "delete"?
    5. In the "Rows waited on:" section is it saying that Session 542 is waiting on on obj - rowid = 0000BE63 - AAAL5jAAGAAA6tZAAK or that it is has the lock on that row and other things are waiting on it?
    A couple of notes:
    - the cxml_foldercontent.structuredDataId FK column has an index on it already
    Deadlock graph:
                           ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name                    process session holds waits  process session holds waits
    TX-003a0011-000003d0        44       548     X               30        542             X
    TM-0000be63-00000000       30       542     SX              44        548     SX    SSX
    session 548: DID 0001-002C-000002D9     session 542: DID 0001-001E-00000050
    session 542: DID 0001-001E-00000050     session 548: DID 0001-002C-000002D9
    Rows waited on:
    Session 542: obj - rowid = 0000BE63 - AAAL5jAAGAAA6tZAAK
      (dictionary objn - 48739, file - 6, block - 240473, slot - 10)
    Session 548: no row
    Information on the OTHER waiting sessions:
    Session 542:
      pid=30 serial=63708 audsid=143708731 user: 41/CASCADE
      O/S info: user: cascade, term: unknown, ospid: 1234, machine:
                program: JDBC Thin Client
      application name: JDBC Thin Client, hash value=2546894660
      Current SQL Statement:
    update cascade.cxml_foldercontent set name=:1 , lockId=:2 , isCurrentVersion=:3 , versionDate=:4 , metadataId=:5 , permissionsId=:6 , workflowId=:7 , isWorkingCopy=:8 , parentFolderId=:9 , relativeOrder=:10 , cachePath=:11 , isRecycled=:12 , recycleRecordId=:13 , workflowComment=:14 , draftUserId=:15 , siteId=:16 , prevVersionId=:17 , nextVersionId=:18 , originalCopyId=:19 , workingCopyId=:20 , displayName=:21 , title=:22 , summary=:23 , teaser=:24 , keywords=:25 , description=:26 , author=:27 , startDate=:28 , endDate=:29 , reviewDate=:30 , metadataSetId=:31 , expirationNoticeSent=:32 , firstExpirationWarningSent=:33 , secondExpirationWarningSent=:34 , expirationFolderId=:35 , maintainAbsoluteLinks=:36 , xmlId=:37 , structuredDataDefinitionId=:38 , pageConfigurationSetId=:39 , pageDefaultConfigurationId=:40 , structuredDataId=:41 , pageStructuredDataVersion=:42 , shouldBeIndexed=:43 , shouldBePublished=:44 , lastDatePublished=:45 , lastPublishedBy=:46 , draftOriginalId=:47 , contentTypeId=:48  where id=:49
    End of information on OTHER waiting sessions.
    Current SQL statement for this session:
    delete from cascade.cxml_structureddata where id=:1

    Mohamed Houri wrote:
    What is important for a foreign key is to be indexed (of course if the parent table is deleted/merged/updated, or if a performance reason imposes it). Wether this index is unique or not doesn't matter (as far as i know).But, you should ask your self the following question : what is the meaning of having a 1 to 1 relationship between a parent and a child table ? if you succeed to create a unique index on your FK then this means that for each PK value corresponds at most one FK value!! Isn't it? is this what you want to have?Thanks, as I mentioned above, cxml_structureddata is actually the child table of cxml_foldercontent with 1 or more records' owningEntityId referring to rows in cxml_foldercontent. The reason for the FK on cxml_foldercontent.structuredDataId is a little ambiguous but it explained above.
    Will a TX-enqueue held on mode X always be waited on by another TX-enqueue row lock X? Or can it be waited on by an Exclusive (X) table lock?Not really clear. Sorry, are you saying my question is unclear or it's not clear why type of eXclusive lock session 542 is trying to acquire in the first line of the trace? Do you think that the exclusive lock being held by session 548 in the first line is on rows in cxml_foldercontent (due to the ON DELETE SET NULL on these child rows) or rows in the cxml_structureddata that it's actually deleting?
    Is there any way for me to tell for certain?
    The first enqueue is a TX (Transaction Enqueue) held by session 548 on mode X (exclusive). This session represents the blocking session. At the same time the locked row is waited on by the blocked session (542) and the wait is on mode X (exclusive). So put it simply, we have here session 542 waiting for session 548 to release it lock (may be by commiting/roll backing). At this step we are not in presence of a deadlock.
    The second line of the deadlock graph shows that session 542 is the blocking session and it is doing a TM enqueue (DML lock) held on SX(Shared eXclusive). While session 548(which is the waiting session) is blocked by session 542 and is waiting on SSX mode.
    Here we see that 548 is blocking session 542 via a TX enqueue and session 542 is blocking session 548 via a TM enqueue ---> That is the deadlock. Oracle will then immediately choose arbitrarlly a victim session (542 or 548) and kill its process letting the remaining session continuing its work.
    That is your situation explained here.Thanks, any idea why session 542 (the DELETE from cxml_structureddata) would be trying to upgrade it's lock to SSX? Is this lock mode required to update a child tables foreign key columns when using an ON DELETE SET NULL trigger? Having read more about SSX, I'm not sure I understand in what cases it's used. Is there a way for me to confirm with 100% certainty specifically which tables in the TM enqueue locks are being held on? Is session 548 definitely trying to acquire an SSX mode on my cxml_foldecontent table or could it be cxml_structureddata table?
    (a) Verify that all your FK are indexed (be carreful that the FK columns should be at the leading edge of the index)Thanks, we've done this already. When you say the "leading edge" you mean for a composite index? These indexes are all single column.
    (b) Verify the logic of the DML against cxml_foldercontentCan you be more specific? Any idea what I'm looking for?

  • OIM DB Row LOCK Exception on Quartz tables

    I am facing db row lock error in Prod OIM due to which the Scheduler fails to kick off and an OIM Restart is required to release the lock and start the Scheduler again.
    This Error is occuring at any time when none of the scheduler( Custom as well as House Keeping) are scheduled.The OIM Version is 9.0.3.1.
    I have enabled Database logs in Debug mode but there are no logs corresponding to the table where lock occured.
    This Error was encountered long back with OIM 9.0.1 and was reported as Bug 6491465, but was suspended because of no response from Customer.
    The Error trace is as follows
    ERROR,11 Sep 2009 16:57:05,497,[org.quartz.core.ErrorLogger],An error occured while scanning for the next trigger to fire.
    org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Io exception: Connection reset [See nested exception: java.sql.SQLException: Io ex
    ception: Connection reset]
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock(StdRowLockSemaphore.java:154)
    at org.quartz.impl.jdbcjobstore.JobStoreCMT.acquireNextTrigger(JobStoreCMT.java:1376)
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
    * Nested Exception (Underlying Cause) ---------------
    java.sql.SQLException: Io exception: Connection reset
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:287)
    at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:515)
    at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
    at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:535)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.obtainLock(StdRowLockSemaphore.java:137)
    at org.quartz.impl.jdbcjobstore.JobStoreCMT.acquireNextTrigger(JobStoreCMT.java:1376)
    at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:231)
    Did anyone had ever encountered this error.Any Hints?

    I would check the network pieces as suggested in our internal emails. If the connection is dropping somewhere on your network, the lock would never be released.
    -Kevin

  • Tuning row lock contention wait events

    Hello everyone,
    Working on 10g/windows
    Top 5 events
    EVENT TOTAL_WAITS TIME_WAITED AVG_MS PERCENT
    CPU 9462339 48
    enq: TX - row lock contention 12531 3660728 2921.34 18
    control file parallel write 1300731 3088079 23.74 16
    log file parallel write 1510503 1264080 8.37 6
    log file sync 1072553 968007 9.03 5
    Distribution of row lock wait during the last 4 days in the database server
    END_INTERVAL_TIME TOTAL_WAITS TIME_WAITED_MICRO AVG_WAIT_MS
    2008-04-01 16:00:58 909 2721008230 2993.41
    2008-04-01 15:00:27 50 149941140 2998.82
    2008-03-31 12:00:42 193 575595397 2982.36
    2008-03-29 23:00:13 172 513058700 2982.9
    2008-03-29 22:00:37 164 483940046 2950.85
    2008-03-27 22:00:35 565 1667120838 2950.66
    2008-03-26 18:00:59 348 1042918982 2996.89
    My analysis:
    It's obvious that the row lock contention wait time is huge, and this direct me to find out SQL stmt, causing this.
    all the SQL statement was SELECT ....... FOR UPDATE stmt.
    I was also able to find out locked tables.
    My tuning idea:
    1. I'm thinking to reorganize hot tables as well as their indexes, but by instinct it seems to not give so much value to avoid the huge row lock wait time.
    2. I'm also seeing if I can reduce the number of rows per block, by increasing PCTFREE and diminishing PCTUSED, so the contention will spread over many blocks instead of one heavy block.
    Question
    As SQL stmt related to those locked tables are select ... for update, how could I tune this kind of stmt?
    Does someone have other idea to come up with this row lock contention?
    Tanks for your effort and help

    Taking another look at your suggested function based index, it depends on the data type of the DEV.POS_FOLIO_ID.POS_FOLIO_ID column. If the column is defined as a number, and it is a primary key, there will already be a usable index on that column.
    Yesterday, I wrote this: "Once I understood why or how the sessions were trying to insert duplicate primary key values, I would try to determine why the average number of seconds for the wait event is almost 3 seconds (maybe a timeout)."
    After fixing the formatting of the top 5 wait events (total duration unknown):
    EVENT                        TOTAL_WAITS  TIME_WAITED   AVG_MS PERCENT
    CPU                                         94,623.39             48
    enq: TX - row lock contention     12,531    36,607.28  2921.34    18
    control file parallel write    1,300,731    30,880.79    23.74    16
    log file parallel write        1,510,503    12,640.80     8.37     6
    log file sync                  1,072,553     9,680.07     9.03     512,531 * 3 second time out = 37,593 seconds = 10.44 hours.
    What if the reason for the 3 second average wait time is due to a timeout. I performed a little experiment... I changed a row in a test table and then made a pot of coffee.
    In session 1:
    CREATE TABLE T1 (
      C1 NUMBER(10),
      C2 NUMBER(10),
      PRIMARY KEY (C1));
    INSERT INTO T1
    SELECT
      ROWNUM,
      ROWNUM*10
    FROM
      DUAL
    CONNECT BY
      LEVEL<=1000000;
    COMMIT;I now have a test table with 1,000,000 rows. I start monitoring the changes in the wait events roughly every 60 seconds, and V$SESSION_WAIT and V$LOCK roughly 4 times per second.
    Back in session 1:
    UPDATE
      T1
    SET
      C1=-C1
    WHERE
      C1<=100;I have now modified the first 100 rows that were inserted into the table, time to make the pot of coffee.
    In session 2, I try to insert a row with a primary key value of -10:
    INSERT INTO T1 VALUES (
      -10,
      10);Session 2 hangs.
    If I take the third 60 second snap of the system wide wait events as the zero point, and the 11th snap as the end point. There were 149 waits on ENQ: TX - ROW LOCK CONTENTION, 148 time outs, 446.62 seconds of total time in the wait event, with an average wait time of 2.997450 seconds.
    Rolling down to the session level wait events, SID 208 (my session 2) had 149 waits on ENQ: TX - ROW LOCK CONTENTION, for a total time of 446.61 seconds with an average wait time of 2.997383 seconds. All of the 149 waits and the wait time was in this one session that was locked up for the full duration of this time period because session 1 was making a pot of coffee.
    Rolling down to V$SESSION_WAIT (sampled roughly 4 times per second): At the start of the third time interval, SID 208 has been in the ENQ: TX - ROW LOCK CONTENTION wait event for 39 seconds and is actively waiting trying to execute SQL with a hash value of 1001532423, the wait object is -1, wait file is 0, wait block is 0, wait row is 0, P1 is 1415053316, P2 is 196646, P3 is 4754.
    At the end of the 11th time interval: , SID 208 has been in the ENQ: TX - ROW LOCK CONTENTION wait event for 483 seconds and is actively waiting trying to execute SQL with a hash value of 1001532423, the wait object is -1, wait file is 0, wait block is 0, wait row is 0, P1 is 1415053316, P2 is 196646, P3 is 4754.
    Rolling down to V$LOCK (sampled roughly 4 times per second): I see that SID 214 (session 1) is blocking SID 208 (session 2). SID 214 has a TX lock in mode 6 with ID1 of 196646 and ID2 of 4754. SID 208 is requesting a TX lock in mode 4 with ID1 of 196646 and ID2 of 4754.
    So, it seems that I need a faster coffee pot rather than an additional index on my table. It could be that the above process would have found that the application associated with SID 214 was abandoned or crashed and for some reason the lock was not released for a long period of time, a little less than 10.44 hours in your case.
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Heavy row lock contention

    Guys,
    I really appreciate your views on this.. Please can some one who have worked on RAC and have an understanding how RAC works, guide me.
    We currently are running a loadtest on one of the new RAC system and we are seeing excessive row lock contention for one table. The table basically has very few rows, say about 6-8 and pretty much every user uses this table to lock rows before fetching some data from other tables. When have a heavy load, we see very high wait on this table and enq TX : Row lock contention.
    What is the best way to avoid this ? Is there anyway, we can modify the design of the application and ensure locking.. The typical query that locks the rows in the table looks like this
    SELECT WL0.CLUB_NAME, WL0.SCHEDULE_ID FROM VF_BINGO_NEXT_CLUB_DRAW WL0 WHERE ( WL0.CLUB_NAME = :1 ) FOR UPDATE As said, they table has only 6-8 rows, so query plan etc doesn't apply. Please can someone who have extensive application knowledge guide me thru ?
    Many thanks in advance.
    G

    > But is there a way to alliviate the concurrency issue, if there is a genuine
    requirement to hold lock on a table. What other options do we have other
    than locking ?
    The purpose of a lock is to ensure data consistency - only 1 process can change that row. So what I find puzzling is why so many app sessions want to change that single row. What data does that row hold that requires continual change? Just what is the purpose of this data if it is consistently and continually changing? What business requirement does it attempt to solve?
    To be honest, this sounds like a major design problem to me.
    Like the surrogate key generator approach I mentioned. You create a PK_SEQUENCE table with columns (tablename, pk_value). Any insert against a table requires a lock on PK_SEQUENCE for the table being inserted into - a read of the PK_VALUE, incrementing it by one and then updating that row with the latest sequence. This way each INSERT gets a "nice sequential number" to use as surrogate key for new rows.
    Even when this is done as an autonomous transaction, it introduces a very expensive resource - why? Because only one session at a time can be serviced by that resource.
    If there are a lot of INSERTs into a table, this approach will quickly become a severe bottleneck as every single insert requires a new surrogate key value and a lock on that PK_SEQUENCE table to obtain that value.
    This problem is solved by allowing/enabling such a resource to serve multiple sessions concurrently. Which is for example what Oracle Sequence objects do within this example I've described.
    The bottom line is that the design you describe introduced a bottleneck by create an expensive and serialised resource that can only serve a single session at a time.
    You need to re-look at the business requirement - and find another way to solve it than to introduce this type of serialised resource and contention.

  • Row lock contention error to resolve

    hi,
    i m facing sever issue with row lock contention error for the statement and causing concurrency and application usage more making database vulnerable
    UPDATE RULE_DATA SET RULE_DATA = :B3 , UPDATED_BY = :B2 , UPDATED_DATE = SYSDATE WHERE RULE_DATA_SEQ_ID = :B1
    RETURNING PAT_GEN_DETAIL_SEQ_ID INTO :O0
    in this query RULE_DATA_SEQ_ID is primary key and and having index too, how can i over come row lock contention error ,
    if i try like this will it work
    UPDATE RULE_DATA SET RULE_DATA = :B3 , UPDATED_BY = :B2 , UPDATED_DATE = SYSDATE WHERE RULE_DATA_SEQ_ID = :B1
    RETURNING PAT_GEN_DETAIL_SEQ_ID INTO :O0
    log errors into temp_log (sysdate||:O0 ) REJECT LIMIT UNLIMITED;
    commit;
    please help me;

    select sid,  sql_text from v$session s, v$sql q
    where sid in (select sid from v$session
    where state in ('WAITING')
    and wait_class != 'Idle'
    and event='enq: TX - row lock contention'
    and (q.sql_id = s.sql_id or q.sql_id = s.prev_sql_id));
    from the above query if found the sid and sql_text,
    actually three procedures been called at once as a batch from java and given auto commit at once for the batch;
    and in one of the procedure it is called by multiple times with different seq_id's
    what i thought is by logging error can we skip the update statement from locking , this what happening
    where v_tariff_detail_seq_id will be 25,26,28,29,30 like records
    begin
    IF v_tariff_detail_seq_id = 0 THEN
    INSERT INTO pat_tariff_details (
    tariff_detail_seq_id,
    pat_gen_detail_seq_id,
    ward_type_id ,
    room_type_id ,
    days_of_stay ,
    requested_amount,
    approved_amount,
    maximum_allowed_amount,
    notes,
    added_by,
    added_date )
    VALUES (
    pat_tariff_details_seq.NEXTVAL ,
    v_pat_gen_detail_seq_id,
    v_ward_type_id ,
    v_room_type_id ,
    v_days_of_stay ,
    v_requested_amount ,
    v_approved_amount,
    v_maximum_allowed_amount,
    v_notes,
    v_added_by,
    SYSDATE );
    ELSE
    UPDATE pat_tariff_details SET
    room_type_id = v_room_type_id,
    days_of_stay = v_days_of_stay,
    requested_amount = v_requested_amount,
    approved_amount = v_approved_amount,
    maximum_allowed_amount = v_maximum_allowed_amount,
    notes = v_notes,
    updated_by = v_added_by,
    updated_date = SYSDATE
    WHERE tariff_detail_seq_id = v_tariff_detail_seq_id;
    END IF;
    end;
    version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    Edited by: user13134817 on Nov 2, 2012 2:39 AM

  • How to find sql causing "enq: TX - row lock contention"

    Hi,
    In one of our database we keep finding "enq: TX - row lock contention" for 2-3 days. But, then it stopped. The time it happened it blocked other sessions for some long time and it got resolved automatically. Now from ADDM report we got sql queries which waited for this but, we can not find which query from which module was causing the issue. What I should look for that past information. Please help.
    Database is 10gR2 on AIX.
    Regards,
    Gourab

    moreajays wrote:
    Try executing below query real time
    alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';
    SELECT  vp.spid,c.inst_id,b.session_id sid,c.serial#,a.object_name,
    a.owner object_owner,
    Decode(b.locked_mode, 0, 'None',
    1, 'Null (NULL)',
    2, 'Row-S (SS)',
    3, 'Row-X (SX)',
    4, 'Share (S)',
    5, 'S/Row-X (SSX)',
    6, 'Exclusive (X)',
    b.locked_mode) locked_mode,
    b.oracle_username,
    c.program,
    d.event,
    c.status,
    c.last_call_et,
    c.sql_address,
    e.sql_text, c.logon_time
    FROM   all_objects a,
    gv$locked_object b,
    gv$session c,
    gv$session_wait d,
    gv$sqlarea e,
    gv$process vp
    WHERE  a.object_id = b.object_id
    and b.session_id=c.sid
    and c.sid=d.sid and c.paddr=vp.addr
    and e.address=c.sql_address and lower(d.event) like '%enq%'
    ORDER BY 1;
    The OP asked for a way of find a historic blocker, not a current blocker.
    This query - apart from being one that no-one should want to run on a production system - doesn't say anything about the past, and doesn't identify a blocker.
    It reports the sessions that are being blocked, and EVERY table that is currently locked by each session whether or not the table is involved in the current statement.
    You're using the gv$ (RAC) views but haven't put in any suitable join predicates on the instance (inst_id) columns; the OP is on 10g so you don't need to join to v$session_wait to pick up the wait information; and the join to v$sqlarea forces a "full tablescan" of the library cache (child cursor derived view) because you're joining on address rather than sql_id.
    Regards
    Jonathan Lewis

  • Front Row Locking up

    Hello Front Row Support forum!
    I recently upgraded to Leopard (Much <3 for the new version of OS X) and I've actually started using Front Row. I really like the new look and it fits into my lifestyle more now to use it.
    Unfortunately though, Front Row has been periodically locking up when I listen to music. It becomes completely non-responsive and I can't even force my way out of it. I've actually had to resort to turning my laptop completely off
    Any suggestions, fixes, or magic tricks to help me?

    I have the same problem with locking up. And the escape key combo doesn't work, I'm sorry to say.
    As I wrote in another post ( http://discussions.apple.com/thread.jspa?threadID=1393270&tstart=0 ) it seems (I know this will sound idiotic) to lock up only when the song name is so long that it must scroll (while the song is playing) to show the whole name (this is mainly classical music, which often has long "song" titles). It is when that annoying "flip" occurs, putting the album and song info on the reverse sides, that these Front Row locks always seem to happen. Though at other times the lock seems to come arbitrarily. Sounds very similar to all the problems described above.

  • Row lock class concurrency Monitor

    Greetings,
    We are getting ready to release my first webapp and need a �row-locking� class of sorts. For example, when a user logs in they have choices of searches where they can query the db. There is a link in the reulstSet that brings them to a detail screen. If that �detail� or row is currently open in a browser, I want to know about it.
    I wonder about when a user closes their browser from the �detail� view, how can I know?
    I am thinking about using a filter to track all active 'rows' and using an application scope class to track the 'locked' rows. I am developing on a Mainframe db (DMSii) that has essentially no modern capabilities. We use struts as a framework and EAServer as a container.
    I could be so far from base that I am a spectator, so if there is any CONSTRUCTIVE advice or examples to point to, It would be greatly appreciated.
    thanks,
    mccools

    You can use Rowset, RowsetEvent and RowSetListener implementation for tracking the rows.
    "I wonder about when a user closes their browser from the �detail� view, how can I know?"
    For this you can use the SessionBindingListener implementation.
    Hope this helps.
    Regards,
    Rohan Kamat

  • Row lock on db2

    we are using db2 udb v8.1, with the type 4 jcc jdbc driver. does anyone know how to create a row lock while i open a resultset? i do select ... from .. where ... for update of ...... is not working. i need to have a row lock while my cursor is move backward or forward in the resultset. thanks

    I'm looking for the answer too....
    anyway i want lock a row and detect row lock... for
    microsoft access....good luck finding this... access doesn't support row locking.

  • How can I retain updates made in multiple locked rows and override scope rollback defined for row locking purposes ?

    I have a set of stored procedures in SQL
    One of which is called to build a list of entries to submit to a web service
    Those queries are called by identical processes running on different machines, so to prevent duplicate processing we lock rows that are presently being processed.
    BEGIN
    TRAN TRAN1
    SELECT t.[TransactionId],t.[ContentIdentifier]
    FROM [dbo].[Transactions]
    t WITH(READPAST,
    UPDLOCK,
    ROWLOCK)where
    (t.Quarantined
    <> 1)
    COMMIT
    A Second stored procedure simply updates the Quarantined flag.
    My C# code
    TransactionOptions transactionOptions
    =
    new
    TransactionOptions();
    transactionOptions.IsolationLevel
    =
    IsolationLevel.ReadCommitted;
    transactionOptions.Timeout
    =
    new
    TimeSpan(0,
    10,
    0);
    using (TransactionScope
    scopeMain =
    new
    TransactionScope(TransactionScopeOption.Required,
    transactionOptions))
    TransactionsReady = DAL.GetFilesForProcessingByServiceType(i);
    using (TransactionScope
    scopeSuppress =
    new
    TransactionScope(TransactionScopeOption.Suppress,
    transactionOptions))
    foreach (var
    Transaction in TransactionsReady)
    { try
    returnData = proxy.Submit(stuffToProcess);
    using (var
    scopeInner =
    new System.Transactions.TransactionScope())
    DAL.QuarantineTransaction(Transaction.TransactionId);
    scopeInner.Complete();
    scopeSuppress.Complete();
    scopeMain.Complete();
    The problem I experience is that if I have the Transaction Scope scopeSuppress uncommented, then the QuarantineTransaction stored procedure deadlocks.
    However if I comment out the ScopeSuppress, while the process then works, if it is interrupted mid-way, then all of the Quarantine flags get reset, meaning the entire batch of items will get re-submitted next
    pass (this is not desirable).
    What I actually want to occur, is for the Quarantine flag to be retained on all processed records so that even if the program terminates unexpectedly, processed items remain processed but all the row locks are
    released.
    Does anyone know of a way to achieve this ?

    The hour is late where I sit, so I don't have the time to dive into this in detail.
    However, if memory serves, TransactionScopes defaults to Serializable isolation level, which may explain the deadlocks you are getting.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • V$system_event, timeouts and row lock contention

    Hello everyone,
    What is the meaning of the total_timeouts column in the v$system_event view if it is related to the event "enq: TX - row lock contention"?
    How can we have a timeout since "query timeout" is a non existent concept on Oracle?
    Maybe I am wrong.
    Regards.
    Carl

    Hello everyone,
    What is the meaning of the total_timeouts column in
    the v$system_event view if it is related to the event
    "enq: TX - row lock contention"?
    How can we have a timeout since "query timeout" is a
    non existent concept on Oracle?
    Maybe I am wrong.
    Regards.
    CarlThe value for timeouts, in this case, indicates the number of times one of the sessions had to wait a full 3 second time slice while waiting for a second session to either commit or roll back, in anticipation of a potential primary key violation. If the second session commits, the first session will receive an error indicating a primary key violation.
    Test setup:
    In session 2:
    CREATE TABLE T1 (C1 VARCHAR2(20) PRIMARY KEY);
    INSERT INTO T1 VALUES ('ORACLE');
    In session 1:
    INSERT INTO T1 VALUES ('ORACLE');
    After executing tha above, allow 60 seconds to elapse after the insert in session 1, and then check the delta values in either V$SYSTEM_EVENT or V$SESSION_EVENT:
    20 waits on ENQ: TX - ROW LOCK CONTENTION, 19 timeouts, 59.99 seconds, with an average wait of 2.9995 seconds.
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Error while upgrading OBIEE10g RPD to 11g Cannot release MBean - not locked

    Hi,, I have successfully installed OBIEE 11g and now truing to upgrade 10g RPD to 11g RPD using Upgrade Assistant. The process gets failed with following error in the LOG file;
    *[2013-02-19T00:54:53.367+05:30] [bi] [NOTIFICATION] [oracle.bi.security] Adding member 'REPORTING_USER' to role 'REPORTING_USER'*
    [Comment] The above line is last line without any WARNING or ERROR, the WARNING and ERROR starts brom next line (below)
    *[2013-02-19T00:56:55.375+05:30] [BIEE] [WARNING] [upgrade.BIEE] Cannot release MBean - not locked*
    *[2013-02-19T00:56:55.376+05:30] [BIEE] [ERROR] [upgrade.BIEE] javax.management.OperationsException: WARNING: Element Type: DOMAIN[[*
    Element Id: null
    Operation Result: FAILED_TO_APPLY_CHANGES
    Detail Message: Timeout; Waiting for all managed servers to push configuration changes; [120 secs]; AdminServer
    Please help.
    Edited by: 923934 on Feb 25, 2013 2:41 AM

    while upgrading the RPD make sure that user weblogic server must be up and running including the all the BI Services.
    first look into these servers and run the upgrade utility.
    let me know is there any issues.
    Regards,
    Yogi.

Maybe you are looking for

  • How to use Find my Mac on a different iCloud account?

    I have my own iCloud account set on my mac and on my iPhone, however on my iPhone, I manage to use my dad's iCloud account so he can use the find my iphone app on my phone. I do this while still having all other icloud stuff (eg. imessage or app stor

  • New Infotype Framework

    Hello! I'm just going to implement a new Infotype that should use the Data Sharing functionality for Concurrent Employment. I've read a document about the implementation of the "new" Infotype Framework, but I haven't found an example how to use it fo

  • Contact customer support

    Absolutely incredible. It took me 22 minutes to get to some place on this site where I could contact - anyone or anything. I wanted to contact customer support or technical support but I just kept getting shipped around all over the site always loopi

  • Clusterware Upgrade 12.1.0.2 complete

    Hi, Currently the cluster with the entire GI + RDBMS 11.2.0.4 stack with BP 11.2.0.4.12 (October 2014) is installed. Now, a upgrade will be made to 12.1.0.2. - Step 1 => GI 12.1.0.2 - Step 2 => CPU 12.1.0.2.4 How to check whether a GI 12.1.0.2 instal

  • Pay On Receipt AutoInvoice

    Is Pay On Receipt AutoInvoice program operating unit or responsibility specific? We have 2 OUs. Do we run it for each OU?