Question on Lock in In-Doubt Transaction

Dear All,
Could you kindly explain me why distributed transaction imposes a lock on read also with write? During Read, Select statement also uses rollback segment.
But in the document “Oracle9i - Database Administrator’s Guide Release 2 (9.2) - March 2002 Part No. A96521-01” at page 31-16, it has been written that
“the data is locked for both reads and writes. Oracle blocks reads because it cannot determine which version of the data to display for a query.”
So could we come to a conclusion that distributed transaction does not use rollback segment.
But at page 31-18, under manual resolution of In-Doubt Transaction, the first point is that the in-doubt transaction has locks on critical data or rollback segment.
Therefore, rollback segment is using during distributed transaction. So why does Oracle impose a lock on READ the data?
Regards,
Student

Redo logs are effectively write-only under normal circumstances. The database NEVER goes back to read the redo log unless it is in crash recovery mode.
Therefore, even though the information has been recorded in the online redo log, that information can not be used to roll back a failed in-doubt transaction. The rollback information MUST come from the rollback segment or from some other online location.
(I am not taking this as an argument - it's helping me as well.)

Similar Messages

  • ORA-01591 Lock held by in doubt transaction

    We have this error
    ORA-01591 Lock held by in doubt transaction
    this error appear randomly when
    in the same transaction we use inser,delete or update sentence and a call to MS-MSMQ ( asynchronous transaction)
    (Oracle 9i 9.2.0.5, HP Itanium Unix)
    (Web application with .NET ODP Provider)
    thanks for your help

    Hi Vivek,
    This error is encountered by many DBA's and cause problem by locking the distributed transaction process, and not letting the query go through, because the Two - Phase Commit Mechanism got an error somewhere.
    he DBA should query the pending_trans$ and related tables, and attempt to repair network connection(s) to coordinator and commit point.
    Here are some codes to help you through the process:
    This one brings in-doubt transactions:
    select * from DBA_2PC_PENDING where state='prepared'
    This one prepares the rollback script for the transactions:
    select 'rollback force '''||local_tran_id||''';' from DBA_2PC_PENDING where state='prepared'
    All this is well described in below link
    ORA-01591: lock held by in-doubt distributed transaction
    ORA-01591: lock held by in-doubt distributed transaction string tips
    On BizTalk Side you need to make ambient transaction to false as Oracle does not go ahead with DTC Transaction with  Biz Talk
    Thanks
    Abhishek

  • Questions on Locking-- URGENT

    Here are my questions on Locking.:
    1)
    How do I use v$lock to figure out lock details ? Details like
    whos has locked,on which table,who else is waiting, and what type
    of locking (shared or exlusive ?), since when it is locked.
    2)
    Why and when exclusive/shared locks are used ? Could you give me
    example please ?
    3)
    Could you tell me significance of v$mystat and v$locked_object ?
    4)
    Do we have page level locking in Oracle ?
    Thanks in advance,
    DN

    Details about locks : All locks acquired by statements within a transaction are held for the duration of the transaction.
    Oracle releases all locks acquired by the statements within a transaction when an explict or implied commit or roll back is executed. Oracle also releases locks acquired after a savepoint when rolling back to the savepoint.
    Note: Only transactions not waiting for the previously locked resources can acquire locks on now available resources. Waiting transactions continue to wait until after the original transaction commits or completely rolls back.
    1. How do I use v$lock to figure out lock details? Details like
    whos has locked,on which table,who else is waiting, and what type
    of locking (shared or exlusive ?), since when it is locked.
    Better way is to use Oracle OEM. The TYPE column in v$lock shows the type of wait events and we also have the LMODE column (lock mode) and REQUEST columns.
    Here is a comprehensive v$lock query by Deepak Baranwal, listing the lock types:
    set echo off
    col sid form 9999
    col id1 form 9999999999
    col id2 form 999999999
    col lmode head "Lock Held" form a14
    col request1 head "Lock Request" form a16
    col type head "Lock Type" form a15
    col ctime head "Time|Held" form 999999
    col block head "No Of |Sessions|Waiting|For This|Lock" form 99999
    select sid,
    DECODE(TYPE,
    'BL','Buffer hash table',
    'CF','Control File Transaction',
    'CI','Cross Instance Call',
    'CS','Control File Schema',
    'CU','Bind Enqueue',
    'DF','Data File',
    'DL','Direct-loader index-creation',
    'DM','Mount/startup db primary/secondary instance',
    'DR','Distributed Recovery Process',
    'DX','Distributed Transaction Entry',
    'FI','SGA Open-File Information',
    'FS','File Set',
    'IN','Instance Number',
    'IR','Instance Recovery Serialization',
    'IS','Instance State',
    'IV','Library Cache InValidation',
    'JQ','Job Queue',
    'KK','Redo Log "Kick"',
    'LS','Log Start/Log Switch',
    'MB','Master Buffer hash table',
    'MM','Mount Definition',
    'MR','Media Recovery',
    'PF','Password File',
    'PI','Parallel Slaves',
    'PR','Process Startup',
    'PS','Parallel Slaves Synchronization',
    'RE','USE_ROW_ENQUEUE Enforcement',
    'RT','Redo Thread',
    'RW','Row Wait',
    'SC','System Commit Number',
    'SH','System Commit Number HWM',
    'SM','SMON',
    'SQ','Sequence Number',
    'SR','Synchronized Replication',
    'SS','Sort Segment',
    'ST','Space Transaction',
    'SV','Sequence Number Value',
    'TA','Transaction Recovery',
    'TD','DDL enqueue',
    'TE','Extend-segment enqueue',
    'TM','DML enqueue',
    'TS','Temporary Segment',
    'TT','Temporary Table',
    'TX','Transaction',
    'UL','User-defined Lock',
    'UN','User Name',
    'US','Undo Segment Serialization',
    'WL','Being-written redo log instance',
    'WS','Write-atomic-log-switch global enqueue',
    'XA','Instance Attribute',
    'XI','Instance Registration',
    decode(substr(TYPE,1,1),
    'L','Library Cache ('||substr(TYPE,2,1)||')',
    'N','Library Cache Pin ('||substr(TYPE,2,1)||')',
    'Q','Row Cache ('||substr(TYPE,2,1)||')',
    '????')) TYPE,
    id1,id2,
    decode(lmode,
    0,'None(0)',
    1,'Null(1)',
    2,'Row Share(2)',
    3,'Row Exclu(3)',
    4,'Share(4)',
    5,'Share Row Ex(5)',
    6,'Exclusive(6)') lmode,
    decode(request,
    0,'None(0)',
    1,'Null(1)',
    2,'Row Share(2)',
    3,'Row Exclu(3)',
    4,'Share(4)',
    5,'Share Row Ex(5)',
    6,'Exclusive(6)') request1,
    ctime, block
    from
    v$lock
    where sid>5
    and type not in ('MR','RT')
    order by decode(request,0,0,2),block,5
    2 .Why and when exclusive/shared locks are used ? Could you give me
    example please ?
    Exclusive Lock Mode : Prevents the associates resource from being shared. This lock mode is obtained to modify data. The first transaction to lock a resource exclusively is the only transaction that can alter the resource until the exclusive lock is released.
    Share Lock Mode : Allows the associated resource to be shared, depending on the operations involved. Multiple users reading data can share the data, holding share locks to prevent concurrent access by a writer (who needs an exclusive lock). Several transactions can acquire share locks on the same resource.
    Oracle Lock Types
    DML locks (data locks)
    DDL locks (dictionary locks)
    Oracle Internal Locks/Latches
    Oracle Distributed Locks
    Oracle Parallell Cache Management Locks
    3. Could you tell me significance of v$mystat and v$locked_object ?
    v$locked_object show the information about Who is locking and what object they locking. This view is similar to v$mystat except that it shows cumulated statistics for all sessions.
    4. Do we have page level locking in Oracle ? No
    Sachin

  • Weblogic leaves in-doubt transaction on Oracle when it fails

    Hi,
    I'm looking at resilience with our Weblogic (6.1sp2) and Oracle
    (8.1.7) environment, and have been doing a few tests. We're using the
    Oracle OCI (thick) driver, in "XA" mode (i.e. using the "Driver"
    oracle.jdbc.xa.client.OracleXADataSource). We need to do this because
    our application uses JMS/Message driven beans to intiate a lot of the
    work, and any database activity that fails needs to be rolled back
    together with the message and any other work. We don't "enable
    two-phase commit" as shown on the TxDatasource config, so get real XA
    behaviour, with JMS and the JDBC connection as the XA resources.
    The problem is when/if Weblogic dies. As WLS is the transation
    manager, if a transaction is in-flight at the time WLS fails the XA
    resources need to take action. If the TM fails after the transaction
    starts but before the prepare() calls, it seems as though things
    generally work out; Oracle rolls back its transactions, and when WLS
    is restarted, the JMS messages are recovered and re-delivered (after
    the initial delay period of five minutes). The problem seems to be
    when WLS dies between the prepare and the commit. In this case, Oracle
    holds the various locks it needs to commit the transaction, and when
    WLS is restarted it doesn't seem to inform the XA resources that the
    transaction should be rolled back/abandoned. Until a DBA sorts out the
    problem, any attempts to use the locked areas (e.g. anything that does
    a table scan or uses specific rows) result in errors of the form:
    ORA-01591: lock held by in-doubt distributed transaction 18.65.2221
    This is sensible as far as Oracle's concerned - it doesn't know if any
    other XA resources committed or rolled back their transactions.
    However, I'd have expected WLS, as the TM, to have sent the necessary
    instructions to Oracle once the transaction has been recovered.
    Nothing in WL's logs implies it's trying to do anything with recovered
    transactions.
    I've managed to make this repeatable. I have a class which I can send
    a JMS message to kill the server. This MDB calls
    Runtime.getRuntime.halt(1) (to simulate a serious crash) either during
    the transaction (in onMessage()) or registers its own "XA killer"
    resource which calls halt(1) in the prepare(). In the latter case I
    always get an in-doubt transaction.
    Anyone else had this behaviour, and more importantly, know how to
    resolve it?
    James

    Lou,
    any information about the results of testing of the patch from oracle for 'in-doubt
    transaction' problem?
    Thanks
    Sanjay
    "Fei Luo" <[email protected]> wrote:
    >
    James,
    Our support engineer is still testing the patch from Oracle. I
    will keep you updated on this.
    [email protected] (James Elson) wrote:
    "Fei Luo" <[email protected]> wrote in message news:<3cee9c1c$[email protected]>...
    Are you using Oracle817? Yes, we are.
    There is a known Oracle817 bug that may be related to
    your problem. You may try Oracle901.Ah. Such an upgrade would have major implications on our architecture.
    Do you have any more information on this bug (a bug number etc)?
    Would we have to upgrade the server, or just the clients?
    James

  • How to create an in-doubt transaction?

    I need to create/force an MSDTC in-doubt distributed transaction to verify that they are resolved automatically. The code successfully participates in the transaction via OraMTSSvcGet and OraMTSSvcEnlist and works as expected. I have tried creating in-doubt transactions via constraint violations, table locking, killing the application, killing the Oracle session, etc. but can't force an error between the first and second phase of the commit( which I think is the trick). Any ideas?
    Message was edited by:
    jgbell

    If your site is dynamically populated with content from server-side databases, it's not hard.
    If your site is static, a 3rd party search function might be a better choice until you're ready to build a dynamic site.
    Zoom search engine
    http://www.wrensoft.com/zoom/
    Freefind
    http://www.freefind.com/
    Setting up a PHP environment in Dreamweaver
    http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html
    Building your first dynamic website – Part 1: Setting up your site and database connection
    http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt1.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Unable to rollback in-doubt transactions

    We are using Oracle 10g R2 on Linux platform. When I execute the below rollback statement, it executes successfully but the state of the transaction remains same i.e. prepared. Due to this, when we try to update some row in the table, "ORA-01591 lock held by in-doubt distributed transaction..." is thrown by sqlplus.
    ROLLBACK FORCE '10.10.36244821';
    Followings are the contents of DBA_2PC_PENDING
    LOCAL_TRAN_ID
    GLOBAL_TRAN_ID
    STATE
    MIXED
    FAIL_TIME
    RETRY_TIME
    OS_USER
    OS_TERMINAL
    HOST
    COMMIT#
    10.10.36244821
    1463898948.00000143D0D116E10000000C00003B1F001F318F7CB4CAB62B82A96CF3CE98C592462030
    prepared
    no
    01/27/2014 00:12:28
    01/28/2014 12:01:48
    was
    unknown
    rzyz.lj.et
    11201668706058
    Followings are the contents of DBA_2PC_NEIGHBORS
    LOCAL_TRAN_ID
    IN_OUT
    DATABASE
    DBUSER_OWNER
    INTERFACE
    DBID
    SESS#
    BRANCH
    10.10.36244821
    in
    jdbc_699
    xyz
    N
    jdbc_ttc_impl
    4.0000
    00000143D0D116E10000000C00003B1F001F318F7CB4CAB62B82A96CF3CE98C592462030000000010000000000000000000000000005
    10.10.36244821
    in
    jdbc_713
    xyz
    N
    jdbc_ttc_impl
    3.0000
    00000143D0D116E10000000C00003B1F001F318F7CB4CAB62B82A96CF3CE98C592462030000000010000000000000000000000000004
    10.10.36244821
    in
    jdbc_700
    xyz
    N
    jdbc_ttc_impl
    2.0000
    00000143D0D116E10000000C00003B1F001F318F7CB4CAB62B82A96CF3CE98C592462030000000010000000000000000000000000003
    10.10.36244821
    in
    jdbc_702
    xyz
    N
    jdbc_ttc_impl
    1.0000
    00000143D0D116E10000000C00003B1F001F318F7CB4CAB62B82A96CF3CE98C592462030000000010000000000000000000000000002
    We are using a JEE appliction (EJB) on IBM WebSphere that is generating ORA-01591 error in the log file when it runs the update statement against a table.

    See http://support.oracle.com:
    note 126069.1 "Manually Resolving In-Doubt Transactions"
    note 100664.1 - Master Note for Oracle managed distributed transactions

  • RECO何时清理in-doubt transaction

    关于in-doubt transaction清理,管理员手册说到:
    The RECO background process of an Oracle Database instance automatically resolves failures involving distributed transactions. At exponentially growing time intervals, the RECO background process of a node attempts to recover the local portion of an in-doubt distributed transaction.
    那么这个exponentially growing time intervals如何算法,RECO到底等多久才会出来“大扫除”呢?
    如果,没有发生1591之类的报错,是不是可以不必理会,死等RECO出来干活儿呢?
    昨天遭遇了in-doubt transaction事件,由于某个DB达到最大会话数引起,在恢复正常后,至少两个小时内,pending事物还没有被自动清理,后来手工rollback force处理的。
    并且观察到,在手工干预之后又过了几十分钟,dba_2pc_pending中的rollback force记录确实被自动清理掉了,
    故有此问

    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> set linesize 200
    SQL> set pagesize 1400
    SQL> SELECT x.ksppinm NAME,y.ksppstvl VALUE, x.ksppdesc describ
      2   FROM SYS.x$ksppi x, SYS.x$ksppcv y
      3   WHERE x.inst_id = USERENV ('Instance')
      4   AND y.inst_id = USERENV ('Instance')
      5   AND x.indx = y.indx
      6  AND x.ksppinm like '%distributed%';
    NAME                           VALUE      DESCRIB
    distributed_lock_timeout       60         number of seconds a distributed transaction waits for a lock
    _distributed_recovery_connection_hold_time 200        number of seconds RECO holds outbound connections open
    distributedrecovery_connection_hold_time 隐藏参数默认为200s, 控制了Oracle会允许一个失败的事务连接持续打开, 该参数最大可以设置为4,294,967,295s, 但是RECO进程仍会每30分钟会唤醒一次并处理失败的分布式事务。 默认值200一般是建议的, 不需要额外修改。
    注意分布式事务 会让数据库不稳定, 分布式事务是方便的 ,但是分布式事务是罪恶的(evils)
    *<font color="red" size="2" face="courier">如果觉得本回复有意义,请点击本条回复右手边的Correct按钮,谢谢!</font>*
    如何在OTN中文技术论坛提一个问题?
    论坛礼仪需知及学习oracle的方法论
    Maclean Liu
    Oracle Database Administrator
    Oracle Certified 10g/11g Master     
    www.askmaclean.com

  • Is it possible to lock and unlock a transaction?

    Hi SDN,
    Is it possible to lock and unlock a standard transaction( for eg VA02 ) through my program?( i am creating a customized version of standard transaction ) I want to lock the transaction for my user-id and then i will update the values in that transaction and finally i will unlock it.
    I got the FM for locking at the database level.is there is any FM to lock and unlock the transaction?

    Hi,
    It may not be the best way, but maybe you could use the functionality behind transaction code SM01. Here you can lock/unlock the transaction code. If you look at the program, all it is really doing is updating table TSTC field CINFO. CINFO = 80 when unlocked, CINFO = A0 when locked. You could just update the field accordingly and then call this function module right after.
    * For locking
    CALL FUNCTION 'RSAU_WRITE_SM01_LOG'
      EXPORTING
        TCODE = TSTC-TCODE
        LOCK = 'X'.
    * For unlocking
    CALL FUNCTION 'RSAU_WRITE_SM01_LOG'
      EXPORTING
        TCODE = TSTC-TCODE
        UNLOCK = 'X'.
    Regards,
    Ferry Lianto

  • Questions about Territory determination in Business transactions in CRM 7.0

    Hi All,
    We are in the process of configuring territory management in our system. I have a couple of questions regarding Territory determination in Business transactions in CRM 7.0.
    1) Territories in business transactinos are determined based on partner function categories: employee and person responsible. If the employee is assigned to multiple territories, which territory is determined for the transaction.
    a) Is it the territory for which he is assigned the 'Default territory' flag'?
    b) What if the employee does not have any territories with the 'Default territory' set?
    2) We have had SAP CRM since the last 6-7 years and recently upgraded to CRM 7.0. When I use the transaction searches in the Web UI using the search parameters 'Territory ID' and 'Territory description' we can't see any old transactions in the search results. We can only see the test transactions that were created after we ran the master data reln. update program CRM_TERRMAN_PROC_REL. Is there another program which updates transactional data relationships similar to the master data one?
    Appreciate your inputs.
    Regards,
    Ramesh Nallabelli

    Hi All,
    We are in the process of configuring territory management in our system. I have a couple of questions regarding Territory determination in Business transactions in CRM 7.0.
    1) Territories in business transactinos are determined based on partner function categories: employee and person responsible. If the employee is assigned to multiple territories, which territory is determined for the transaction.
    a) Is it the territory for which he is assigned the 'Default territory' flag'?
    b) What if the employee does not have any territories with the 'Default territory' set?
    2) We have had SAP CRM since the last 6-7 years and recently upgraded to CRM 7.0. When I use the transaction searches in the Web UI using the search parameters 'Territory ID' and 'Territory description' we can't see any old transactions in the search results. We can only see the test transactions that were created after we ran the master data reln. update program CRM_TERRMAN_PROC_REL. Is there another program which updates transactional data relationships similar to the master data one?
    Appreciate your inputs.
    Regards,
    Ramesh Nallabelli

  • In Doubt transactions

    In Oracle, how do you find out if there are any in doubt transactions
    In DB2, its
    DB2>LIST INDOUBT TRANSACTIONS
    How would you do this in Oracle ?

    desc dba_2pc_pending
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/ds_txnman003.htm
    SELECT local_tran_id, global_tran_id, state, mixed, advice, tran_comment FROM dba_2pc_pending;

  • The apple account number had the question to lock the account number

    The apple account number had the question to lock the account number

    Try resending the verification email by going to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right click Resend under your Primary Email Address.

  • Oracle BPM Issue - By lock held by indoubt transaction

    Hi ,
    I am getting the below issue while processing the work items(Applications) in the Oracle BPM. I am using Oracle BPM 10g R3 (10.3.1.0.0  Build# 100812) in Linux Environment.
    An unexpected error occured while trying to execute an automatic task,pending automatic tasks will continue to be executed. Details:\n"An error occured while accessing the database. Detail: SQL statement: 'SELECT DUETIME, ID, PROCESSID,INSTDID, THREADID, ANCESTORTHREADID, TSTAMP, TYPE, ACTIVITYNAME,ORIGINPROCESSDN, REAL THREADID, NETYPE, PRIORITY, LATER, DATA FROM PTODOITEMS WHERE DUETIME=2011-12-22 11:23:53.0 AND PROCESSID=31 AND ID=94370151 FOR UPDATE' Caused by :[BEA][Oracle JDBC Driver][Oracle]ORA-01591: lock held by in doubt distributed transaction 9.30.1176766 fuego.transaction.DatabaseException; An error occured while accessing the database. Detail:SQL statment: 'SELECT DUETIME, ID, PROCESSID,INSTDID, THREADID, ANCESTORTHREADID, TSTAMP, TYPE, ACTIVITYNAME,ORIGINPROCESSDN, REAL THREADID, NETYPE, PRIORITY, LATER, DATA FROM PTODOITEMS WHERE DUETIME=2011-12-22 11:23:53.0 AND PROCESSID=31 AND ID=94370151 FOR UPDATE' at
    If I force COMMIT the Transaction 9.30.1176766 in the dba_2pc_pending, pending_trans$, pending_sessions$ tables, I am able to move forward.
    Please help me to resolve this issue.
    Thanks In Advance.
    Bhaskara

    Hi ,
    I am getting the below issue while processing the work items(Applications) in the Oracle BPM. I am using Oracle BPM 10g R3 (10.3.1.0.0  Build# 100812) in Linux Environment.
    An unexpected error occured while trying to execute an automatic task,pending automatic tasks will continue to be executed. Details:\n"An error occured while accessing the database. Detail: SQL statement: 'SELECT DUETIME, ID, PROCESSID,INSTDID, THREADID, ANCESTORTHREADID, TSTAMP, TYPE, ACTIVITYNAME,ORIGINPROCESSDN, REAL THREADID, NETYPE, PRIORITY, LATER, DATA FROM PTODOITEMS WHERE DUETIME=2011-12-22 11:23:53.0 AND PROCESSID=31 AND ID=94370151 FOR UPDATE' Caused by :[BEA][Oracle JDBC Driver][Oracle]ORA-01591: lock held by in doubt distributed transaction 9.30.1176766 fuego.transaction.DatabaseException; An error occured while accessing the database. Detail:SQL statment: 'SELECT DUETIME, ID, PROCESSID,INSTDID, THREADID, ANCESTORTHREADID, TSTAMP, TYPE, ACTIVITYNAME,ORIGINPROCESSDN, REAL THREADID, NETYPE, PRIORITY, LATER, DATA FROM PTODOITEMS WHERE DUETIME=2011-12-22 11:23:53.0 AND PROCESSID=31 AND ID=94370151 FOR UPDATE' at
    If I force COMMIT the Transaction 9.30.1176766 in the dba_2pc_pending, pending_trans$, pending_sessions$ tables, I am able to move forward.
    Please help me to resolve this issue.
    Thanks In Advance.
    Bhaskara

  • A string of question about Locking & Isolation Level

    Hi All
    It is highly appreciated if someone give offer answers to my below questions
    1) There are two ways of locking mechanism: Pessimistic & Optimistic. In general, do all J2EE app server support all these two ways of locking ?
    2) It seems to me that setting the isolation level to "serialization" should result in using pessmistic locking. If no so, please point out my misconcept and explain to me.
    3) Are there any differences in the way of entity bean programming as different locking mechansim is adopted ?
    4) With regard to optimistic locking, will the app server throw out exception as data contention is detected ? Is the way of handling dependent on app server? Or It is transparent to the developer of entity bean. Please give me an e.g of j2ee app server product how to handle this scenario.
    5) To adopt the approach of "optimistic" locking, do l have to implement it on my own using bean managed entity bean.
    6) It seems to me that optimistic locking can achieve better concurrency. If it is inherently supported by app server for its container managed entity bean (=> totally transparent to the developer of entity bean). Is it always the rule of thumb to config the server to use "optimistic" locking instead of "pessimistic" ?
    Sorry for bombarding you guys with such long list of questions. l would be very thankful if someone can help me consolidate my concept on these topics.
    Also, please send your reply to [email protected] as well
    thanks & regards
    Danny

    Hi Danny,
    I became interested about the optimistic locking recently. If the topic is not long forgotten then this may make some difference!
    We have attacked the optimistic locking issue by introducing audit fields (MODIFY_BY_USER, MODIFY_DATE) in tables where concurrency needs to be implemented.
    We are retrieving rows from the table (for display or update) through Stateless Session Bean using simple SQL SELECT. The audit fields are fetched along with the business data and are kept at the client. While any of the concurrent users tries to update the row the audit fields are sent to the application server along with the modified business data. The relevant Entity Bean checks for any difference in the timestamp of the audit field (MODIFY_DATE) value with the value in the database. If a mismatch is found it reports a business exception to the user. Otherwise, the row is updated with the lastest timestamp value in the audit field MODIFY_DATE.
    This works fine when two update operations are not concurrent, i.e., two users submit their update requests in a time lag greater than the time taken by the transaction to complete. This alone could not prevent the dirty update on the database.
    Hence, to prevent any concurrent update contending for the same row you need to set the following ejbgen tag in the Entity Bean:
    concurrency-strategy = Exclusive<<<<<Note: We are using Weblogic 6.1 with SP4 and CMP (no BMP).
    Please let me know if you have got a better solution to tackle this issue.
    Chandra.

  • Question about locking order during merge statement

    Dear all.
    I have a merge query with a decedent hint to prevent deadlock with another queries.
    Another queries use select ~for update with same hint.
    My question is that the locking order will follow the hint in this query?
    Or I might use the select ~ for update before this merege.
    Please give any advice about select ~for update and locking order in the query.
    Thanks.
    MERGE INTO  A
    USING
         (SELECT /*+ index_desc(C index_key) */ *
         FROM
             C
          WHERE key > :start and key < :end
        ) B
         ON  ( A.KEY = B.KEY )
    WHEN MATCHED THEN
         UPDATE
         SET A.v1 = B.v1

    What you are doing is not going to prevent a deadlock in your, as yet, unknown version of Oracle. Reading an index does not cause deadlocks. Trying to alter an uncommitted row does.
    I would suggest you code this correctly by doing a SELECT FOR UPDATE WAIT <seconds> in all transactions.
    http://www.morganslibrary.org/reference/deadlocks.html#dlfu

  • Question about Lock Duration

    Hi,
    I found a description at this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/content.htm
    'At the end of an SAP LUW, you should release all locks. This either happens automatically during the database update, or explicitly, when you call the corresponding dequeue function module. Locks that are not linked to a database update are released at the end of the SAP transaction'
    I don't understand this, because I tested using commit work and wait. The lock entry still there after the statement 'commit' executed. the lock entry disappeared when the whole task completed.
    don't know what does happens automatically during the database update. Isn't the 'commit' the case they mentioned?

    So does that means even I using a SYNCHRONIZE commit. There still not a database update happen?
    From help.sap.com:
    For 'commit work' "It triggers a database commit that also terminates the current database LUW and closes all database cursors. "
    Database commit <> database update ?

Maybe you are looking for