Deadlock problem

Hello,
I had to modify a program that initially did not allow concurrent access, and now I have a deadlock issue. The method where the problem appears contains the following operations: a select from the DB (returns some ids to be cancelled), then 2 deletes from two different tables (of the rows with the ids returned by the select). The db is Oracle by the way. Right.. so.. I launch the web application(jsf) from two different browsers, and I want to calculate something simultaneously.
Thread 1 does select and delete from tbl1/delete from tbl2 of record {color:#ff0000}27242{color}, then
Thread 1 does select and delete from tbl1/delete from tbl2 of record 27247, then
Thread 2 does select and delete fromtbl1/delete from tbl2 of record 27319, then
Thread 1 does select and delete from tbl1 and tries to delete from tbl2 record{color:#ff0000} 27243{color} and deadlock occurs, Thread 1 is killed, the other one finishes the job. The deadlock occurs when Thread 2 tries to make the delete from tbl2, according to the jboss log.
Any ideas?
Thank you,
Ioana.

Well, these operations are part of a loop and I'm supposed to commit, close db connection only at the end, otherwise there is the risk to have inconsistent data.
It seems strange to me that thread 1 manages to make select/delete/delete twice, then thread 2 does once, and only after that i get deadlock.. I made some more tests, the chain could be even longer.. thread 1 is killed only when it tries to delete a row close to a row it canceled before. Plus, I'd have expected a deadlock when thread 2 tries to do the select (after thread 1 deleted stuff) and gets inconsistent data.. instead deadlock is on second delete, after a few cycles..
Anyway.. it is 100% sure that the threads do not cancel the same data, so isn't there some magic word to put in the queries to solve this problem?
Thanks,
Ioana.

Similar Messages

  • Deadlock Problems

    Hi, i've got a deadlock problem - I've read though the tutorials about it but I still dont get whats going on... =/
    Basically I want to send out the position of the scrollbar, but make sure that messages are not sent too often (no less than 0.5 sec between messages). Heres some code (its trimmed down - pretend that the scrollbar was added to a window and that the sendScrollMoved method exists):
    private int scrollValue ;
    public Constructor() {
      scrollValue = -1 ;
      JScrollBar scrollbar = new JScrollBar() ;
      scrollbar.addAdjustmentListener( new AdjustmentListener() {
          public void adjustmentValueChanged(AdjustmentEvent e) {
            scrollValue = e.getValue() ;
      ScrollThread thread = new ScrollThread() ;
      thread.run() ;
      private class ScrollThread extends Thread {
        public ScrollThread() {
          super() ;
          setDaemon(true) ;
        public void run() {
          while (1==1) {
            yield() ;
            try {
              sleep(500) ;
            } catch(Exception e) {
                System.out.println("ScrollListener couldnt sleep") ;
            if (scrollValue >= 0) {
               sendscrollMoved(scrollValue) ;
               scrollValue = -1 ;

    the program halts without displaying any error
    messagesIf there was a deadlock then the program would stall forever without halting. This is the opposite of your actual symptoms. So you need to stop looking for deadlocks and start with another guess at your actual problem.

  • Mule, Weblogic and MQ JMS : deadlock problem

    Dear Oracle community,
    We are hosting our Mule ESB (3.1) application on a Weblogic 10.3 (11g) server and are using IBM Websphere MQ's JMS solution (with libraries version 7.0.1.7).
    The problem we are facing is that JMS connections are created by one of Weblogic's worker (thread) and the close() method for those connections are not necessarily called by the same thread.
    This is bad because from what I know this behavior is undefined from JMS specification
    (see http://docs.oracle.com/cd/E15051_01/wls/docs103/jms/design_best_practices.html#wp1061413 ) and it is a blocker issue in our case because this lead to a deadlock.
    Do someone has any idea how to enforce the fact that the same thread do create and close the connection through Weblogic and/or Mule configuration (without re-implementing the connector) ?
    Thanks in advance for your help,
    Best regards,
    Y.
    PS : I've already posted this question on Mule ESB's forum : http://forum.mulesoft.org/mulesoft/topics/mule_weblogic_and_mq_jms_deadlock_problem
    Edited by: user7428803 on May 14, 2012 2:26 PM

    I hope you found a solution by now, but as an FYI:
    * The JMS specification specifically requires that JMS providers support the ability to call connection.close() and session.close() from an arbitrary thread even when another thread is making calls on these objects. It furthermore goes into some detail about the expected behavior of these calls. The best practices link you cited alludes to this: "The JMS Specification states that multi-threading a session, producer, consumer, or message method results in undefined behavior +except when calling close().+"
    * Depending on your use case, you may not need to use Mule to integrate MQ with WebLogic. WebLogic supports a variety of options for integrating MQ directly without the use of third party tooling. See http://download.oracle.com/docs/cd/E17904_01/web.1111/e13727/interop.htm .
    Tom

  • MtxLock DeadLock problem

    Hello all,
        In one of our ECC system when a user executing one transaction work process is taking more time for execution. When i checked the trace file of the work process i found following error/warning:
    I  WARNING: MtxLock 0xc000000017e340f0 rrol0003 owner=2 deadlock ?
    I Fri Mar 11 16:18:43 2011
    I  WARNING: MtxLock 0xc000000017e340f0 rrol0003 owner=2 deadlock ?
    I Fri Mar 11 16:19:44 2011
    I  WARNING: MtxLock 0xc000000017e340f0 rrol0003 owner=2 deadlock ?
    I searched on google but could not find anything. On SDN i found only one forum and some one has told to check if note 1309072 - System standstill: MtxLock EMADM helps to resolve the issue. But this note also could not help.
    Can anyone please answer this what this is exactly and why this occurs in system???
    Regards,
    Nirav

    I'm facing the same problem too and it occurred several times before, especially when someone was running programs which cost too much time and decided to ternimate the session but for some unknown reason failed, then the GUI crashed and after that, the work process began deadlock.
    The trace log is like below:
    C Thu Apr 14 15:50:56 2011
    C  build_stmt: reallocating stmt buffer: 3801 -> 4807 characters
    C  build_stmt: reallocating stmt buffer: 4807 -> 5808 characters
    C  build_stmt: reallocating stmt buffer: 2304 -> 3308 characters
    C  build_stmt: reallocating stmt buffer: 3308 -> 4318 characters
    C  build_stmt: reallocating stmt buffer: 512 -> 2000 characters
    C  build_stmt: reallocating stmt buffer: 3072 -> 4078 characters
    C  build_stmt: reallocating stmt buffer: 4078 -> 5090 characters
    C  build_stmt: reallocating stmt buffer: 256 -> 2000 characters
    I
    I Thu Apr 14 16:09:07 2011
    I  WARNING: MtxLock 0x7000000063626e4 rrol0112 owner=0 deadlock ?
    I
    I Thu Apr 14 16:10:08 2011
    I  WARNING: MtxLock 0x7000000063626e4 rrol0112 owner=0 deadlock ?
    I
    I Thu Apr 14 16:11:08 2011
    I  WARNING: MtxLock 0x7000000063626e4 rrol0112 owner=0 deadlock ?
    We are using ECC6 with kernal SAPKB70103 on AIX system with oracle database. I also noticed sap notes 1309072, but i don't know what EMADM stands for in the note as we have 'rrol0112' instead of 'EMADM' in the log, and whether we should apply the patch SP199 before let it work or we can just set parameters as mentioned in the notes.
    Could anybody please help to explain it or tell me how to do with the deadlock?
    Thank you very much!
    Best Regards,
    Jeff

  • DeadLock Problem - Please Help

    I don' know what is the problem actually. This warning "Warning: To avoid potential deadlock, operations that may block, such as networking, should be performed in a different thread than the commandAction() handler." exists when i click the submit button.
    I have read some passage that advice to separate the main from the connection part.
    I have done this as follows ..... but the problem is still the same.
    Can anyone guide me some solution. Any helps would be appreciated.
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.Vector;
    public class SecondMidletServlet extends MIDlet implements CommandListener {
    Display display = null;
    List menu = null;
    TextBox input = null;
    String user = null;
    //String url = "http://popolo.no-ip.com:23/phoneserver/RequestServlet";
    static final Command backCommand = new Command("Back", Command.BACK, 0);
    static final Command submitCommand = new Command("Submit", Command.OK, 2);
    static final Command exitCommand = new Command("Exit", Command.STOP, 3);
    String currentMenu = null;
    public SecondMidletServlet() {
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);
    menu = new List("Invoke Servlet", Choice.IMPLICIT);
    menu.append("Add a user", null);
    menu.addCommand(exitCommand);
    menu.setCommandListener(this);
    mainMenu();
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    void mainMenu() {
    display.setCurrent(menu);
    public void addName() {
    input = new TextBox("Enter first name:", "", 5, TextField.ANY);
    input.addCommand(submitCommand);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    if (label.equals("Exit")) {
    destroyApp(true);
    } else if (label.equals("Back")) {
    mainMenu();
    } else if (label.equals("Submit")) {
    user = input.getString();
    try
    newThread thr = new newThread();
    thr.invokeServlet(user);
    thr.ReturnStr();
    TextBox t = new TextBox("Second Servlet", thr.toString(), 1024, 0);
    t.addCommand(backCommand);
    t.setCommandListener(this);
    catch(IOException e) {}
    else
    addName();
    class newThread extends Thread
    public String url = "http://popolo.no-ip.com:23/phoneserver/RequestServlet";
    public StringBuffer strBuf = null;
    public newThread() {}
    public void invokeServlet(String user) throws IOException
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer b = new StringBuffer();
    TextBox t = null;
    try
    c = (HttpConnection)Connector.open(url);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
    c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("Content-Language", "en-CA");
    os = c.openOutputStream();
    String str = "name=" + user;
    byte postmsg[] = str.getBytes();
    System.out.println("Length: "+ str.getBytes());
    for(int i=0;i<postmsg.length;i++)
    os.write(postmsg);
    // or you can easily do:
    // os.write(("name="+user).getBytes());
    os.flush();
    is = c.openDataInputStream();
    int ch;
    while ((ch = is.read()) != -1)
    b.append((char) ch);
    System.out.print((char)ch);
    strBuf = b;
    finally
    if(is!= null)
    is.close();
    if(os != null)
    os.close();
    if(c != null)
    c.close();
    public StringBuffer ReturnStr()
    return strBuf;

    Putting a method in a Thread subclass doesn't automatically make that method run in a separate thread. You have to implement a run() method for the thread that calls your invokeServlet() method, and in commandAction() you have to call the start() method (which will call run() in a separate thread, which will call invokeServlet()) of the thread instead of calling invokeServlet() directly.
    Check out this tutorial.
    shmoove

  • About deadlock problems

    If you use "lock table ..." and "drop table ..." in one programme, sometimes it will lead to deadlock(ORA-00054). Need I resolve it in my *.pc files?
    And how to??

    Since we are having a problem understanding what you are trying to say, if you are still under warranty, call Apple Care.  Otherwise, take the computer to an Apple store or an AASP.  Whichever is more convenient for you. 

  • Deadlock problem, why?

    Hello.
    I have aplication founded with Oracle database 10g2.
    People are working and sometimes the application hangs ...
    Please see this logs: http://student.zsl.gda.pl/~krystian/oracle/
    What should I do to fix this problem?
    Please help me.

    To put the deadlock file into english:
    Deadlock graph:
                           ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name          process session holds waits  process session holds waits
    TM-00003868-00000000        32     119           X       39     141          SS
    TM-0000385d-00000000        39     141    SS             20     135           X
    TM-00003868-00000000        20     135    SS             32     119           X
    session 119: DID 0001-0020-0000000B     session 141: DID 0001-0027-00000010
    session 141: DID 0001-0027-00000010     session 135: DID 0001-0014-0000003C
    session 135: DID 0001-0014-0000003C     session 119: DID 0001-0020-0000000B
    Rows waited on:
    Session 141: obj - rowid = 00003DBB - AAAD27AANAAAZ2FAAA
      (dictionary objn - 15803, file - 13, block - 105861, slot - 0)
    Session 135: obj - rowid = 00003AFB - AAADr7AANAAASUIAAA
      (dictionary objn - 15099, file - 13, block - 75016, slot - 0)
    Session 119: no row1. Session 141 is waiting behind session 119 for a lock on object 14440 (hex: 3868).
    2. Session 119 is waiting for X lock on object 14440 but is blocked by session 135 which has an SS lock on it.
    3. But session 135 is itself waiting for an x lock on object 14429 (hex: 385d), a request which is held up the SS lock which session 141 holds but can't release because it's blocked by 119 (back to point 1).
    So you have three session participating in the deadlock.
    You just need to be aware that the SQL statements in the files don't give you the full picture of everything involved in the deadlock scenario.
    For that, you're either going to have to reproduce the problem and trace the sessions or step through the application code and the order in which things are done / data is modified
    Use the data dictionary to verify the objects being waited on above (dba_objects.object_id 14440/14429) are the ones in the statements.

  • [Deadlock problem] Lenovo G460

    My laptop has recently been deadlock. 
    There are some flash horizontal stripes and it's suddenly dead!
    This has been happened after updating drivers for windows7 (bluetooth, wireless, power manager) 
    Before updating, sometime my laptop display become "fade" and "color-less". And that problem is still exist now.
    Please help! Thanks

    Hi
    Welcome To Lenovo Community
      We are really sorry to hear about the issue you are experiencing .Please try the following  
         Please Boot up the system to safe mode by pressing F8 at the startup and check if it is able to boot up
         Now Open device manager and uninstall display adaptor, Restart the system and boot in Normal mode
         You may need to update the display drivers once it boots up in normal mode
                http://support.lenovo.com/en_US/research/hints-or-tips/detail.page?DocID=HT072732
    Have a check and let us know the results
    Hope This Helps
    Cheers!!!
    Important Note: If you need help, post your question in the forum, and include your system type, model number and OS. Do not post your serial number.
    Did someone help you today? Press the star on the left to thank them with Kudos!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"!  This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Create index intermittent deadlock problem

    Hi. Apologies but I'm a newbie to Oracle Text. I have a batch process which occasionally (twice so far) falls over with:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: Oracle Text error:
    DRG-50857: oracle error in drekmap (lob write)
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at "CTXSYS.DRUE", line 157
    ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 204
    This is when trying to create a multi_column index defined as
    BEGIN
    CTX_DDL.CREATE_PREFERENCE('mikec_test', 'MULTI_COLUMN_DATASTORE');
    CTX_DDL.SET_ATTRIBUTE ('mikec_test', 'columns',
    'title, result_text, location, origin, inc_details');
    END;
    The create index is:
    CREATE INDEX schema.idx_freetext_new
    ON schema.freetext_search_new(title)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('datastore ctxsys.mikec_test');
    Most of the time the above works fine. I'm using Oracle 9.2.0.4 on a SunOS 5.8 machine. Could anyone please give me a hint how/where to start tracking this deadlock down? Should I specify tablespace storage for the i/k/n/r thingummies? Is it something I need to get a patch for? Oracle 10/11?
    Many thanks.

    Starting places:
    select * from ctxsys.ctx_index_errors;
    check your alert log
    turn tracing on and check trace file
    search metalink for drekmap

  • Performance problems, do we need to upgrade. Server and Database level

    Problem:
    I'm a Java programmer and a Transact SQL DBA. So i have knowledge about databases. Nowwe have a database who performs very bad and got much deadlock problems and so on. It's an Oracle Database.
    We have Oracle version 9 and an application in Delphi. The bad performance is only since a while. We have cleaned the archive.
    My suggestion is why not migrate to a newer version of Oracle. Change some hardware specs get up to date.Then i think we will have less problems.
    But ofcourse this is more trail on error. That why i hope there is an Oracle specialist here who can help me with a few questions.
    Users and Specs
    I got 150 till 180 users
    i got a server with 1 processor XEON 233 GHZ
    4 gig memory, constant use 1,5 gig
    Questions
    1. Is it a good idea to upgrade? Maybe not to solve al the problems, but version 9 is old, there is version 10 or 11.
    2. Which version we should use 10 or 11? 11 is in use for a while so this sounds like a good idea.
    3. Are the specs OK or must i do something about the server to?
    Maybe dual core, or Enterprise (64 bit). Memory upgrade?
    4. Maybe for 64 bit i need Oracle version 11 to have good support on it?
    I hope somebody can help me a bit.
    Thanks,
    Kind regards,
    André

    Hi Andre,
    . Is it a good idea to upgrade? Maybe not to solve al the problems, but version 9 is old, there is version 10 or 11.
    2. Which version we should use 10 or 11? 11 is in use for a while so this sounds like a good idea.I suggest you to upgrade to latest available 11.2.0.2.
    But do complete testing your upgraded database before you move to PRODUCTION.
    . Are the specs OK or must i do something about the server to?It all depends on the usage and concurrent users :)
    4. Maybe for 64 bit i need Oracle version 11 to have good support on it?Regardless of bit version all Oracle Versions has good support.
    Refer MOS tech notes:
    *How to Perform a Full Database Export Import during Upgrade, Migrate, Copy, or Move of a Database [ID 286775.1]*
    *Minimizing Downtime During Production Upgrade [ID 478308.1]*
    *Different Upgrade Methods For Upgrading Your Database [ID  419550.1]*
    thanks,
    X A H E E R

  • Is there any problem to use multiple threads to send email with JavaMail

    Dear all,
    I am using JavaMail 1.3.2 to send emails with SMTP, it works very well for a long time.
    But one day, I found that the email service hanged and I could never send email again until I restart the tomcat. I found that the reason was a deadlock had been created, the required resource for sending email had not been released.
    I guess the error is due to multiple threads are sending email at the same time. I made a test to create seperate thread for sending each email. After few days, I found this deadlock happened again. So, my question is: Can I use JavaMail with multiple threads? If not, I may need to sychronized all the thread that using JavaMail. I would like to make sure this is the reason for causing the deadlock problem.
    Here is part of my code for using JavaMail:
    transport = session.getTransport("smtp");
    transport.connect(email_host, smtp_user, smtp_pass);
    message.saveChanges();
    transport.sendMessage(message,message.getAllRecipients());
    which is very standard call, and it worked well for a long time.
    Here is part for my thread dump on tomcat:
    (Thread-339)
    - waiting to lock <0x5447c180> (a sun.nio.cs.StandardCharsets)
    (Thread-342)
    - locked <0x5447c180> (a sun.nio.cs.StandardCharsets)
    It seems that these happened after call the method transport.sendMessage() or message.updateChanges()
    , and the underlying implementation may require the JRE StandardCharsets object. But the object had been locked and never be released. So, the sendMessage() or updateChanges() can't be completed.
    Please give me some helps if you have any idea about it.
    Thanks very much!
    Sirius

    Note that the Nightly build gets updated daily (and sometimes more than once in case of a respin) and it is always possible that something goes wrong and it doesn't work properly, so be prepared for issues if you decide to stay with the Nightly build and make sure to have the current release with its own profile installed as well in case of problems.
    See also:
    * http://kb.mozillazine.org/Testing_pre-release_versions
    *http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    *http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    *http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • What are the different ways to handle deadlocks?

    Hi,
    May I know what are the ways to solve a deadlock problem?
    Currently, I have the following code to catch the exception:
    catch (XmlException ex)
                   try
                        ex.printStackTrace();
                        txn.abort();
                   } catch (DatabaseException DbEx)
                        System.err.println("txn abort failed.");
                   }and the resulting error is:
    com.sleepycat.dbxml.XmlException: Error: DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock, errcode = DATABASE_ERROR
    Any other more efficient way to handle deadlock?
    Or better ways to prevent deadlock from happening?
    I am using this environment config
    EnvironmentConfig envConf = new EnvironmentConfig();
                   envConf.setAllowCreate(true); // If the environment does not exits,
                   // create it.
                   envConf.setInitializeCache(true); // Turn on the shared memory
                   // region.
                   // envConf.setCacheSize(25 * 1024 * 1024); // 25MB cache
                   envConf.setInitializeLocking(true); // Turn on the locking
                   // subsystem.
                   envConf.setInitializeLogging(true); // Turn on the logging
                   // subsystem.
                   envConf.setTransactional(true); // Turn on the transactional
                   // subsystem.
                   // envConf.setRunRecovery(true); //Turn on run recovery
                   // envConf.setTxnNoSync(true); // Cause BDB XML to not synchronously
                   // force any log data to disk upon transaction commit
                   envConf.setLogInMemory(true); // specify in-memory logging
                   envConf.setLogBufferSize(60 * 1024 * 1024); // set logging size.
                   // envConf.setTxnWriteNoSync(true); //method. This causes logging
                   // data to be synchronously written to the OS's file system buffers
                   // upon transaction commit.
                   // envConf.setThreaded(true); //default by Java that threaded = true
                   // envConf.setMultiversion(true);
                   envConf.setLockDetectMode(LockDetectMode.DEFAULT); // Reject a
                   // random lock
                   // requestThanks in advance for any help!
    :)

    Hi Vyacheslav,
    here is the code:
    package ag;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.db.LockDetectMode;
    import com.sleepycat.dbxml.XmlContainerConfig;
    import com.sleepycat.dbxml.XmlDocumentConfig;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlDocument;
    import com.sleepycat.dbxml.XmlManagerConfig;
    import com.sleepycat.dbxml.XmlTransaction;
    import com.sleepycat.dbxml.XmlUpdateContext;
    import inter.DBInterface;
    import java.io.*;
    import java.util.Properties;
    import cp.CheckPointer;
    public class SaveMessageinDB implements DBInterface
         Environment myEnv;
         XmlManager myManager;
         XmlContainer myContainer;
         XmlTransaction txn;
         XmlContainerConfig cconfig;
         Properties properties;
         // CheckPointer cp;
         int Counter;
         public SaveMessageinDB()
              try
                   properties = new Properties();
                   properties.load(ClassLoader
                             .getSystemResourceAsStream("Aggregator.properties"));
                   setXmlEnvrionment();
                   setXmlManager();
                   setXmlContainer();
                   // cp = new CheckPointer(myEnv);
                   // cp.start();
                   // System.out.println("Checkpointer started....");
                   Counter = 0;
              } catch (Exception ex)
                   ex.printStackTrace();
         public void saveMessage(String docName, String content) throws Exception
              addXMLDocument(docName, content);
         public void setXmlEnvrionment()
              try
                   File envHome = new File(properties.getProperty("DATABASE_LOCATION"));
                   EnvironmentConfig envConf = new EnvironmentConfig();
                   envConf.setAllowCreate(true); // If the environment does not exits,
                   // create it.
                   envConf.setInitializeCache(true); // Turn on the shared memory
                   // region.
                   envConf.setCacheSize(100 * 1024 * 1024); // 100MB cache
                   envConf.setInitializeLocking(true); // Turn on the locking
                   // subsystem.
                   envConf.setInitializeLogging(true); // Turn on the logging
                   // subsystem.
                   envConf.setTransactional(true); // Turn on the transactional
                   // subsystem.
                   // envConf.setRunRecovery(true); // Turn on run recovery
                   // envConf.setTxnNoSync(true); // Cause BDB XML to not synchronously
                   // force any log data to disk upon transaction commit
                   envConf.setLogInMemory(true); // specify in-memory logging
                   envConf.setLogBufferSize(60 * 1024 * 1024); // set logging size.
                   // envConf.setTxnWriteNoSync(true);
                   // This causes logging
                   // data to be synchronously written to the OS's file system buffers
                   // upon transaction commit.
                   envConf.setMultiversion(true); //Turn on snapshot isolation
                   envConf.setLockDetectMode(LockDetectMode.DEFAULT); // Reject a
                   // random lock
                   // request
                   // myEnv = new Environment(envHome, null); //To adopt Environment
                   // already set by others
                   myEnv = new Environment(envHome, envConf);
                   System.out.println("Environment created...");
              } catch (Exception ex)
                   ex.printStackTrace();
         // All BDB XML programs require an XmlManager instance.
         // Create it from the DB Environment, but do not adopt the
         // Environment
         public void setXmlManager()
              try
                   XmlManagerConfig mconfig = new XmlManagerConfig();
                   mconfig.setAllowAutoOpen(true);
                   mconfig.setAdoptEnvironment(true);
                   mconfig.setAllowExternalAccess(true);
                   myManager = new XmlManager(myEnv, mconfig);
                   // myManager = new XmlManager (mconfig);
                   System.out.println("Manager created...");
              } catch (Exception ex)
                   ex.printStackTrace();
         public void setXmlContainer()
              try
                   cconfig = new XmlContainerConfig();
                   cconfig.setNodeContainer(true);
                   cconfig.setIndexNodes(true);
                   cconfig.setTransactional(true); // set transaction need an
                   // cconfig.setAllowValidation(false);
                   // environment
                   // cconfig.setReadUncommitted(true); // This container allow
                   // uncommitted read (able to read dirty data and not set a deadlock
                   // cconfig.setMultiversion(true);
                   myContainer = myManager.openContainer(properties
                             .getProperty("DATABASE_LOCATION")
                             + properties.getProperty("CONTAINER_NAME"), cconfig);
                   System.out.println("Container Opened...");
              } catch (XmlException XmlE)
                   try
                        myContainer = myManager.createContainer(properties
                                  .getProperty("DATABASE_LOCATION")
                                  + properties.getProperty("CONTAINER_NAME"), cconfig);
                        System.out.println("Container Created...");
                   } catch (Exception e)
                        e.printStackTrace();
              } catch (Exception ex)
                   ex.printStackTrace();
         public void addXMLDocument(String docName, String content)
              try
                   txn = myManager.createTransaction(); // no need to create
                   // transaction. auto commit
                   // by the environment
                   XmlDocumentConfig docConfig = new XmlDocumentConfig();
                   docConfig.setGenerateName(true);
                   docConfig.setWellFormedOnly(true);
                   myContainer.putDocument(txn, docName, content, docConfig);
                   // commit the Transaction
                   txn.commit();
                   System.out.println("documents added.....");
                   Counter++;
                   System.out.println("Document no: " + Counter);
                   txn.delete();
              } catch (XmlException ex)
                   try
                        System.out.println("Occuring in addXMLDocument");
                        ex.printStackTrace();
                        txn.abort();
                   } catch (DatabaseException DbEx)
                        System.err.println("txn abort failed.");
         public void cleanup()
              try
                   if (myContainer != null)
                        myContainer.close();
                   if (myManager != null)
                        myManager.close();
                   if (myEnv != null)
                        System.out.println("All cleaned up done..in sm");
                        myEnv.close();
              } catch (Exception e)
                   // ignore exceptions in cleanup
    }Thanks!

  • DEADLOCK DETECTED ( ORA-00060 )

    Hi,
    We are getting deadlocks when the System (Exteranl-Portal-
    Production) Cache Upload process runs. It's Looks like
    application problem.
    We have been getting this deadlock problem whenever the CACHE job gets
    executed.
    Basically its a portal SRM Business package system.
    We have scheduled the CACHE job on portal at 1 AM MSTAZ time , so it
    will use Jco to connect R3 and SRM system to bring the data.
    We have been observing this deadlock problem only at the time of cache
    job.
    But cache job is executing succesfully , but we could see the deadlock
    in the logs.
    In the beginning of trace file (Location:-
    /oracle/RPE/saptrace/usertrace/) we found the information as follows
    more rpe_ora_1835342.trc
    Dump file /oracle/RPE/saptrace/usertrace/rpe_ora_1835342.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    ORACLE_HOME = /oracle/RPE/102_64
    System name:    AIX
    Node name:      fsp55a08
    Release:        3
    Version:        5
    Machine:        000788ABD600
    Instance name: RPE
    Redo thread mounted by this instance: 1
    Oracle process number: 17
    Unix process pid: 1835342, image: oracle@fsp55a08
    2009-05-31 01:00:49.485
    ACTION NAME:() 2009-05-31 01:00:49.485
    MODULE NAME:(JDBC Thin Client) 2009-05-31 01:00:49.485
    SERVICE NAME:(SYS$USERS) 2009-05-31 01:00:49.485
    SESSION ID:(275.1229) 2009-05-31 01:00:49.485
    DEADLOCK DETECTED ( ORA-00060 )
    [Transaction Deadlock]
    The following deadlock is not an ORACLE error. It is a
    deadlock due to user error in the design of an application
    or from issuing incorrect ad-hoc SQL. The following
    information may aid in determining the deadlock:
    Deadlock graph:
    Blocker(s)--  -Waiter(s)--
    Resource Name          process session holds waits  process session holds waits
    TX-00050010-00003981        17     275     X             18     284           X
    TX-00010000-000038a3        18     284     X             17     275           X
    session 275: DID 0001-0011-00000139     session 284: DID 0001-0012-0000004F
    session 284: DID 0001-0012-0000004F     session 275: DID 0001-0011-00000139
    Rows waited on:
    Session 284: obj - rowid = 0000561D - AAAFYdAAJAAAHUlAAU
      (dictionary objn - 22045, file - 9, block - 29989, slot - 20)
    Session 275: obj - rowid = 00005617 - AAAFYXAAJAAAG1aAAc
      (dictionary objn - 22039, file - 9, block - 27994, slot - 28)
    Information on the OTHER waiting sessions:
    Session 284:
      pid=18 serial=1236 audsid=672749 user: 21/SAPRPEDB
      O/S info: user: rpeadm, term: unknown, ospid: 1234, machine: fsp65003
                program: JDBC Thin Client
    Please help me on this issue.
    Please let me know if you need any more information on the same.
    Thank you in advance.
    Regards,
    A.Naresh
    SAP-BASIS

    Hi,
    Check SAP Note 84348 - Oracle deadlocks, ORA-00060
    Thanks
    Sunny

  • How get outside deadlock

    Hi all,
    i have these problem i get one "cool" app on my table which has these feature. Have deadlock problem ;). There occur situation when one sesion is select for update row with id = 10 second session take for update 20 first want take 20 then ;) and second 10 :0 and deadlock is born.
    oracle find deadlock and one select is raising exception e.g.
    S2 take 20
    S1 take 10
    S1 try take 20 and waitin
    S2 try take 10 = deadlock
    oracle throw error in S1
    and my goal is catch this exception and try do same work in S1 again i try something like this (pseudocode)
    while deadlock = true loop
    deadlock := false;
    savepoint s1
    begin
    select for update where id = 10;
    select for update where id = 20;
    exception
    when others then
    if errorcode = - 60 then deadlock :- true rollback to s1;
    end;
    end loop
    but rollback to savepoint dont unlock my rows. can u give me advice how make this on oracle? I want loop in which i can free all my locks.
    Thanks a lot martin.

    Is there a reason that you can't simply avoid the deadlock by requiring that sessions lock rows in a particular order (i.e. always lock row 10 before trying to lock row 20)? Or that you can't specify NOWAIT when you try to lock the row and handle the ORA-00054 error if the row is already locked? Normally, the solution to deadlock problems is not to allow them to occur, not to try to handle them when they occur.
    Justin

  • Deadlock detected in one single insert

              We have a deadlock problem in our application, we are using
              weblogic server 6 and Oracle 8 database, when running to a
              ceartain time, oracle will detect a deadlock problem, actually
              from the stack trace, it is when EntityBean using
              ejbCreate to create new record, oracle server threw an
              ORA-00060 SQLException, complaining about deadlock detected.
              The enitty Bean has its own transaction. Could anyone tell me
              a scenario that when inserting a record will have deadlock?
              Since our entity bean has its own transaction and inside this
              transaction, it only creates a new record, also it does not hold
              other resource, why deadlock porblem pop up?
              Thanks for your help.
              Following is the exception trace:
              (null)/java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
              java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
                   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
                   at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
                   at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)
                   at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1311)
                   at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:738)
                   at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1313)
                   at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1232)
                   at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch(OracleStatement.java:1353)
                   at oracle.jdbc.driver.OracleStatement.doExecute(OracleStatement.java:1760)
                   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1805)
                   at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:322)
                   at weblogic.jdbcbase.jts.Statement.executeUpdate(Statement.java:345)
                   at glog.util.jdbc.SqlUpdate.resetArguments(SqlUpdate.java:94)
                   at glog.util.jdbc.SqlUpdate.execute(SqlUpdate.java:60)
                   at glog.util.remote.BeanManagedEntityBean.executeUpdate(BeanManagedEntityBean.java:499)
                   at glog.util.remote.BeanManagedEntityBean$1.execute(BeanManagedEntityBean.java:144)
                   at glog.util.remote.BeanManagedEntityBean.dbModify(BeanManagedEntityBean.java:777)
                   at glog.util.remote.BeanManagedEntityBean.doCreate(BeanManagedEntityBean.java:141)
                   at glog.util.remote.BaseEntityBean$1.doIt(BaseEntityBean.java:376)
                   at glog.util.remote.BaseEntityBean.ejb(BaseEntityBean.java:651)
                   at glog.util.remote.BaseEntityBean.ejbCreator(BaseEntityBean.java:374)
                   at glog.ejb.orderbase.db.ObLineBeanDB.ejbCreate(ObLineBeanDB.java:64)
                   at glog.ejb.orderbase.ObLineBeanImpl.ejbCreate(ObLineBeanImpl.java:1273)
                   at java.lang.reflect.Method.invoke(Native Method)
                   at weblogic.ejb20.manager.ExclusiveEntityManager.create(ExclusiveEntityManager.java:446)
                   at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:353)
                   at glog.ejb.orderbase.ObLineBeanHomeImpl.create(ObLineBeanHomeImpl.java:133)
                   at java.lang.reflect.Method.invoke(Native Method)
                   at glog.util.remote.BeanBaseInvoker.invoke(BeanBaseInvoker.java:24)
                   at glog.util.remote.EntityBeanHomeInvoker.create(EntityBeanHomeInvoker.java:49)
                   at glog.util.persistence.PersistenceListener.insertPerformed(PersistenceListener.java:114)
              

    try this please
    INSERT ALL
    INTO RD_CARRY_NEW1 VALUES
        SSM_ID,
        ROLLDOWN,
        OAS,
        carry,
        finance_rate,
        price_drop,
        heldby_pco_sw,
        rolldown_bk1,
        rolldown_bk2,
        r_srm_flag,
        o_srm_flag,
        c_srm_flag,
        F_SRM_FLAG,
        rolldown_method
    INTO RD_FINANCE_NEW1 VALUES
        SSM_ID,
        ROLLDOWN,
        OAS,
        carry,
        finance_rate,
        price_drop,
        heldby_pco_sw,
        rolldown_bk1,
        rolldown_bk2,
        r_srm_flag,
        o_srm_flag,
        c_srm_flag,
        F_SRM_FLAG,
        rolldown_method
    INTO PCO_OWN.RD_ROLLDOWN_NEW1 VALUES
        SSM_ID,
        ROLLDOWN,
        OAS,
        carry,
        finance_rate,
        price_drop,
        heldby_pco_sw,
        rolldown_bk1,
        rolldown_bk2,
        r_srm_flag,
        o_srm_flag,
        c_srm_flag,
        F_SRM_FLAG,
        rolldown_method
    SELECT s.ssm_id,
      NVL(srm.rolldown,0) AS rolldown,
      v_zero              AS oas,
      v_zero              AS carry,
      v_zero              AS finance_rate,
      v_zero              AS price_drop,
      sw.heldby_pco_sw,
      v_zero            AS rolldown_bk1,
      v_zero            AS rolldown_bk2,
      'Y              ' AS r_srm_flag,
      'Y              ' AS o_srm_flag,
      'Y              ' AS c_srm_flag,
      'Y              ' AS f_srm_flag,
      'SRM'             AS rolldown_method
    FROM sec_tab_sdb s,
      sr_measures srm,
      sec_sw sw
    WHERE s.ssm_id = srm.ssm_id
    AND s.ssm_id   = sw.ssm_id;

Maybe you are looking for