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!

Similar Messages

  • What are the different ways to upload file data to SAP? Please help

    Hi Experts,
       I have to transfer huge file data (few lakhs records) to SAP business transaction. What are the different ways to do the same? I have heard of BDC and LSMW. But are there any more options?
    Which option is best suited for huge file data?
    Is LSMW an old technology and SAP will not support it any more?
    Kindly answer my queries at the earliest.
    I will be greatful to you if you can help me.
    Thanks
    Gopal

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • What are the Different Ways of receiving Acknowlegements ?

    Hi Experts,
    Can you please let me know what are the Different Ways of receiving Acknowlegements from target system as a response to the Message sent from source system.
    As when we send Idoc to target system acknowledgement is sent through XI to Source system, what are the configuration steps required for it. Can we use Webservice or link which can be provided to target/customer system and acknowledgement is confirmed using this medium. Please suggest any possible option.
    Where I can find the related information or standard document about the same.
    Please guide.
    Regards,
    Nitin

    Hi ,
    Can you please let me know what are the Different Ways of receiving Acknowlegements from target system as a response to the Message sent from source system.
    System acknowledgments used by the runtime environment to confirm that an asynchronous message has reached the receiver.
    Application acknowledgments used to confirm that the asynchronous message has been successfully processed at the receiver
    These are of positive or Negative.
    As when we send Idoc to target system acknowledgement is sent through XI to Source system, what are the configuration steps required for it. Can we use Webservice or link which can be provided to target/customer system and acknowledgement is confirmed using this medium. Please suggest any possible option.
    This is based on your souce system to accept the ack, what is the protocol used to communicate with the source system.
    http://help.sap.com/saphelp_nw04/helpdata/EN/55/65c844539349e9b1450581ab44a5e6/frameset.htm
    Regards
    Harsha Paruchuri

  • What are the different ways to back up your photos from iphoto using a MacBook Pro which does not have a disk drive?

    What are the different ways to back up your photos from iphoto using a MacBook Pro which does not have a disk drive?

    Note - that no internet backup service has been proven to be safe and effective for backing up the iPhoto library - unless you personally have backup uyp an iPhoto library and restored it sucussfuly form one it should not be recommended - a large number of people have lost their photos trying it
    LN

  • What are the different ways of retrieving data from Oracle8i

    What are the different ways of retrieving data from Oracle8i
    into my HTML page ?
    Is it JDBC and ODBC ?
    Is there any other way ?
    null

    Methods I tried,
    Applet using SQLJ/JDBC with JDBC drivers thin or Oci8,
    Oracle Web Publishing Assistant,
    HTP/HTF PL/SQL packages (if you have OAS 4.0)
    Webserver Generator of Designer 2000 (if you have OAS 4.0)
    Arun (guest) wrote:
    : What are the different ways of retrieving data from Oracle8i
    : into my HTML page ?
    : Is it JDBC and ODBC ?
    : Is there any other way ?
    null

  • What are the different ways you guys add your favicon?

    I'm curious as to all the different ways people add their url favicon for their iWeb sites.
    What is the easiest way?

    Have a look here...
    http://iwebfaq.org/site/iWeb_Favicons.html

  • What are the different ways in accessing the SQL server from NWDS ?

    Hi Experts,
    Can anyone suggest the different ways for accessing the SQL server from NWDS.I also want to know whether any tool is available for accessing SQL server from Webdynpro java application in Netweaver development studio.
    I am currently using JDBC driver for accessing the SQL server from Webdynpro java application in NWDS.
    Regards,
    Krishna Balaji T

    Note - that no internet backup service has been proven to be safe and effective for backing up the iPhoto library - unless you personally have backup uyp an iPhoto library and restored it sucussfuly form one it should not be recommended - a large number of people have lost their photos trying it
    LN

  • What are the different ways to transfer BAPIs from one company to another?

    Hello friends
    There are some ZBAPIs that we have written which has to be given to a partnering company.
    Instead of recreating the whole BAPIs and related structures and data elements etc.,, is there a way I can package them and send them.
    For example, on XI side I can export the mappings etc., to a tpz file which can be imported on a different server out side our network.
    Any suggestions or feedback will be greatly apprecited.
    Thanks
    Ram

    I am really sorry..
    I thought that people will be looking at the different areas of the forum based on their interest. So I thought of putting the question in other areas where I thought may get the attention of different people who have expertise in this area.
    Thanks for letting me know.
    Thanks a lot for the answer also. I appreciate it
    Ram

  • What are the different ways to Export JTable to HTML file

    What would be best way of going about (well the easiest way) in exporting a jtable to html file, I can only think of one...
    Would it be to create file, then loop through Jtable and write data to the file using appriopiate tr, td tags..
    Are there any other methods which are better?

    Perhaps you could use XMLEncoder to write the JTable to an xml stream, and then use xslt to convert it into the html you want. Not sure if that is any easier.

  • What are the different ways to improve performance of WSRP?

    Producer - Websphere Portal 6
    Consumer - Weblogic Portal 10.2
    Also, if anyone can way to optimize the performance of remote portlets in general would be helpful to everyone.
    Thank You

    Yes. I have implemented those methods. Thanks anyway. If you are aware of any other ways, please let me know.
    Consumer: Weblogic portal 10.2
    Producer: Websphere Portal 6.1

  • What are the Different Reporting Types Offer By SAP Package

    Hello everyone...
    Been on SAP almost a year and finding there is alot to learn.
    Question: What are the different ways to generate reports and to link reports\programs across the SAP system. I know about BW, RRI, ABAP language, CRYSTAL.
    Are there any more ?
    Thank you in advance....
    Jim

    there are four reporting possibilities using business explorer in bw:
    bex analyser:
    (reports displayed in normal excell)
    web application:
    (publishing above reports in web)
    formated reporting:
    (crystal reports)
    mobile intelligence:
    (view reports in mobiles)
    hope it helps

  • What are the diffrent ways to copy data from one application to another?

    Hi,
    Can you guys tell me what are the different ways to copy data from one application to another application??
    I know we can do it through script logic using DESTINATION_APP.
    Is there any other way to copy data from one application to another application?
    Please help me
    Thanks,
    Charly

    You can also call a custom DTSX package in SSIS via the datamanager.
    there are at least 5 ways of transfering data in BPC between apps.
    1. Through the front end (excel etc) via evdre/evsnds
    2. Through Script logic using *Dest App
    3. Using BPC's standard export dtsx package via DM
    4. Using SSIS using BPC's custom SSIS tasks
    5. Through Script logic using stored procs.
    i am sure people will come up with more.
    remember if you use ssis and move data into any table but the wb, you need to process the cube afterwards.

  • What are the different approaches to do Fault Handling?

    What are the different approaches to do Fault Handling?

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • What are the different steps to follow in order to develop an application and deploy it into a PAC

    Hi,
    I developped a program on my computer but in order to deploy it in a PAC , I don't know what are the different steps to follow?
    What are the difference between a stand alone application and communication with server mode.
    Can the file which will be downloaded into the PAC be in a form othre than (.exe). 
    what does the deployment licence consist of??? is it a software? 
    if the file is .exe then how to maintain it?
    Thank you for all,
    Regards

    Hi!
       Since I'm familiar with FieldPoint PACs, I'll refer to that (but maybe it is similar for cRIO...).
       An embedded application (standalone), runs entirely and independently on the PAC, while if you're not doing this, you'll have your computer, with LabView, which is controlling the PAC.  In this mode, application is dowloaded in PAC's RAM, so when you reboot controller, application will be lost.  If you build an embedded application, you can provide for application to boot authomatically at boot, each time the PAC reboots.  These are some basic stuffs on embedded applications with LV.
        To deploy an application to a PAC, you need LabVIEW + Real-Time module. Without it, you can't build an embedded application on PACs.
        usually, the file dowloaded is an .exe, and some libraries.  What would you like to have, exactly? For example, I think you can buy a simple .exe, which is universal, which loads VIs dinamically, so you can download directly VIs, but I've never tried this way....
       Deployment license, I think, refer to PCs, id est, when you use a PC or PXI as embedded target, in PACs, you have it bundled (it seems to me) whit the PAC you buy, so you don't have to buy an extra license for every PAC you ship with your application.  Otherwise, if you develop a Real-Time application for a PC, you will ship PC + OS licensed + Real-Time extension licensed, but this is not your case, since you'll use PACs.
       The maintain problem... I've already faced with! Simply, for my needs it was enough to make an application which loads configuration files, depending on different task the controller has to do. If you have to dowload a completely new version of VI.... it's better to deploy new application from LV.  But maybe you can bypass this problem with dinamic VIs loading...
        Let me know if this help.... Have a nice day!
    graziano

  • What are the different kind of parameter/attributes we can set in  XI ?

    Hi  Experts
        Yesterday i have attended an interview ....one question was
        1) What are the different knid of parameters we can set in XI ? Have done ?
            what and all the cases we will set the parameters/Attributes?
    and one more was
       2) How will you do Stress testing in XI ?
    Awaitng for responses
    Adv thax and regards
    Kiran lvs

    Hi,
    1) What are the different knid of parameters we can set in XI ? Have done ?
    what and all the cases we will set the parameters/Attributes?
    -First you should ask in which stage or where do you want to configure parameters ,i mean  Whatever parameters we can set in XI all comes under this question like all sort of Adapters,each of adapter can have its own set of configuration , configuration parameters,XI admin config parameters.. etc..
    and one more was
    2) How will you do Stress testing in XI ?
    In general stress tesing will be done by testing team
    Stress testing by way of sending more messages and performance also
    see the below links
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3a67c790-0201-0010-89aa-d27d97dd1374
    Rules of thumb on size of messagetypes in XI
    /people/sravya.talanki2/blog/2006/02/28/simulating-xi-messages-proto
    Measure Performance
    Regards
    Chilla..

Maybe you are looking for

  • Flash Builder Design Mode Bug Workaround (!!!)

    I've been fighting this annoyance since FB4 came out, and while I still don't think that custom/embedded fonts in design view are fixed by this, I've been able to reproduce this "fix" (workaround) to get design view to show fonts/theme correctly unde

  • Accessibility issues: iPod touch 8GB

    I am wondering if anyone here has used their iPod touch 8GB for English text-to-speech functions. I am considering purchasing this for a family member who has lost her ability to read and write. Primarily I'm thinking of using this device as a readin

  • Problem with my mac

    The problem is all of a sudden when it starts up up comes the grey screen with apple logo as usual but now I have a progress bar and loading is much slower it is running in safe mode I think . I have it set so no access unless i type in a password ,

  • Pro*C for Oracle 10g in Debian Linux

    Hi, I've downloaded and installed the Debian packages for Oracle 10g XE, and I'm trying to compile a local copy of CASTOR http://www.cern.ch/castor This software requires the Pro*C compiler. Where can I find/download it from? Thanks in advance!

  • Single user mode - fsck drive full

    Hi all I get the drive full error when trying to run fsck saying drive full when trying to rebuild b-tree along with some other errors invalid leaf count any idea to be able to boot up do i need to post the whole results from fsck? what does this mea