1 2 Previous Next 21 Replies Latest reply: Sep 25, 2009 9:24 PM by 721971 RSS

    DBXML 2.4.16:  Accessing containers from multiple threads and deadlock

    721971
      Hi,
      I am evaluating dbxml for my upcoming project (http://xcapserver.sourceforge.net) where I am sending following four requests through multiples threads which gets into deadlock situation after running certain iterations. Can you please help me what am I doing wrong?

      1. Put Document
      2. Get Document
      3. Get Document Node (XPATH Query)
      4. Delete Document

      I am using following environment variables.
      u_int32_t env_flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |DB_INIT_TXN | DB_THREAD|DB_RECOVER| DB_AUTO_COMMIT; (I tried removing DB_AUTO_COMMIT)
      dbEnv_.open(dbxml_env.c_str(), env_flags, 0);

      XmlManager instance is initialized as :pxmlmgr_= new XmlManager(&dbEnv_) ;
      pxmlmgr_->setDefaultContainerType(DbXml::XmlContainer::WholedocContainer);
      NOTE: pxmlmgr_ instance is member variable of singleton class assuming XmlManager is thread safe and can be reused for all threads.


      Below is the psudo code. It is written in C++. I have removed exception handling and other code for clarity.

      getDocument (...){
      XmlTransaction containerTxn =pxmlmgr_->createTransaction();
                XmlContainer cont = pxmlmgr_->openContainer(container, DB_RDONLY|DB_THREAD);
                XmlDocument doc = cont.getDocument(document);
                containerTxn.commit();
                data = doc.getContent(data
      }

      NOTE: To use doc(...) function, I have to create an alias than only I can use container name e.g /dbxml/resource-lists/users/rjoshi where /dbxml is env_home.
      container name: /dbxml/resource-lists/users/rjoshi (here rjoshi is container name)
      document name: presence

      getDocumentNode(...) {
      size_t npos = container.find_last_of("/", container.length());
                std::string alias = container.substr(npos+1, container.length()-npos) + "_" + document;
                     XCAP_DEBUG("Alias:" + alias);
                     std::string fullQuery = "doc('dbxml:" + alias + '/' + document + "')" + node;
                     XCAP_DEBUG("XPath Full Query:" + fullQuery);

                     XmlTransaction txn = pxmlmgr_->createTransaction();
                     XmlContainer cont = pxmlmgr_->openContainer(container, DB_RDONLY|DB_THREAD);
                     cont.addAlias(alias);
                     //query context
                     XmlQueryContext context = pxmlmgr_->createQueryContext();
                XmlResults results(pxmlmgr_->query(fullQuery, context ) );
                     cont.removeAlias(alias);
                     txn.commit();
      }

      putDocument(....){
      size_t npos = container.find_last_of("/", container.length());
                std::string dir = container.substr(0, npos);

                     boost::filesystem::path p(dir);
                     if(!boost::filesystem::exists(p)) {
                          boost::filesystem::create_directories(p);
                     }
                     XmlTransaction txn = pxmlmgr_->createTransaction();
                     XmlContainer cont = pxmlmgr_->openContainer(container, DBXML_TRANSACTIONAL|DB_THREAD|DB_CREATE);

                XmlUpdateContext updateContext = pxmlmgr_->createUpdateContext();
                     cont.putDocument(document, data, updateContext, 0);
                     
                     txn.commit();
      }

      deleteDocument() {
      XmlTransaction txn = pxmlmgr_->createTransaction();
                XmlContainer cont = pxmlmgr_->openContainer(container, DB_THREAD);
                XmlUpdateContext updateContext = pxmlmgr_->createUpdateContext();
                cont.deleteDocument(document, updateContext);          
                txn.commit();
      }
        • 1. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
          "Oracle, Sandra Whitman-Oracle"
          Hello,

          From the psudo code it looks like you need to pass
          the transactions created to the functions being called
          e.g. putDocument, getDocument, query. Please try that
          and let me know if the deadlock is resolved.

          Thanks,
          Sandra
          • 2. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
            721971
            Hi Sandra,
            Thanks for responding to my question. I did try that and still locking out. Below is the link to my dbxml related header and cpp file.

            dbxml_db.cpp : http://tinyurl.com/dbxml-db-cpp
            dbxml_db.hpp: http://tinyurl.com/dbxml-db-hpp

            DbXmlEnv = /dbxml/env
            Container Directory: /dbxml/resource-lists/users //NOTE:container directory is created at run time if doesn't exists.
            Container name: rjoshi
            Document name: presence

            My jmeter scripts invokes four functions: putDocument(), getDocument(), getDocumentNode() and deleteDocument(). When I use one thread and invoke each function sequentially, everything works great and I love the performance compare to other xml db but when I change number of threads to more than 1, after around 200 requests, all threads are in deadlock and nothing is getting processed.
            • 3. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
              "Oracle, Sandra Whitman-Oracle"
              Thanks for the pointers to the source,

              Could you also collect the db_stat -CA output at the first sign of the
              deadlock.

              Sandra
              • 4. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
                "Oracle, Sandra Whitman-Oracle"
                Hello,

                Looking at your source again, the function getXPathValue
                does not use a transaction. Also in getDocumentNode the
                transaction should be kept active until after going through
                the results and the transaction should be kept open in
                getDocument until after getting the data. In general
                transactions should be kept open until they are done with
                the objects the transaction is used to get. Can you make
                those changes and see if the deadlock still happens. If
                it does you can get the db_stat output.

                Thanks,
                Sandra
                • 5. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
                  721971
                  1. getXPathValue function is not yet used.
                  2. Regarding keeping the transaction open for getdocument, I thought it would unnecessary lock the object so thought of keeping document processing outside the transaction for performance but now I modified the source to include all processing within transaction. Still I am able to reproduce the issues.

                  Please see the updated source file at: http://tinyurl.com/dbxml-db-cpp-updated

                  Also please find below the output for 'db_state -h /dbxml/ENV -CA' command : http://rapidshare.com/files/280222122/dbstat.out.html

                  Error log:
                  |2009-Sep-14 22:51:08.203979|1|4|../src/db/dbxml_db.cpp:327|0xb0aa9000|-Error: DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock File: NsEventReader.cpp Line: 828
                  |2009-Sep-14 22:51:08.206832|2|4|../src/db/dbxml_db.cpp:212|0xb0923000|-Error: Document not found: presence
                  |2009-Sep-14 22:51:08.280468|3|4|../src/db/dbxml_db.cpp:327|0xb0aa9000|-Error: DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock File: NsEventReader.cpp Line: 828
                  |2009-Sep-14 22:51:08.444156|4|4|../src/db/dbxml_db.cpp:212|0xb0699000|-Error: DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock File: NsEventReader.cpp Line: 828
                  |2009-Sep-14 22:51:08.550313|5|4|../src/db/dbxml_db.cpp:411|0xb071b000|-Error: DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock File: NsEventReader.cpp Line: 828

                  Question: I am using two separate transactions objects: one for opening the container and 2nd for data processing. Should I be using only one transaction object for opening container and add/delete/updat-ing document?
                  • 6. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock
                    721971
                    Here is db_state -CA output if you can not download from rapidshare link.

                    efault locking region information:
                    4414 Last allocated locker ID
                    0x7fffffff Current maximum unused locker ID
                    9 Number of lock modes
                    1000 Maximum number of locks possible
                    1000 Maximum number of lockers possible
                    1000 Maximum number of lock objects possible
                    36 Number of current locks
                    47 Maximum number of locks at any one time
                    110 Number of current lockers
                    121 Maximum number of lockers at any one time
                    12 Number of current lock objects
                    19 Maximum number of lock objects at any one time
                    8051 Total number of locks requested
                    7849 Total number of locks released
                    0 Total number of locks upgraded
                    468 Total number of locks downgraded
                    615 Lock requests not available due to conflicts, for which we waited
                    8 Lock requests not available due to conflicts, for which we did not wait
                    152 Number of deadlocks
                    0 Lock timeout value
                    0 Number of locks that have timed out
                    0 Transaction timeout value
                    0 Number of transactions that have timed out
                    464KB The size of the lock region
                    32 The number of region locks that required waiting (0%)
                    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Lock REGINFO information:
                    Lock Region type
                    7 Region ID
                    /dbxml/ENV/__db.007 Region name
                    0x27000 Original region address
                    0x27000 Region address
                    0x27044 Region primary address
                    0 Region maximum allocation
                    0 Region allocated
                    Region allocations: 3005 allocations, 0 failures, 0 frees, 1 longest
                    REGION_JOIN_OK Region flags
                    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Lock region parameters:
                    786457 Lock region region mutex [33/26579 0% 5466/0]
                    1031 locker table size
                    1031 object table size
                    436 obj_off
                    45860 locker_off
                    0 need_dd
                    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Lock conflict matrix:
                    0 0 0 0 0 0 0 0 0
                    0 0 1 0 1 0 1 0 1
                    0 1 1 1 1 1 1 1 1
                    0 0 0 0 0 0 0 0 0
                    0 1 1 0 0 0 0 1 1
                    0 0 1 0 0 0 0 0 1
                    0 1 1 0 0 0 0 1 1
                    0 0 1 0 1 0 1 0 0
                    0 1 1 0 1 1 1 0 1
                    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Locks grouped by lockers:
                    Locker Mode Count Status ----------------- Object ---------------
                    109d dd=106 locks held 1 write locks 0 pid/thread 5447/0
                    109d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                    10a0 dd=105 locks held 0 write locks 0 pid/thread 5447/0
                    10a0 dd=105 locks held 0 write locks 0 pid/thread 5447/0
                    10a1 dd=104 locks held 1 write locks 0 pid/thread 5447/0
                    10a1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                    10a4 dd=103 locks held 0 write locks 0 pid/thread 5447/0
                    10a5 dd=102 locks held 1 write locks 0 pid/thread 5447/0
                    10a5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                    10a8 dd=101 locks held 0 write locks 0 pid/thread 5447/0
                    10a9 dd=100 locks held 1 write locks 0 pid/thread 5447/0
                    10a9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                    10ac dd=99 locks held 0 write locks 0 pid/thread 5447/0
                    10ad dd=98 locks held 1 write locks 0 pid/thread 5447/0
                    10ad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                    10b0 dd=97 locks held 0 write locks 0 pid/thread 5447/0
                    10b1 dd=96 locks held 2 write locks 0 pid/thread 5447/0
                    10b1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                    10b1 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    10b4 dd=95 locks held 0 write locks 0 pid/thread 5447/0
                    10b8 dd=94 locks held 1 write locks 0 pid/thread 5447/0
                    10b8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                    10bb dd=93 locks held 0 write locks 0 pid/thread 5447/0
                    10bc dd=92 locks held 2 write locks 0 pid/thread 5447/0
                    10bc READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                    10bc READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    10bf dd=91 locks held 0 write locks 0 pid/thread 5447/0
                    10ed dd=90 locks held 2 write locks 0 pid/thread 5447/0
                    10ed READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                    10ed READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    10f0 dd=89 locks held 0 write locks 0 pid/thread 5447/0
                    10f5 dd=88 locks held 0 write locks 0 pid/thread 5447/0
                    10f6 dd=87 locks held 0 write locks 0 pid/thread 5447/0
                    10f7 dd=86 locks held 0 write locks 0 pid/thread 5447/0
                    10f8 dd=85 locks held 0 write locks 0 pid/thread 5447/0
                    10f9 dd=84 locks held 0 write locks 0 pid/thread 5447/0
                    10fa dd=83 locks held 0 write locks 0 pid/thread 5447/0
                    10fb dd=82 locks held 0 write locks 0 pid/thread 5447/0
                    10fc dd=81 locks held 0 write locks 0 pid/thread 5447/0
                    10fd dd=80 locks held 0 write locks 0 pid/thread 5447/0
                    10fe dd=79 locks held 0 write locks 0 pid/thread 5447/0
                    10ff dd=78 locks held 0 write locks 0 pid/thread 5447/0
                    1100 dd=77 locks held 0 write locks 0 pid/thread 5447/0
                    1101 dd=76 locks held 0 write locks 0 pid/thread 5447/0
                    1102 dd=75 locks held 0 write locks 0 pid/thread 5447/0
                    1103 dd=74 locks held 0 write locks 0 pid/thread 5447/0
                    1104 dd=73 locks held 0 write locks 0 pid/thread 5447/0
                    1105 dd=72 locks held 0 write locks 0 pid/thread 5447/0
                    1106 dd=71 locks held 0 write locks 0 pid/thread 5447/0
                    1107 dd=70 locks held 0 write locks 0 pid/thread 5447/0
                    1108 dd=69 locks held 0 write locks 0 pid/thread 5447/0
                    1109 dd=68 locks held 0 write locks 0 pid/thread 5447/0
                    110a dd=67 locks held 0 write locks 0 pid/thread 5447/0
                    110b dd=66 locks held 0 write locks 0 pid/thread 5447/0
                    110c dd=65 locks held 0 write locks 0 pid/thread 5447/0
                    110d dd=64 locks held 0 write locks 0 pid/thread 5447/0
                    110e dd=63 locks held 0 write locks 0 pid/thread 5447/0
                    110f dd=62 locks held 0 write locks 0 pid/thread 5447/0
                    1110 dd=61 locks held 0 write locks 0 pid/thread 5447/0
                    1111 dd=60 locks held 0 write locks 0 pid/thread 5447/0
                    1112 dd=59 locks held 0 write locks 0 pid/thread 5447/0
                    1113 dd=58 locks held 0 write locks 0 pid/thread 5447/0
                    1114 dd=57 locks held 0 write locks 0 pid/thread 5447/0
                    1115 dd=56 locks held 0 write locks 0 pid/thread 5447/0
                    1116 dd=55 locks held 0 write locks 0 pid/thread 5447/0
                    1117 dd=54 locks held 0 write locks 0 pid/thread 5447/0
                    1118 dd=53 locks held 0 write locks 0 pid/thread 5447/0
                    1119 dd=52 locks held 0 write locks 0 pid/thread 5447/0
                    111a dd=51 locks held 0 write locks 0 pid/thread 5447/0
                    111b dd=50 locks held 0 write locks 0 pid/thread 5447/0
                    111c dd=49 locks held 0 write locks 0 pid/thread 5447/0
                    111d dd=48 locks held 0 write locks 0 pid/thread 5447/0
                    111e dd=47 locks held 0 write locks 0 pid/thread 5447/0
                    111f dd=46 locks held 0 write locks 0 pid/thread 5447/0
                    1120 dd=45 locks held 0 write locks 0 pid/thread 5447/0
                    1121 dd=44 locks held 0 write locks 0 pid/thread 5447/0
                    1122 dd=43 locks held 0 write locks 0 pid/thread 5447/0
                    1123 dd=42 locks held 0 write locks 0 pid/thread 5447/0
                    1124 dd=41 locks held 0 write locks 0 pid/thread 5447/0
                    1125 dd=40 locks held 0 write locks 0 pid/thread 5447/0
                    1126 dd=39 locks held 0 write locks 0 pid/thread 5447/0
                    1127 dd=38 locks held 0 write locks 0 pid/thread 5447/0
                    1128 dd=37 locks held 0 write locks 0 pid/thread 5447/0
                    1129 dd=36 locks held 0 write locks 0 pid/thread 5447/0
                    112a dd=35 locks held 0 write locks 0 pid/thread 5447/0
                    112b dd=34 locks held 0 write locks 0 pid/thread 5447/0
                    112c dd=33 locks held 0 write locks 0 pid/thread 5447/0
                    112d dd=32 locks held 0 write locks 0 pid/thread 5447/0
                    112e dd=31 locks held 0 write locks 0 pid/thread 5447/0
                    112f dd=30 locks held 0 write locks 0 pid/thread 5447/0
                    1130 dd=29 locks held 0 write locks 0 pid/thread 5447/0
                    1131 dd=28 locks held 0 write locks 0 pid/thread 5447/0
                    1132 dd=27 locks held 0 write locks 0 pid/thread 5447/0
                    1133 dd=26 locks held 0 write locks 0 pid/thread 5447/0
                    1134 dd=25 locks held 0 write locks 0 pid/thread 5447/0
                    1135 dd=24 locks held 0 write locks 0 pid/thread 5447/0
                    1136 dd=23 locks held 0 write locks 0 pid/thread 5447/0
                    1137 dd=22 locks held 0 write locks 0 pid/thread 5447/0
                    1138 dd=21 locks held 0 write locks 0 pid/thread 5447/0
                    1139 dd=20 locks held 0 write locks 0 pid/thread 5447/0
                    113a dd=19 locks held 0 write locks 0 pid/thread 5447/0
                    113b dd=18 locks held 0 write locks 0 pid/thread 5447/0
                    113c dd=17 locks held 0 write locks 0 pid/thread 5447/0
                    113d dd=16 locks held 0 write locks 0 pid/thread 5447/0
                    113e dd=15 locks held 0 write locks 0 pid/thread 5447/0
                    800003ed dd=14 locks held 1 write locks 0 pid/thread 5447/0
                    800003ed READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003ed READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f1 dd=12 locks held 1 write locks 0 pid/thread 5447/0
                    800003f1 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f1 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f3 dd=11 locks held 0 write locks 0 pid/thread 5447/0
                    800003f4 dd=11 locks held 1 write locks 0 pid/thread 5447/0
                    800003f4 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f4 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f6 dd=10 locks held 0 write locks 0 pid/thread 5447/0
                    800003f7 dd=10 locks held 1 write locks 0 pid/thread 5447/0
                    800003f7 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f7 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f9 dd= 9 locks held 0 write locks 0 pid/thread 5447/0
                    800003fa dd= 9 locks held 1 write locks 0 pid/thread 5447/0
                    800003fa READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fa READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fc dd= 8 locks held 1 write locks 0 pid/thread 5447/0
                    800003fc READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fc READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fe dd= 7 locks held 1 write locks 0 pid/thread 5447/0
                    800003fe READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fe READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fc dd= 8 locks held 1 write locks 0 pid/thread 5447/0
                    800003fc READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fc READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fe dd= 7 locks held 1 write locks 0 pid/thread 5447/0
                    800003fe READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fe READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    80000400 dd= 6 locks held 0 write locks 0 pid/thread 5447/0
                    80000401 dd= 6 locks held 1 write locks 0 pid/thread 5447/0
                    80000401 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    80000401 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    80000407 dd= 3 locks held 0 write locks 0 pid/thread 5447/0
                    80000408 dd= 3 locks held 1 write locks 0 pid/thread 5447/0
                    80000408 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    80000408 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    8000040a dd= 2 locks held 1 write locks 0 pid/thread 5447/0
                    8000040a READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    8000040a READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    8000040c dd= 1 locks held 0 write locks 0 pid/thread 5447/0
                    8000040d dd= 1 locks held 1 write locks 0 pid/thread 5447/0
                    8000040d READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    8000040d READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                    Locks grouped by object:
                    Locker Mode Count Status ----------------- Object ---------------
                    10a1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4

                    10a5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6

                    10b1 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    10bc READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    10ed READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                    109d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2

                    10b1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12

                    8000040a READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    8000040d READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f1 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fe READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f4 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    80000401 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    80000408 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003ed READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003f7 READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fa READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13
                    800003fc READ 1 PENDING /dbxml/resource-lists/users/rjoshi page 13

                    10b8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14

                    10a9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8

                    10ad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10

                    800003f1 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f4 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003ed READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003f7 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fa READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fc READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    800003fe READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    80000401 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    80000408 READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    8000040a READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11
                    8000040d READ 1 HELD /dbxml/resource-lists/users/rjoshi page 11

                    10bc READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16

                    10ed READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                    • 7. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                      721971
                      Guys, I am stuck and really appreciate if you can give me hint on deadlock.
                      • 8. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                        "Oracle, Sandra Whitman-Oracle"
                        Apologies on the delay, I will take another look and get back to you.
                        • 9. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                          "Oracle, Sandra Whitman-Oracle"
                          Hello,

                          Again apologies on the delay. The db_stat output
                          is very strange. It is showing several transactions
                          waiting for a read lock on page 13, but it does not
                          show any transaction holding the write lock on page 13.
                          There are no write locks at all.

                          Using a transaction to open the container then another
                          to do the operations will not cause a hang, so that
                          is not the problem as long as you are committing the
                          open container transaction before starting the next
                          operation with another transaction.

                          Are you running this after a crash or something like
                          that? It could be that an earlier crash left a lock on
                          page 13 and that recovery needs to be run.

                          If you have a test case that I can use to reproduce the
                          problem I will also give it a try here.


                          Thanks,
                          Sandra
                          • 10. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                            "Oracle, Sandra Whitman-Oracle"
                            Hello,

                            A few additional points,

                            1. What platform are you on?
                            The db_stat output is showing no evidence of a deadlock,
                            only a hang. From that output, you'll notice that no
                            threads are listed although there are a number of transactions.
                            This implies that all transactions belong to the same thread
                            and looking at the individual stack traces will identify
                            where the hang is.

                            2. There are still some potential coding issues here:

                            2a. In DbXmlDb.hpp there is a DbEnv instance which is
                            a member of your class. If using DbEnv as a data member
                            it is usually best to use new/delete vs making it a member.

                            2b. In DbXmlDB.cpp DBXML_ADOPT_DBENV is being used.
                            DBXML_ADOPT_DBENV requires that DbEnv be created via
                            new() as it calls delete() on it.

                            2c. In general is it best not to open containers upon
                            each use. Containers should be opened and shared among
                            threads.

                            2d. Instead of using a transaction for opening containers
                            use DBXML_TRANSACTIONAL|DB_THREAD. Also the use of
                            DB_RDONLY in the read cases will not change anything significant
                            as open instances are shared and the state of the first
                            one is the only one that counts.

                            2e. The setting of DB_THREAD looks to be used inconsistently.
                            It should be used all the time if the application is
                            making use of threading.

                            2f. I can not tell for sure from looking at the cpp file,but
                            just make sure that operation-based transactions are consistently
                            passed in the application.

                            Thanks,
                            Sandra

                            Edited by: Oracle, Sandra Whitman on Sep 23, 2009 12:27 PM
                            • 11. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                              721971
                              1. What platform are you on?
                              rjoshi>>I am running on mac OSX 10.5.8

                              2. There are still some potential coding issues here:

                              2a. In DbXmlDb.hpp there is a DbEnv instance which is
                              a member of your class. If using DbEnv as a data member
                              it is usually best to use new/delete vs making it a member.
                              rjoshi>>I have modified code to use new/delete

                              2b. In DbXmlDB.cpp DBXML_ADOPT_DBENV is being used.
                              DBXML_ADOPT_DBENV requires that DbEnv be created via
                              new() as it calls delete() on it.

                              rjoshi>> modified code to use new/delete

                              2c. In general is it best not to open containers upon
                              each use. Containers should be opened and shared among
                              threads.

                              rjoshi>> In real application, multiple devices (e.g IM, Phone) can read/write same document but it's not always the case so I don't want to open the container and keep in the memory. There is no way for me to know when to close the container. Is there any way to set flag where container can be open for certain duration and if not used, it will get closed and removed from memory?

                              2d. Instead of using a transaction for opening containers
                              use DBXML_TRANSACTIONAL|DB_THREAD. Also the use of
                              DB_RDONLY in the read cases will not change anything significant
                              as open instances are shared and the state of the first
                              one is the only one that counts.

                              rjoshi>> In init() function, I am setting default container flags as
                              pxmlmgr_->setDefaultContainerFlags(DB_CREATE | DB_THREAD
                                             | DBXML_TRANSACTIONAL);
                              Do I still need to set these flags while opening the container?

                              2e. The setting of DB_THREAD looks to be used inconsistently.
                              It should be used all the time if the application is
                              making use of threading.

                              rjoshi>> Again I was setting default flag for container as below in the init() function so was not using it. I have corrected the inconsistency.
                              pxmlmgr_->setDefaultContainerFlags(DB_CREATE | DB_THREAD
                                             | DBXML_TRANSACTIONAL);

                              2f. I can not tell for sure from looking at the cpp file,but
                              just make sure that operation-based transactions are consistently
                              passed in the application.

                              rjoshi>> I have removed transactions while opening the container and using all other places.

                              Still I am able to reproduce the deadlock. Please see the below output of db_state -CA.

                              bash-3.2$ ./db_stat -h /dbxml/ENV -CA
                              Default locking region information:
                              3327     Last allocated locker ID
                              0x7fffffff     Current maximum unused locker ID
                              9     Number of lock modes
                              1000     Maximum number of locks possible
                              1000     Maximum number of lockers possible
                              1000     Maximum number of lock objects possible
                              39     Number of current locks
                              143     Maximum number of locks at any one time
                              75     Number of current lockers
                              313     Maximum number of lockers at any one time
                              12     Number of current lock objects
                              26     Maximum number of lock objects at any one time
                              6643     Total number of locks requested
                              6560     Total number of locks released
                              0     Total number of locks upgraded
                              2166     Total number of locks downgraded
                              531     Lock requests not available due to conflicts, for which we waited
                              9     Lock requests not available due to conflicts, for which we did not wait
                              0     Number of deadlocks
                              0     Lock timeout value
                              0     Number of locks that have timed out
                              0     Transaction timeout value
                              0     Number of transactions that have timed out
                              464KB     The size of the lock region
                              60     The number of region locks that required waiting (0%)
                              =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                              Lock REGINFO information:
                              Lock     Region type
                              7     Region ID
                              /dbxml/ENV/__db.007     Region name
                              0xf000     Original region address
                              0xf000     Region address
                              0xf044     Region primary address
                              0     Region maximum allocation
                              0     Region allocated
                              Region allocations: 3005 allocations, 0 failures, 0 frees, 1 longest
                              REGION_JOIN_OK     Region flags
                              =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                              Lock region parameters:
                              786457     Lock region region mutex [60/23741 0% 12394/0]
                              1031     locker table size
                              1031     object table size
                              436     obj_off
                              45860     locker_off
                              1     need_dd
                              =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                              Lock conflict matrix:
                              0     0     0     0     0     0     0     0     0     
                              0     0     1     0     1     0     1     0     1     
                              0     1     1     1     1     1     1     1     1     
                              0     0     0     0     0     0     0     0     0     
                              0     1     1     0     0     0     0     1     1     
                              0     0     1     0     0     0     0     0     1     
                              0     1     1     0     0     0     0     1     1     
                              0     0     1     0     1     0     1     0     0     
                              0     1     1     0     1     1     1     0     1     
                              =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                              Locks grouped by lockers:
                              Locker Mode Count Status ----------------- Object ---------------
                              c3e dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c3e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                              c41 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c42 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c42 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                              c45 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c46 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c46 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                              c49 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c4a dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c4a READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                              c4d dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c4e dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c4e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                              c51 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c52 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              c52 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                              c52 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              c55 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c59 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c59 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                              c5c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c5d dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              c5d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                              c5d READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              c60 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000325 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000326 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              80000326 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                              80000326 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                              80000327 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c8e dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                              c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              80000328 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              80000328 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                              80000328 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                              8000032a dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c91 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032b dd= 0 locks held 3 write locks 1 pid/thread 12389/0
                              8000032b WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              8000032b READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
                              8000032b WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
                              8000032b READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
                              8000032c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032c READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              c93 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032d dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c94 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032e dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032e READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              c95 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              8000032f dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000330 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000330 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000331 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000332 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000332 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              c99 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c99 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                              80000333 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000333 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000334 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000334 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000335 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              c9c dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000336 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              80000336 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              c9d dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              c9d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                              ca0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              ca1 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              ca1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                              ca4 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              ca5 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              ca5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                              ca8 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              ca9 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              ca9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                              cac dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cad dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              cad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                              cad READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              cb0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cb4 dd= 0 locks held 1 write locks 0 pid/thread 12389/0
                              cb4 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                              cb7 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cb8 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              cb8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                              cb8 READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              cbb dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              ce9 dd= 0 locks held 2 write locks 0 pid/thread 12389/0
                              ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                              ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              cec dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              ced dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cee dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cef dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf0 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf1 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf2 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf3 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf4 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf5 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf6 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf7 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf8 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cf9 dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cfa dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cfb dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cfc dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cfd dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cfe dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              cff dd= 0 locks held 0 write locks 0 pid/thread 12389/0
                              =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                              Locks grouped by object:
                              Locker Mode Count Status ----------------- Object ---------------
                              80000326 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                              80000328 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                              8000032b READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
                              8000032b WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              8000032c READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              8000032e READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000330 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000332 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000333 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000334 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                              80000336 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11

                              c4e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                              ca9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10

                              c4a READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                              ca5 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8

                              c59 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                              cb4 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14

                              8000032b WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
                              8000032b READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
                              80000328 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                              80000326 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13

                              c52 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                              cad READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12

                              c3e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                              c99 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2

                              c52 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              c5d READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              cad READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              cb8 READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                              ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0

                              c46 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                              ca1 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6

                              c42 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                              c9d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4

                              c8e READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                              ce9 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18

                              c5d READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                              cb8 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                              • 12. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                                721971
                                What I found is when I execute putDocument() and deleteDocument() functions in multiple threads, after few requests (just 4), it goes into deadlock. But when I run getDocument() and putDocument() or getDocument() and deleteDocument() in multiple threads, everything works fine which means putDocument and deleteDocument() both try to add/remove the same document which is causing the deadlock.

                                Below is the links for source and header file.

                                dbxml_db.hpp:
                                http://xcapserver.svn.sourceforge.net/viewvc/xcapserver/trunk/XCAPServer%2B%2B/include/db/dbxml_db.hpp?view=markup&pathrev=30

                                dbxml_db.cpp:
                                http://xcapserver.svn.sourceforge.net/viewvc/xcapserver/trunk/XCAPServer%2B%2B/src/db/dbxml_db.cpp?view=markup&pathrev=30

                                Please see below db_state -CA log.

                                Default locking region information:
                                117504     Last allocated locker ID
                                0x7fffffff     Current maximum unused locker ID
                                9     Number of lock modes
                                1000     Maximum number of locks possible
                                1000     Maximum number of lockers possible
                                1000     Maximum number of lock objects possible
                                41     Number of current locks
                                145     Maximum number of locks at any one time
                                77     Number of current lockers
                                317     Maximum number of lockers at any one time
                                12     Number of current lock objects
                                40     Maximum number of lock objects at any one time
                                454400     Total number of locks requested
                                454313     Total number of locks released
                                0     Total number of locks upgraded
                                73252     Total number of locks downgraded
                                36856     Lock requests not available due to conflicts, for which we waited
                                9     Lock requests not available due to conflicts, for which we did not wait
                                0     Number of deadlocks
                                0     Lock timeout value
                                0     Number of locks that have timed out
                                0     Transaction timeout value
                                0     Number of transactions that have timed out
                                464KB     The size of the lock region
                                2596     The number of region locks that required waiting (0%)
                                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                Lock REGINFO information:
                                Lock     Region type
                                7     Region ID
                                /dbxml/ENV/__db.007     Region name
                                0xf000     Original region address
                                0xf000     Region address
                                0xf044     Region primary address
                                0     Region maximum allocation
                                0     Region allocated
                                Region allocations: 3005 allocations, 0 failures, 0 frees, 1 longest
                                REGION_JOIN_OK     Region flags
                                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                Lock region parameters:
                                786457     Lock region region mutex [2596/1223898 0% 12454/0]
                                1031     locker table size
                                1031     object table size
                                436     obj_off
                                45860     locker_off
                                1     need_dd
                                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                Lock conflict matrix:
                                0     0     0     0     0     0     0     0     0     
                                0     0     1     0     1     0     1     0     1     
                                0     1     1     1     1     1     1     1     1     
                                0     0     0     0     0     0     0     0     0     
                                0     1     1     0     0     0     0     1     1     
                                0     0     1     0     0     0     0     0     1     
                                0     1     1     0     0     0     0     1     1     
                                0     0     1     0     1     0     1     0     0     
                                0     1     1     0     1     1     1     0     1     
                                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                Locks grouped by lockers:
                                Locker Mode Count Status ----------------- Object ---------------
                                80008c02 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c03 dd= 0 locks held 3 write locks 1 pid/thread 12445/0
                                80008c03 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c03 READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
                                80008c03 WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
                                80008c03 READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c08 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c09 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                80008c09 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c09 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0a dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c0b dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                80008c0b READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c0b READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0c dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c0d dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                80008c0d READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c0d READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0e dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c0f dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                80008c0f READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c0f READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c10 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c11 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c11 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c12 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c13 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c13 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c14 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c15 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c15 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c16 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c17 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c17 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c18 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c19 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                80008c19 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                1ca40 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca40 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                                1ca43 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca44 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca44 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                                1ca47 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca48 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca48 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                                1ca4b dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca4c dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca4c READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                                1ca4f dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca50 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca50 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                                1ca53 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca54 dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1ca54 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                                1ca54 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1ca57 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca5b dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca5b READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                                1ca5e dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca5f dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1ca5f READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                                1ca5f READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1ca62 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca90 dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1ca90 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                                1ca90 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1ca93 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca98 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca98 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                                1ca9b dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca9c dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1ca9c READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                                1ca9d dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1ca9e dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caa1 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caa2 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caa3 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1caa3 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                                1caa6 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caa7 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1caa7 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                                1caaa dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caab dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1caab READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                                1caae dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caaf dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1caaf READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                                1caaf READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1cab2 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cab6 dd= 0 locks held 1 write locks 0 pid/thread 12445/0
                                1cab6 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                                1cab9 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caba dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1caba READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                                1caba READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1cabd dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caeb dd= 0 locks held 2 write locks 0 pid/thread 12445/0
                                1caeb READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                                1caeb READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1caee dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caef dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf0 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf1 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf2 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf3 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf4 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf5 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf6 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf7 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf8 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caf9 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cafa dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cafb dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cafc dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cafd dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cafe dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1caff dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                1cb00 dd= 0 locks held 0 write locks 0 pid/thread 12445/0
                                =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                                Locks grouped by object:
                                Locker Mode Count Status ----------------- Object ---------------
                                1ca5f READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16
                                1caba READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 16

                                1ca90 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18
                                1caeb READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 18

                                1ca4c READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8
                                1caa7 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 8

                                80008c03 READ 3 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c09 READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0b READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0d READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c0f READ 2 HELD /dbxml/resource-lists/users/rjoshi page 11
                                80008c03 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c11 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c13 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c15 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c17 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11
                                80008c19 READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 11

                                1ca50 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10
                                1caab READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 10

                                80008c03 WRITE 14 HELD /dbxml/resource-lists/users/rjoshi page 13
                                80008c03 READ 7 HELD /dbxml/resource-lists/users/rjoshi page 13
                                80008c0b READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c09 WRITE 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c0d READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13
                                80008c0f READ 1 WAIT /dbxml/resource-lists/users/rjoshi page 13

                                1ca54 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12
                                1caaf READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 12

                                1ca5b READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14
                                1cab6 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 14

                                1ca54 READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1ca5f READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1ca90 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1caaf READ 6 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1caba READ 2 HELD /dbxml/resource-lists/users/rjoshi handle 0
                                1caeb READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 0

                                1ca40 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2
                                1ca98 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 2

                                1ca44 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4
                                1ca9c READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 4

                                1ca48 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                                1caa3 READ 1 HELD /dbxml/resource-lists/users/rjoshi handle 6
                                • 13. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                                  Laurenfoutz-Oracle
                                  I can see why you are experiencing deadlock when you put/delete the same document. In your putDocument code, if the document does not exists (i.e. the delete thread deleted it first) then you create a new transaction to add the document, even though you never committed the previous transaction due to the DOCUMENT_NOT_FOUND exception. Multiple active transactions in a thread are one cause of undetectable deadlock.
                                  You should rewrite that function (and your other functions) to always commit or abort a transaction, even if an exception is thrown.

                                  Lauren Foutz
                                  • 14. Re: DBXML 2.4.16:  Accessing containers from multiple threads and deadlock.
                                    "Oracle, Sandra Whitman-Oracle"
                                    Hello,

                                    Just to answer your other questions:

                                    1. Is there any way to set flag where container can be open for
                                    certain duration and if not used, it will get closed and removed
                                    from memory?

                                    A timeout could be implemented by the application to do this.
                                    Open containers don't take up much memory and closing a container
                                    flushes the cache.

                                    2. If the default container flags are set as:
                                    pxmlmgr_->setDefaultContainerFlags(DB_CREATE | DB_THREAD | DBXML_TRANSACTIONAL);
                                    Do the flags still need to be set while opening the container?

                                    No, the flags do not need to be set while opening the container,
                                    but be sure to not pass explicit flags to the open (or make them
                                    inconsistent) as they will override the default.

                                    3. The latest DbXmlDB.cpp has the following:
                                    116 pdbEnv_->set_cachesize(2, 524288000, 3);
                                    117      //pdbEnv_->set_lk_detect(DB_LOCK_MINWRITE);

                                    The set_lk_detect method is required for deadlocks to be
                                    detected and thrown. If you are not using set_lk_detect
                                    at all, that could cause a deadlock.


                                    Thanks,
                                    Sandra
                                    1 2 Previous Next