Lock conflicts

I'm quite a newbie when it comes to using Berkeley DB. I am using BDB
dbxml.
I have an application that fetches data from an external source and
writes that into dbxml. The data fetch takes a long time, so I start a
new thread to do this. All writes into dbxml for that batch are then
done in that same new thread.
When I have a few batches running at the same time, after variable
amounts of time, the application will hang. When this happens my only
option is to run db_recover.
The problem happens when I have more than one of these: multiple writes
in multiple threads. I am protecting everything with transactions, but
am getting lock conflicts.
The output of db_stat -CA includes this:
1 Total number of locks not immediately available due to
conflicts
80000275 READ 28 HELD RefData page
3105
80000275 WRITE 55 HELD RefData page
3105
80000276 READ 1 WAIT RefData page
3105
Unfortunately, I don't know how to interpret this. How do I tell where
the conflict is happening? What sort of pattern should I be following
to prevent this from happening?
I don't know what information would help make the above clearer, but am happy to provide more.
Many thanks,
PC

After reading some more of the manual, I see the following paragraph:
"This has important implications. If a single thread of control opens two cursors, uses a combination of cursor and non-cursor operations, or begins two separate transactions, the operations are performed on behalf of different lockers. Conflicts that arise between these different lockers may not cause actual deadlocks, but can, in fact, permanently block the thread of control. For example, assume that an application creates a cursor and uses it to read record A. Now, assume a second cursor is opened, and the application attempts to write record A using the second cursor. Unfortunately, the first cursor has a read lock, so the second cursor cannot obtain its write lock. However, that read lock is held by the same thread of control, so the read lock can never be released if we block waiting for the write lock. This might appear to be a deadlock from the application's perspective, but Berkeley DB cannot identify it as such because it has no knowledge of which lockers belong to which threads of control. For this reason, application designers are encouraged to close cursors as soon as they are done with them."
I am wondering if this is what is happening as db_deadlock is not returning anything.
In dbxml, how is a cursor created?
In order to make modifications to nodes, first I have to select those nodes. I then have to modify those nodes. Presumably, a select will create a read lock, and a modify will then create a write lock? In my application i have a function "setValues" that does this- first select nodes, then modify the selected nodes in some way. I am wondering if two instances of setValues in separate threads are causing the problem.
I see that I have a read lock waiting on a write lock. How do I tell which reads and writes these are happening on?
Thanks,
PC

Similar Messages

  • SSAS 2012 Tabular Error: The operation was cancelled because of locking conflicts

    I have a 800 mb SSAS database that I refresh(Process current day partition) every 30 minutes. As soon as the processing starts all my users get error The operation was cancelled because of locking conflicts. I ran the deadlocks trace as described in http://blogs.msdn.com/b/sql_pfe_blog/archive/2009/08/27/deadlock-troubleshooting-in-sql-server-analysis-services-ssas.aspx
    but all I see is the processing start and all the users getting the error ("The operation was cancelled because of locking conflicts") 22 mil sec after the processing starts.
    I also ran "select * from $system.discover_locks" but I only see lock types 2,4 and 8. None of which seem to be exclusive
    This is SSAS 2012 with sp 1
    Database Architect

    Hi Derek,
    According to your description, you get the dead lock error when processing partition. Right?
    In Analysis Services, this error occurs when lock manager detects a dead lock. Lock type 2,4 and 8 can also have two transactions waiting each other and cause deadlock. In this scenario, please check the Dead Lock Graph in SQL Profiler
    and find the related processes. Check what the processes work for to see if you need to do parallel processing or process other objects before partition processing.
    Best Regards, 
    Simon Hou
    TechNet Community Support

  • Locked conflicts

    Hi experts,
    While resolving Integration Conflicts, i have selected '' Accept Active" option for few files. These files have not been fixed with resolution. NOW I see them again under Integration Conflicts --> active node even after checkin.  Also from DTR,  these files shows the state "Locked" instead of Resolved. How do I unlock these files and do conflict resolution?
    Thanks,
    Tony.

    Hi Tony,
    Hope you are doing good.
    I hope that the modifications are being applied to the inactive workspace and then the changes will reach the active workspace upon activation of the respective activity. The correct strategy is to solve the conflict in dev/inactive, activate and release the activity and import it into consolidation. This way the conflict will be solved in all four workspaces.
    Further, a prerequisite for conflict resolution is that you have created a project for the affected DC.
    You can find all the information in this regard here:
    http://help.sap.com/saphelp_nw73/helpdata/en/49/1cf4e8096d16b8e10000000a42189d/content.htm
    and http://scn.sap.com/docs/DOC-1178
    Hope this helps.
    Warm regards,
    Hemanth

  • How to avoid lock conflict

    In the program when a transaction is called first time it is locked then inside that standard SAP function is which is trying to lock the same transaction again.Since it was locked before it is giving out error

    >
    balaji gautham wrote:
    > In the program when a transaction is called first time it is locked then inside that standard SAP function is which is trying to lock the same transaction again.Since it was locked before it is giving out error
    Hi ,
    You u can avoid the error message by release the lock manually  by doing a direct database update to table TSTC.
    The field CINFO holds the value A0 when locked, when unlocked, it holds the value 80 .
    Regards ,
    Rajesh Kumar

  • IP lock conflict

    Hi,
    Sometimes we have a situation that the IP lock exists in  SM12 while the user already not using the application. It happens when in several situations (user closes the report not in appropriate way, connection error, PC crash and so on).
    It prevents from other users to work, so we enter the manually remove the stuck session from SM04.
    Is there a solution for that kind of problem ?
    Dimitry Haritonov

    Hi there,
    As far as I know, you have to manually delete the lock entry under the transaction sm12
    You can also define a time out session for a session not used for 30 minutes or more, that way if the user don't use the SAP system after 30 minutes that session is killed automatically and the locks should be gone.
    Hope this helps,
    Regards,
    Diogo.

  • The operation was cancelled because of locking conflicts.

    Hi All,
    We are facing a issue as below when we access the cube via excel.
    Can you please help with the reason and if possible how to solve it.
    Thanks, Tanmoy Santra

    Hi Tanmoy,
    I recommend you take a look at the following article about deadlock Troubleshooting in SQL Server Analysis Services, please see:
    http://blogs.msdn.com/b/sql_pfe_blog/archive/2009/08/27/deadlock-troubleshooting-in-sql-server-analysis-services-ssas.aspx
    In addition, what's the version of your SQL Server? Please try to install the latest Service Pack for SQL Server to see if this helps. Here is a KB article about this issue, please see:
    SQL Server 2008 Service Pack 2 and SQL Server 2008 R2 Service Pack 2 enhancements to the "Operation has been cancelled" error message text in Analysis Services:
    http://support.microsoft.com/kb/2216456
    If you have any feedback on our support, please click
    here.
    Regards,
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Intermittent Lock Timeout Exceptions with JE 5.0.58

    Hi,
    During tests, the system continues to experience Lock Timeout problems from time to time, even with the latest version 5.0.58. The collection contains data which is typically removed shortly after inserted, so records usually have a short lifetime. There are multiple writer threads and 1 delete / reader thread.
    Any tips? Note the timeout is already a healthy 3 minutes long, so I don't think that's the problem. Stack trace and details below.
    Maybe the best thing to do is to reduce the lock timeout in order to not block the data pipeline, if a simple retry fixes it?
    Thanks,
    Karl
    ERROR@00:08:03 com.sleepycat.je.LockTimeoutException: (JE 5.0.58) Lock expired. Locker 879535510 -1_dbreader--Thread-5_ThreadLocker: waited for lock on database=persist#ListenerStore#com.procon.data.msg.local.BerkeleyDBMessage LockAddr:
    892328566 LSN=0xffffffff/0x5882af type=READ grant=WAIT_NEW timeoutMillis=180000 startTime=1344323103818 endTime=1344323283850
    Owners: [<LockInfo locker="1242902705 -1_CAL-dbwriter--Thread-18_ThreadLocker" type="WRITE"/>]
    Waiters: []
    com.sleepycat.je.txn.LockManager.newLockTimeoutException(LockManager.java:664)
    com.sleepycat.je.txn.LockManager.makeTimeoutMsgInternal(LockManager.java:623)
    com.sleepycat.je.txn.SyncedLockManager.makeTimeoutMsg(SyncedLockManager.java:97)
    com.sleepycat.je.txn.LockManager.lockInternal(LockManager.java:390)
    com.sleepycat.je.txn.LockManager.lock(LockManager.java:276)
    com.sleepycat.je.txn.BasicLocker.lockInternal(BasicLocker.java:118)
    com.sleepycat.je.txn.Locker.lock(Locker.java:443)
    com.sleepycat.je.dbi.CursorImpl.lockLN(CursorImpl.java:2589)
    com.sleepycat.je.dbi.CursorImpl.lockLN(CursorImpl.java:2390)
    com.sleepycat.je.dbi.CursorImpl.searchAndPosition(CursorImpl.java:2118)
    com.sleepycat.je.Cursor.searchInternal(Cursor.java:2666)
    com.sleepycat.je.Cursor.searchAllowPhantoms(Cursor.java:2576)
    com.sleepycat.je.Cursor.searchNoDups(Cursor.java:2430)
    com.sleepycat.je.Cursor.search(Cursor.java:2397)
    com.sleepycat.je.Cursor.readPrimaryAfterGet(Cursor.java:3703)
    com.sleepycat.je.SecondaryCursor.readPrimaryAfterGet(SecondaryCursor.java:1470)
    com.sleepycat.je.SecondaryCursor.retrieveNext(SecondaryCursor.java:1448)
    com.sleepycat.je.SecondaryCursor.getNext(SecondaryCursor.java:560)
    com.sleepycat.util.keyrange.RangeCursor.doGetNext(RangeCursor.java:897)
    com.sleepycat.util.keyrange.RangeCursor.getNext(RangeCursor.java:451)
    com.sleepycat.persist.BasicCursor.next(BasicCursor.java:80)
    com.sleepycat.persist.BasicIterator.hasNext(BasicIterator.java:49)
    com.procon.data.msg.local.BerkeleyDBMessageStore.queryMessages(BerkeleyDBMessageStore.java:498)
    com.procon.listener.DatabaseReader.runMain(DatabaseReader.java:161)
    com.procon.base.BasicRunnable.run(BasicRunnable.java:274)
    java.lang.Thread.run(Thread.java:662)

    Karl,
    With a 3 minute timeout, you may have a true deadlock (which are sometimes expected) or a bug in your app where you neglect to close a cursor or close a transaction. Increasing the lock timeout is usually not the solution, but the first step is to diagnose what is causing it, and you haven't given us enough information to do that. You haven't said what isolation modes you're using, what transactions are active, how many records are involved in each transactions, etc.
    I suggest that you read:
    http://docs.oracle.com/cd/E17277_02/html/TransactionGettingStarted/index.html
    in particular the Concurrency chapter.
    Also see:
    http://www.oracle.com/technetwork/database/berkeleydb/je-faq-096044.html#HowdoIdebugalocktimeout
    for how to get more information about this particular lock conflict.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • BDB read performance problem: lock contention between GC and VM threads

    Problem: BDB read performance is really bad when the size of the BDB crosses 20GB. Once the database crosses 20GB or near there, it takes more than one hour to read/delete/add 200K keys.
    After a point, of these 200K keys there are about 15-30K keys that are new and this number eventually should come down and there should not be any new keys after a point.
    Application:
    Transactional Data Store application. Single threaded process, that's trying to read one key's data, delete the data and add new data. The keys are really small (20 bytes) and the data is large (grows from 1KB to 100KB)
    On on machine, I have a total of 3 processes running with each process accessing its own BDB on a separate RAID1+0 drive. So, according to me there should really be no disk i/o wait that's slowing down the reads.
    After a point (past 20GB), There are about 4-5 million keys in my BDB and the data associated with each key could be anywhere between 1KB to 100KB. Eventually every key will have 100KB data associated with it.
    Hardware:
    16 core Intel Xeon, 96GB of RAM, 8 drive, running 2.6.18-194.26.1.0.1.el5 #1 SMP x86_64 x86_64 x86_64 GNU/Linux
    BDB config: BTREE
    bdb version: 4.8.30
    bdb cache size: 4GB
    bdb page size: experimented with 8KB, 64KB.
    3 processes, each process accesses its own BDB on a separate RAIDed(1+0) drive.
    envConfig.setAllowCreate(true);
    envConfig.setTxnNoSync(ourConfig.asynchronous);
    envConfig.setThreaded(true);
    envConfig.setInitializeLocking(true);
    envConfig.setLockDetectMode(LockDetectMode.DEFAULT);
    When writing to BDB: (Asynchrounous transactions)
    TransactionConfig tc = new TransactionConfig();
    tc.setNoSync(true);
    When reading from BDB (Allow reading from Uncommitted pages):
    CursorConfig cc = new CursorConfig();
    cc.setReadUncommitted(true);
    BDB stats: BDB size 49GB
    $ db_stat -m
    3GB 928MB Total cache size
    1 Number of caches
    1 Maximum number of caches
    3GB 928MB Pool individual cache size
    0 Maximum memory-mapped file size
    0 Maximum open file descriptors
    0 Maximum sequential buffer writes
    0 Sleep after writing maximum sequential buffers
    0 Requested pages mapped into the process' address space
    2127M Requested pages found in the cache (97%)
    57M Requested pages not found in the cache (57565917)
    6371509 Pages created in the cache
    57M Pages read into the cache (57565917)
    75M Pages written from the cache to the backing file (75763673)
    60M Clean pages forced from the cache (60775446)
    2661382 Dirty pages forced from the cache
    0 Dirty pages written by trickle-sync thread
    500593 Current total page count
    500593 Current clean page count
    0 Current dirty page count
    524287 Number of hash buckets used for page location
    4096 Assumed page size used
    2248M Total number of times hash chains searched for a page (2248788999)
    9 The longest hash chain searched for a page
    2669M Total number of hash chain entries checked for page (2669310818)
    0 The number of hash bucket locks that required waiting (0%)
    0 The maximum number of times any hash bucket lock was waited for (0%)
    0 The number of region locks that required waiting (0%)
    0 The number of buffers frozen
    0 The number of buffers thawed
    0 The number of frozen buffers freed
    63M The number of page allocations (63937431)
    181M The number of hash buckets examined during allocations (181211477)
    16 The maximum number of hash buckets examined for an allocation
    63M The number of pages examined during allocations (63436828)
    1 The max number of pages examined for an allocation
    0 Threads waited on page I/O
    0 The number of times a sync is interrupted
    Pool File: lastPoints
    8192 Page size
    0 Requested pages mapped into the process' address space
    2127M Requested pages found in the cache (97%)
    57M Requested pages not found in the cache (57565917)
    6371509 Pages created in the cache
    57M Pages read into the cache (57565917)
    75M Pages written from the cache to the backing file (75763673)
    $ db_stat -l
    0x40988 Log magic number
    16 Log version number
    31KB 256B Log record cache size
    0 Log file mode
    10Mb Current log file size
    856M Records entered into the log (856697337)
    941GB 371MB 67KB 112B Log bytes written
    2GB 262MB 998KB 478B Log bytes written since last checkpoint
    31M Total log file I/O writes (31624157)
    31M Total log file I/O writes due to overflow (31527047)
    97136 Total log file flushes
    686 Total log file I/O reads
    96414 Current log file number
    4482953 Current log file offset
    96414 On-disk log file number
    4482862 On-disk log file offset
    1 Maximum commits in a log flush
    1 Minimum commits in a log flush
    160KB Log region size
    195 The number of region locks that required waiting (0%)
    $ db_stat -c
    7 Last allocated locker ID
    0x7fffffff Current maximum unused locker ID
    9 Number of lock modes
    2000 Maximum number of locks possible
    2000 Maximum number of lockers possible
    2000 Maximum number of lock objects possible
    160 Number of lock object partitions
    0 Number of current locks
    1218 Maximum number of locks at any one time
    5 Maximum number of locks in any one bucket
    0 Maximum number of locks stolen by for an empty partition
    0 Maximum number of locks stolen for any one partition
    0 Number of current lockers
    8 Maximum number of lockers at any one time
    0 Number of current lock objects
    1218 Maximum number of lock objects at any one time
    5 Maximum number of lock objects in any one bucket
    0 Maximum number of objects stolen by for an empty partition
    0 Maximum number of objects stolen for any one partition
    400M Total number of locks requested (400062331)
    400M Total number of locks released (400062331)
    0 Total number of locks upgraded
    1 Total number of locks downgraded
    0 Lock requests not available due to conflicts, for which we waited
    0 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
    1MB 544KB The size of the lock region
    0 The number of partition locks that required waiting (0%)
    0 The maximum number of times any partition lock was waited for (0%)
    0 The number of object queue operations that required waiting (0%)
    0 The number of locker allocations that required waiting (0%)
    0 The number of region locks that required waiting (0%)
    5 Maximum hash bucket length
    $ db_stat -CA
    Default locking region information:
    7 Last allocated locker ID
    0x7fffffff Current maximum unused locker ID
    9 Number of lock modes
    2000 Maximum number of locks possible
    2000 Maximum number of lockers possible
    2000 Maximum number of lock objects possible
    160 Number of lock object partitions
    0 Number of current locks
    1218 Maximum number of locks at any one time
    5 Maximum number of locks in any one bucket
    0 Maximum number of locks stolen by for an empty partition
    0 Maximum number of locks stolen for any one partition
    0 Number of current lockers
    8 Maximum number of lockers at any one time
    0 Number of current lock objects
    1218 Maximum number of lock objects at any one time
    5 Maximum number of lock objects in any one bucket
    0 Maximum number of objects stolen by for an empty partition
    0 Maximum number of objects stolen for any one partition
    400M Total number of locks requested (400062331)
    400M Total number of locks released (400062331)
    0 Total number of locks upgraded
    1 Total number of locks downgraded
    0 Lock requests not available due to conflicts, for which we waited
    0 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
    1MB 544KB The size of the lock region
    0 The number of partition locks that required waiting (0%)
    0 The maximum number of times any partition lock was waited for (0%)
    0 The number of object queue operations that required waiting (0%)
    0 The number of locker allocations that required waiting (0%)
    0 The number of region locks that required waiting (0%)
    5 Maximum hash bucket length
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock REGINFO information:
    Lock Region type
    5 Region ID
    __db.005 Region name
    0x2accda678000 Region address
    0x2accda678138 Region primary address
    0 Region maximum allocation
    0 Region allocated
    Region allocations: 6006 allocations, 0 failures, 0 frees, 1 longest
    Allocations by power-of-two sizes:
    1KB 6002
    2KB 0
    4KB 0
    8KB 0
    16KB 1
    32KB 0
    64KB 2
    128KB 0
    256KB 1
    512KB 0
    1024KB 0
    REGION_JOIN_OK Region flags
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock region parameters:
    524317 Lock region region mutex [0/9 0% 5091/47054587432128]
    2053 locker table size
    2053 object table size
    944 obj_off
    226120 locker_off
    0 need_dd
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock conflict matrix:
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Locks grouped by lockers:
    Locker Mode Count Status ----------------- Object ---------------
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Locks grouped by object:
    Locker Mode Count Status ----------------- Object ---------------
    Diagnosis:
    I'm seeing way to much lock contention on the Java Garbage Collector threads and also the VM thread when I strace my java process and I don't understand the behavior.
    We are spending more than 95% of the time trying to acquire locks and I don't know what these locks are. Any info here would help.
    Earlier I thought the overflow pages were the problem as 100KB data size was exceeding all overflow page limits. So, I implemented duplicate keys concept by chunking of my data to fit to overflow page limits.
    Now I don't see any overflow pages in my system but I still see bad bdb read performance.
    $ strace -c -f -p 5642 --->(607 times the lock timed out, errors)
    Process 5642 attached with 45 threads - interrupt to quit
    % time     seconds  usecs/call     calls    errors syscall
    98.19    7.670403        2257      3398       607 futex
     0.84    0.065886           8      8423           pread
     0.69    0.053980        4498        12           fdatasync
     0.22    0.017094           5      3778           pwrite
     0.05    0.004107           5       808           sched_yield
     0.00    0.000120          10        12           read
     0.00    0.000110           9        12           open
     0.00    0.000089           7        12           close
     0.00    0.000025           0      1431           clock_gettime
     0.00    0.000000           0        46           write
     0.00    0.000000           0         1         1 stat
     0.00    0.000000           0        12           lseek
     0.00    0.000000           0        26           mmap
     0.00    0.000000           0        88           mprotect
     0.00    0.000000           0        24           fcntl
    100.00    7.811814                 18083       608 total
    The above stats show that there is too much time spent locking (futex calls) and I don't understand that because
    the application is really single-threaded. I have turned on asynchronous transactions so the writes might be
    flushed asynchronously in the background but spending that much time locking and timing out seems wrong.
    So, there is possibly something I'm not setting or something weird with the way JVM is behaving on my box.
    I grep-ed for futex calls in one of my strace log snippet and I see that there is a VM thread that grabbed the mutex
    maximum number(223) of times and followed by Garbage Collector threads: the following is the lock counts and thread-pids
    within the process:
    These are the 10 GC threads (each thread has grabbed lock on an avg 85 times):
      86 [8538]
      85 [8539]
      91 [8540]
      91 [8541]
      92 [8542]
      87 [8543]
      90 [8544]
      96 [8545]
      87 [8546]
      97 [8547]
      96 [8548]
      91 [8549]
      91 [8550]
      80 [8552]
    VM Periodic Task Thread" prio=10 tid=0x00002aaaf4065000 nid=0x2180 waiting on condition (Main problem??)
     223 [8576] ==> grabbing a lock 223 times -- not sure why this is happening…
    "pool-2-thread-1" prio=10 tid=0x00002aaaf44b7000 nid=0x21c8 runnable [0x0000000042aa8000] -- main worker thread
       34 [8648] (main thread grabs futex only 34 times when compared to all the other threads)
    The load average seems ok; though my system thinks it has very less memory left and that
    I think is because its using up a lot of memory for the file system cache?
    top - 23:52:00 up 6 days, 8:41, 1 user, load average: 3.28, 3.40, 3.44
    Tasks: 229 total, 1 running, 228 sleeping, 0 stopped, 0 zombie
    Cpu(s): 3.2%us, 0.9%sy, 0.0%ni, 87.5%id, 8.3%wa, 0.0%hi, 0.1%si, 0.0%st
    Mem: 98999820k total, 98745988k used, 253832k free, 530372k buffers
    Swap: 18481144k total, 1304k used, 18479840k free, 89854800k cached
    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    8424 rchitta 16 0 7053m 6.2g 4.4g S 18.3 6.5 401:01.88 java
    8422 rchitta 15 0 7011m 6.1g 4.4g S 14.6 6.5 528:06.92 java
    8423 rchitta 15 0 6989m 6.1g 4.4g S 5.7 6.5 615:28.21 java
    $ java -version
    java version "1.6.0_21"
    Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)
    Maybe I should make my application a Concurrent Data Store app as there is really only one thread doing the writes and reads. But I would like
    to understand why my process is spending so much time in locking.
    Can I try any other options? How do I prevent such heavy locking from happening? Has anyone seen this kind of behavior? Maybe this is
    all normal. I'm pretty new to using BDB.
    If there is a way to disable locking that would also work as there is only one thread that's really doing all the job.
    Should I disable the file system cache? One thing is that my application does not utilize cache very well as once I visit a key, I don't visit that
    key again for a very long time so its very possible that the key has to be read again from the disk.
    It is possible that I'm thinking this completely wrong and focussing too much on locking behavior and the problem is else where.
    Any thoughts/suggestions etc are welcome. Your help on this is much appreciated.
    Thanks,
    Rama

    Hi,
    Looks like you're using BDB, not BDB JE, and this is the BDB JE forum. Could you please repost here?:
    Berkeley DB
    Thanks,
    mark

  • Lock never expires

    Hello,
    About once a month it happens that a lock of a "ENV->txn_checkpoint( ENV, 0, 0, 0 )"
    simply blocks and does not expire. In the down below `db_stat -CA` the lock is kept
    more than 5 hours ("*expires 02-01-00:03:07.151182000*"), until I could do a
    `db_recover` and bring BDB back to life.
    The environment is set to:
    ENV->set_lk_detect( ENV, DB_LOCK_OLDEST );
    ENV->set_timeout( ENV, 60 * 1000 * 1000, DB_SET_LOCK_TIMEOUT );
    ENV->set_timeout( ENV, 60 * 1000 * 1000, DB_SET_TXN_TIMEOUT );
    Once a minute i do:
    ENV->lock_detect( ENV, 0, DB_LOCK_OLDEST, &rejected );
    ENV->lock_detect( ENV, 0, DB_LOCK_EXPIRE, &rejected );
    From "00:03:00" to "05:22:00" I have seen many rejected locks but the perpetual
    lock "80b7b6fb" (PID:32179) from the txn_checkpoint() was never brocken.
    Thanks
    Josef
    I had to remove quite a lot from `db_stat -CA` not to exceed 30000 chars:
    Default locking region information:
    435392  Last allocated locker ID
    0x7fffffff  Current maximum unused locker ID
    9   Number of lock modes
    32768   Maximum number of locks possible
    32768   Maximum number of lockers possible
    32768   Maximum number of lock objects possible
    80  Number of lock object partitions
    6401    Number of current locks
    7214    Maximum number of locks at any one time
    283 Maximum number of locks in any one bucket
    0   Maximum number of locks stolen by for an empty partition
    0   Maximum number of locks stolen for any one partition
    6397    Number of current lockers
    6397    Maximum number of lockers at any one time
    159 Number of current lock objects
    1413    Maximum number of lock objects at any one time
    3   Maximum number of lock objects in any one bucket
    0   Maximum number of objects stolen by for an empty partition
    0   Maximum number of objects stolen for any one partition
    3231M   Total number of locks requested (3231111865)
    3231M   Total number of locks released (3231086892)
    1928    Total number of locks upgraded
    423527  Total number of locks downgraded
    70117   Lock requests not available due to conflicts, for which we waited
    18553   Lock requests not available due to conflicts, for which we did not wait
    1   Number of deadlocks
    60M Lock timeout value (60000000)
    34509   Number of locks that have timed out
    60M Transaction timeout value (60000000)
    4514    Number of transactions that have timed out
    17MB 360KB  The size of the lock region
    24M The number of partition locks that required waiting (0%)
    8468160 The maximum number of times any partition lock was waited for (0%)
    3545    The number of object queue operations that required waiting (0%)
    57474   The number of locker allocations that required waiting (0%)
    64  The number of region locks that required waiting (0%)
    3   Maximum hash bucket length
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock REGINFO information:
    Lock    Region type
    5   Region ID
    __db.005    Region name
    0x925f1000  Region address
    0x925f10c4  Region primary address
    0   Region maximum allocation
    0   Region allocated
    Region allocations: 169 allocations, 0 failures, 0 frees, 1 longest
    Allocations by power-of-two sizes:
      1KB   2
      2KB   0
      4KB   0
      8KB   1
    16KB   0
    32KB   160
    64KB   0
    128KB   0
    256KB   0
    512KB   2
    1024KB  0
    REGION_JOIN_OK  Region flags
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock region parameters:
    65561   Lock region region mutex [64/12M 0% 16646/3074799296] <wakeups 10/11>
    32771   locker table size
    32771   object table size
    724 obj_off
    3020556 locker_off
    0   need_dd
    next_timeout: 02-01-05:22:01.599805000
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock conflict matrix:
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Locks grouped by lockers:
    Locker   Mode      Count Status  ----------------- Object ---------------
    [...] sniped rows starting with a ' ' [...]
    80b88442 dd= 6 locks held 1    write locks 0    pid/thread 16452/3064153872 priority 100       expires 02-01-05:22:22.246053000 lk expires 02-01-05:22:22.246053000
    80b88442 READ          1 WAIT    mediastatistic.db         page          0
    80b88442 READ          1 HELD    mediastatistic.db         handle        0
    80b88445 dd= 1 locks held 1    write locks 0    pid/thread 16634/3063199504 priority 100       expires 02-01-05:23:01.279172000 lk expires 02-01-05:23:01.279172000
    80b88445 READ          1 WAIT    mediastatistic.db         page          0
    80b88445 READ          1 HELD    mediastatistic.db         handle        0
    80b7b6fb dd=4548 locks held 3    write locks 3    pid/thread 32179/3064153872 priority 100       expires 02-01-00:03:07.151182000
    80b7b6fb WRITE         1 HELD    queue_status.db           page          1
    80b7b6fb WAS_WRITE     1 HELD    queue_user.db             page         15
    80b7b6fb WAS_WRITE     2 HELD    queue.db                  page       3417
    80b883ee dd=57 locks held 5    write locks 5    pid/thread 21788/3063506704 priority 100       expires 02-01-05:22:02.091000000 lk expires 02-01-05:22:02.091000000
    80b883ee READ          1 WAIT    queue_status.db           page          1
    80b883ee WAS_WRITE     1 HELD    queue_process.db          page          1
    80b883ee WAS_WRITE     1 HELD    queue_user.db             page          2
    80b883ee WAS_WRITE     1 HELD    queue_media.db            page          1
    80b883ee WAS_WRITE     1 HELD    queue_usercreated.db      page          2
    80b883ee WAS_WRITE     2 HELD    queue.db                  page        620
    80b883ef dd=56 locks held 0    write locks 0    pid/thread 31279/3063117584 priority 100       expires 02-01-05:22:02.094269000 lk expires 02-01-05:22:02.094269000
    80b883ef WRITE         1 WAIT    queue.db                  page       3417
    80b883f4 dd=53 locks held 4    write locks 4    pid/thread 3880/3062753040 priority 100       expires 02-01-05:22:02.112277000 lk expires 02-01-05:22:02.112277000
    80b883f4 WRITE         1 WAIT    queue_process.db          page          1
    80b883f4 WAS_WRITE     1 HELD    queue_user.db             page          5
    80b883f4 WAS_WRITE     1 HELD    queue_usercreated.db      page         10
    80b883f4 WAS_WRITE     1 HELD    queue_useractive.db       page          1
    80b883f4 WAS_WRITE     2 HELD    queue.db                  page       1589
    80b883f6 dd=52 locks held 1    write locks 1    pid/thread 6752/3063416592 priority 100       expires 02-01-05:22:02.120049000 lk expires 02-01-05:22:02.120049000
    80b883f6 WRITE         1 WAIT    queue_usercreated.db      page         10
    80b883f6 WAS_WRITE     2 HELD    queue.db                  page        359
    80b88401 dd=50 locks held 2    write locks 2    pid/thread 15858/3063584528 priority 100       expires 02-01-05:22:02.176324000 lk expires 02-01-05:22:02.176324000
    80b88401 WRITE         1 WAIT    mediastatistic.db         page          0
    80b88401 WRITE         1 HELD    mediastatistic.db         page     127272
    80b88401 WAS_WRITE     1 HELD    mediastatistic.db         page     127272
    80b88407 dd=48 locks held 0    write locks 0    pid/thread 15053/3063318288 priority 100       expires 02-01-05:22:02.209851000 lk expires 02-01-05:22:02.209851000
    80b88407 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88408 dd=47 locks held 0    write locks 0    pid/thread 23242/3064022800 priority 100       expires 02-01-05:22:02.213305000 lk expires 02-01-05:22:02.213305000
    80b88408 WRITE         1 WAIT    queue.db                  page        620
    80b88409 dd=46 locks held 0    write locks 0    pid/thread 14254/3064424208 priority 100       expires 02-01-05:22:02.218573000 lk expires 02-01-05:22:02.218573000
    80b88409 WRITE         1 WAIT    queue.db                  page        359
    80b8840b dd=45 locks held 0    write locks 0    pid/thread 3639/3063240464 priority 100       expires 02-01-05:22:02.225444000 lk expires 02-01-05:22:02.225444000
    80b8840b READ          1 WAIT    queue_useractive.db       page          1
    80b8840c dd=44 locks held 0    write locks 0    pid/thread 15783/3063670544 priority 100       expires 02-01-05:22:02.225574000 lk expires 02-01-05:22:02.225574000
    80b8840c WRITE         1 WAIT    mediastatistic.db         page     127272
    80b8840e dd=43 locks held 1    write locks 1    pid/thread 23404/3062658832 priority 100       expires 02-01-05:22:02.232718000 lk expires 02-01-05:22:02.232718000
    80b8840e WRITE         1 WAIT    queue_usercreated.db      page         10
    80b8840e WAS_WRITE     2 HELD    queue.db                  page       2439
    80b88414 dd=40 locks held 0    write locks 0    pid/thread 15532/3062458128 priority 100       expires 02-01-05:22:02.339357000 lk expires 02-01-05:22:02.339357000
    80b88414 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88415 dd=39 locks held 0    write locks 0    pid/thread 12934/3063731984 priority 100       expires 02-01-05:22:02.346746000 lk expires 02-01-05:22:02.346746000
    80b88415 WRITE         1 WAIT    queue.db                  page        359
    80b88416 dd=38 locks held 2    write locks 2    pid/thread 15896/3063670544 priority 100       expires 02-01-05:22:02.411124000 lk expires 02-01-05:22:02.411124000
    80b88416 WRITE         1 WAIT    mediastatistic.db         page          0
    80b88416 WRITE         1 HELD    mediastatistic.db         page     126767
    80b88416 WAS_WRITE     1 HELD    mediastatistic.db         page     126767
    80b88417 dd=37 locks held 0    write locks 0    pid/thread 14569/3063420688 priority 100       expires 02-01-05:22:02.426556000 lk expires 02-01-05:22:02.426556000
    80b88417 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88419 dd=36 locks held 1    write locks 1    pid/thread 1345/3063146256 priority 100       expires 02-01-05:22:02.538765000 lk expires 02-01-05:22:02.538765000
    80b88419 READ          1 WAIT    queue_useractive.db       page          1
    80b88419 WAS_WRITE     2 HELD    queue.db                  page       1585
    80b8841e dd=35 locks held 0    write locks 0    pid/thread 29349/3063453456 priority 100       expires 02-01-05:22:02.618734000 lk expires 02-01-05:22:02.618734000
    80b8841e WRITE         1 WAIT    queue.db                  page       3417
    80b8841f dd=34 locks held 0    write locks 0    pid/thread 6200/3063899920 priority 100       expires 02-01-05:22:02.622259000 lk expires 02-01-05:22:02.622259000
    80b8841f WRITE         1 WAIT    queue.db                  page        359
    80b88420 dd=33 locks held 0    write locks 0    pid/thread 10999/3062880016 priority 100       expires 02-01-05:22:02.622284000 lk expires 02-01-05:22:02.622284000
    80b88420 WRITE         1 WAIT    queue.db                  page        359
    80b88421 dd=32 locks held 1    write locks 1    pid/thread 15349/3062720272 priority 100       expires 02-01-05:22:02.629291000 lk expires 02-01-05:22:02.629291000
    80b88421 WRITE         1 WAIT    queue_usercreated.db      page          6
    80b88421 WAS_WRITE     2 HELD    queue.db                  page        309
    80b88422 dd=31 locks held 0    write locks 0    pid/thread 15969/3062982416 priority 100       expires 02-01-05:22:02.632325000 lk expires 02-01-05:22:02.632325000
    80b88422 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88423 dd=30 locks held 2    write locks 2    pid/thread 21631/3061966608 priority 100       expires 02-01-05:22:02.634340000 lk expires 02-01-05:22:02.634340000
    80b88423 WRITE         1 WAIT    queue_media.db            page          1
    80b88423 WAS_WRITE     1 HELD    queue_usercreated.db      page          6
    80b88423 WAS_WRITE     2 HELD    queue.db                  page       3058
    80b88424 dd=29 locks held 0    write locks 0    pid/thread 1500/3062712080 priority 100       expires 02-01-05:22:02.648949000 lk expires 02-01-05:22:02.648949000
    80b88424 WRITE         1 WAIT    queue.db                  page       1585
    80b88425 dd=28 locks held 0    write locks 0    pid/thread 15274/3063731984 priority 100       expires 02-01-05:22:02.681320000 lk expires 02-01-05:22:02.681320000
    80b88425 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88427 dd=27 locks held 0    write locks 0    pid/thread 5970/3063367440 priority 100       expires 02-01-05:22:02.722208000 lk expires 02-01-05:22:02.722208000
    80b88427 WRITE         1 WAIT    queue.db                  page        359
    80b88428 dd=26 locks held 0    write locks 0    pid/thread 21321/3063117584 priority 100       expires 02-01-05:22:02.736108000 lk expires 02-01-05:22:02.736108000
    80b88428 WRITE         1 WAIT    queue.db                  page        620
    80b8842a dd=25 locks held 0    write locks 0    pid/thread 14491/3063039760 priority 100       expires 02-01-05:22:02.874833000 lk expires 02-01-05:22:02.874833000
    80b8842a WRITE         1 WAIT    mediastatistic.db         page     127272
    80b8842b dd=24 locks held 20   write locks 19   pid/thread 2067/3064137488 priority 100       expires 02-01-05:22:02.881527000 lk expires 02-01-05:22:02.881527000
    80b8842b WRITE         1 WAIT    queue.db                  page        359
    80b8842b WAS_WRITE     1 HELD    mediareferer.db           page      11187
    80b8842b WAS_WRITE     2 HELD    mediadocument.db          page      91943
    80b8842b WAS_WRITE     2 HELD    mediafile.db              page     182304
    80b8842b WAS_WRITE     2 HELD    mediafile_livestream.db   page          1
    80b8842b WAS_WRITE     1 HELD    mediastatistic.db         page          0
    80b8842b WAS_WRITE     2 HELD    mediastatistic.db         page     127441
    80b8842b WAS_WRITE     1 HELD    media.db                  page      59394
    80b8842b WAS_WRITE     1 HELD    media.db                  page          1
    80b8842b WAS_WRITE     1 HELD    media_personalpublished.db page          1
    80b8842b WAS_WRITE     2 HELD    media_personalpublished.db page          6
    80b8842b WAS_WRITE     1 HELD    media_personallanguagetypepublished.db page          1
    80b8842b WAS_WRITE     2 HELD    media_personallanguagetypepublished.db page          8
    80b8842b WAS_WRITE     1 HELD    media_personaltypepublished.db page          1
    80b8842b WAS_WRITE     2 HELD    media_personaltypepublished.db page          6
    80b8842b WAS_WRITE     1 HELD    media_personallanguagepublished.db page          1
    80b8842b WAS_WRITE     2 HELD    media_personallanguagepublished.db page          6
    80b8842b WAS_WRITE     1 HELD    media_language.db         page          7
    80b8842b WAS_WRITE     1 HELD    media_user.db             page        175
    80b8842b READ          1 HELD    media.db                  page      60382
    80b8842b WAS_WRITE     3 HELD    media.db                  page      60382
    80b8842c dd=23 locks held 2    write locks 2    pid/thread 16079/3062560528 priority 100       expires 02-01-05:22:02.914927000 lk expires 02-01-05:22:02.914927000
    80b8842c WRITE         1 WAIT    mediastatistic.db         page          0
    80b8842c WRITE         1 HELD    mediastatistic.db         page     127104
    80b8842c WAS_WRITE     1 HELD    mediastatistic.db         page     127104
    80b8842d dd=22 locks held 0    write locks 0    pid/thread 15946/3063805712 priority 100       expires 02-01-05:22:02.917872000 lk expires 02-01-05:22:02.917872000
    80b8842d WRITE         1 WAIT    mediastatistic.db         page     127104
    80b8842e dd=21 locks held 0    write locks 0    pid/thread 16391/3062630160 priority 100       expires 02-01-05:22:02.933898000 lk expires 02-01-05:22:02.933898000
    80b8842e WRITE         1 WAIT    mediastatistic.db         page     127104
    80b8842f dd=20 locks held 0    write locks 0    pid/thread 14468/3064334096 priority 100       expires 02-01-05:22:02.980551000 lk expires 02-01-05:22:02.980551000
    80b8842f WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88430 dd=19 locks held 2    write locks 2    pid/thread 15108/3063666448 priority 100       expires 02-01-05:22:03.005311000 lk expires 02-01-05:22:03.005311000
    80b88430 WRITE         1 WAIT    mediastatistic.db         page          0
    80b88430 WRITE         1 HELD    mediastatistic.db         page     126936
    80b88430 WAS_WRITE     1 HELD    mediastatistic.db         page     126936
    80b88431 dd=18 locks held 0    write locks 0    pid/thread 15605/3064194832 priority 100       expires 02-01-05:22:03.005324000 lk expires 02-01-05:22:03.005324000
    80b88431 WRITE         1 WAIT    mediastatistic.db         page     126936
    80b88432 dd=17 locks held 2    write locks 2    pid/thread 15550/3064497936 priority 100       expires 02-01-05:22:03.088119000 lk expires 02-01-05:22:03.088119000
    80b88432 WRITE         1 WAIT    mediastatistic.db         page          0
    80b88432 WRITE         1 HELD    mediastatistic.db         page     126091
    80b88432 WAS_WRITE     1 HELD    mediastatistic.db         page     126091
    80b88433 dd=16 locks held 0    write locks 0    pid/thread 14983/3062826768 priority 100       expires 02-01-05:22:03.110238000 lk expires 02-01-05:22:03.110238000
    80b88433 WRITE         1 WAIT    mediastatistic.db         page     127104
    80b88434 dd=15 locks held 0    write locks 0    pid/thread 14858/3064395536 priority 100       expires 02-01-05:22:03.128270000 lk expires 02-01-05:22:03.128270000
    80b88434 WRITE         1 WAIT    mediastatistic.db         page     127104
    80b88435 dd=14 locks held 0    write locks 0    pid/thread 16143/3063744272 priority 100       expires 02-01-05:22:03.138039000 lk expires 02-01-05:22:03.138039000
    80b88435 WRITE         1 WAIT    mediastatistic.db         page     126767
    80b88436 dd=13 locks held 0    write locks 0    pid/thread 15823/3062839056 priority 100       expires 02-01-05:22:03.151565000 lk expires 02-01-05:22:03.151565000
    80b88436 WRITE         1 WAIT    mediastatistic.db         page     127272
    80b88437 dd=12 locks held 0    write locks 0    pid/thread 15694/3063637776 priority 100       expires 02-01-05:22:03.203599000 lk expires 02-01-05:22:03.203599000
    80b88437 WRITE         1 WAIT    mediastatistic.db         page     127104
    80b88439 dd=11 locks held 2    write locks 2    pid/thread 2077/3062581008 priority 100       expires 02-01-05:22:04.313716000 lk expires 02-01-05:22:04.313716000
    80b88439 WRITE         1 WAIT    mediastatistic.db         page          0
    80b88439 WRITE         1 HELD    mediastatistic.db         page     104797
    80b88439 WAS_WRITE     1 HELD    mediastatistic.db         page     104797
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Locks grouped by object:
    Locker   Mode      Count Status  ----------------- Object ---------------
    [...] snip [...]

    Hello,
    This bug did not raise in BDB 5.1.25 yet.
    BDB 5.1.25 is the first release, that runs stable for two month
    without the need of a `db_recover`. Maybe #18789 ?
    Thanks
    Josef

  • Cursors throwing Unexpected lock status: 6

    I am using a Berkeley DB instance and have a multithreaded clients each performing various types of operations on the database. In general there are three types of operations being performed, reads, writes (which use RMW locks), and (non-transactional) cursors. After some time my application dumps the following:
    Unexpected lock status: 6
    PANIC: Invalid argument
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__os_stack+0x2b) [0xb7ef085f]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__os_abort+0x1d) [0xb7eecbb1]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__env_panic+0xa8) [0xb7e80b8e]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__lock_get_internal+0x1855) [0xb7e2e925]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__lock_vec+0x167) [0xb7e2bd3c]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__db_lget+0x45c) [0xb7e8bfe2]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so [0xb7d850a5]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so [0xb7d816ce]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__dbc_get+0x598) [0xb7e76a29]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__dbc_get_pp+0x11f) [0xb7e870ec]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(_ZN3Dbc3getEP3DbtS1_j+0x3f) [0xb7d71feb]
    ...(non-berkeley db layers)...
    /lib/tls/i686/cmov/libpthread.so.0 [0xb7a2350f]
    /lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0xb7b20a0e]
    Aborted
    In studying the core dumps and doing some testing this behavior only occurs when cursors are used, when those operations are removed the error no longer manifests itself so either the cursor is the issue, or how the cursors are interacting with other operations. Below is a sample of cursor code being run:
    void run_cursor()
    Dbc *curp = NULL;
    int ret;
    try
    int i = 0;
    Dbt key(&i,sizeof(int));
    Dbt data(buffer, 0);
    data.set_flags(DB_DBT_USERMEM);
    data.set_ulen(MAX_BUFFER_SIZE);
    db->cursor(NULL, &curp, 0);
    while ((ret = curp->get(&key, &data, DB_NEXT)) == 0) {
    //keep a list of all the keys in the db
    keys.push_back(i);
    if (ret != DB_NOTFOUND) {
    cerr << "Cursor Error" << endl;
    curp->close();
    catch (DbException &ex) {
    cout << ex.what() << endl;
    if( curp != NULL )
    curp->close();
    I have tried wrapping the cursor in a transaction and it seems to worsen the issue (it happens more frequently). In all methods I am printing error messages when exceptions are thrown by the database (e.g. DbExceptions) and the program prints no errors so I do not believe it is a side effect of some other error. Here is the relevant parts of the case where is RMW lock is used:
    void update()
    DbTxn *txn = NULL;
    try
    env->txn_begin(NULL, &txn, 0);
    int id;
    Dbt key( &id, sizeof(int) );
    Dbt value(buffer, 0);
    value.set_flags(DB_DBT_USERMEM);
    value.set_ulen(MAX_BUFFER_SIZE);
    int err = db->get(txn, &key, &value, DB_RMW);
    if( err == DB_NOTFOUND )
    cerr << "Error trying to read key" << endl;
    txn->abort(0);
    return;
    //code to modify the value here
    db->put(txn, &key, &value, 0);
    txn->commit(0);
    } catch (DbDeadlockException &de) {
    cout << de.what() << endl;
    if( txn != NULL )
    txn->abort();
    Just in case it helps, here is the output of db_stat -CA on the database after it has crashed:
    Default locking region information:
    12     Last allocated locker ID
    0x7fffffff     Current maximum unused locker ID
    9     Number of lock modes
    5000     Maximum number of locks possible
    5000     Maximum number of lockers possible
    1000     Maximum number of lock objects possible
    1     Number of lock object partitions
    6     Number of current locks
    9     Maximum number of locks at any one time
    4     Maximum number of locks in any one bucket
    0     Maximum number of locks stolen by for an empty partition
    0     Maximum number of locks stolen for any one partition
    11     Number of current lockers
    13     Maximum number of lockers at any one time
    3     Number of current lock objects
    9     Maximum number of lock objects at any one time
    2     Maximum number of lock objects in any one bucket
    0     Maximum number of objects stolen by for an empty partition
    0     Maximum number of objects stolen for any one partition
    3786734     Total number of locks requested
    3786664     Total number of locks released
    0     Total number of locks upgraded
    1     Total number of locks downgraded
    7089     Lock requests not available due to conflicts, for which we waited
    61     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
    1000000     Transaction timeout value
    0     Number of transactions that have timed out
    1MB 592KB     The size of the lock region
    0     The number of partition locks that required waiting (0%)
    0     The maximum number of times any partition lock was waited for (0%)
    0     The number of object queue operations that required waiting (0%)
    0     The number of locker allocations that required waiting (0%)
    165     The number of region locks that required waiting (0%)
    2     Maximum hash bucket length
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock REGINFO information:
    Lock     Region type
    5     Region ID
    __db.005     Region name
    0xb781b000     Original region address
    0xb781b000     Region address
    0xb781b0c0     Region primary address
    0     Region maximum allocation
    0     Region allocated
    Region allocations: 11006 allocations, 0 failures, 0 frees, 1 longest
    Allocations by power-of-two sizes:
    1KB     11003
    2KB     0
    4KB     0
    8KB     0
    16KB     1
    32KB     0
    64KB     1
    128KB     1
    256KB     0
    512KB     0
    1024KB     0
    REGION_JOIN_OK     Region flags
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock region parameters:
    104     Lock region region mutex [165/7025066 0% 5979/3075574672]
    8191     locker table size
    1031     object table size
    600     obj_off
    62608     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 ---------------
    4 dd= 9 locks held 1 write locks 0 pid/thread 5979/3080828608
    4 READ 1 HELD ./db.db handle 0
    5 dd= 8 locks held 0 write locks 0 pid/thread 5979/3072416656
    6 dd= 7 locks held 0 write locks 0 pid/thread 5979/3073469328
    7 dd= 6 locks held 0 write locks 0 pid/thread 5979/3073469328
    8 dd= 5 locks held 0 write locks 0 pid/thread 5979/3073469328
    9 dd= 4 locks held 0 write locks 0 pid/thread 5979/3072416656
    a dd= 3 locks held 1 write locks 0 pid/thread 5979/3073469328
    a READ 1 WAIT ./db.db page 21
    a READ 2 HELD ./db.db page 20
    b dd= 2 locks held 1 write locks 0 pid/thread 5979/3075574672
    b READ 1 WAIT ./db.db page 21
    b READ 2 HELD ./db.db page 20
    c dd= 1 locks held 0 write locks 0 pid/thread 5979/3075574672
    800054d9 dd= 0 locks held 1 write locks 1 pid/thread 5979/3074522000expires 05-05-12:41:36.048050000
    800054d9 WRITE 2 HELD ./db.db page 21
    800054da dd= 0 locks held 0 write locks 0 pid/thread 5979/3072416656
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Locks grouped by object:
    Locker Mode Count Status ----------------- Object ---------------
    800054d9 WRITE 2 HELD ./db.db page 21
    a READ 1 WAIT ./db.db page 21
    b READ 1 WAIT ./db.db page 21
    a READ 2 HELD ./db.db page 20
    b READ 2 HELD ./db.db page 20
    4 READ 1 HELD ./db.db handle 0
    The number of locks and lockers is somewhat low at 5,000 each, this was intentional since the same error occurs with larger numbers of locks/lockers it simply takes longer to occur. I have reviewed this output and nothing out of the ordinary seems to be occurring as far as I can tell.
    Any additional insight would be appreciated.

    Thanks to both of you for your suggestions.
    I have still noticing the same issue with very similar output etc so I wont repost that. After running it some more I have started seeing another error message, it looks like its very similar and hopefully with make the issue more clear.
    Here is the output of the error file:
    TAS unlock failed: lock already unlocked
    PANIC: Permission denied
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__os_stack+0x2b) [0xb7ee585f]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__os_abort+0x1d) [0xb7ee1bb1]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__env_panic+0xa8) [0xb7e75b8e]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__db_tas_mutex_unlock+0xa5) [0xb7d72245]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so [0xb7e27d04]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__lock_detect+0x129) [0xb7e268bf]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__lock_get_internal+0x1434) [0xb7e23504]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__lock_vec+0x167) [0xb7e20d3c]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__db_lget+0x45c) [0xb7e80fe2]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so [0xb7d7a0a5]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so [0xb7d766ce]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__dbc_get+0x598) [0xb7e6ba29]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(__dbc_get_pp+0x11f) [0xb7e7c0ec]
    /usr/local/BerkeleyDB.4.7/lib/libdb_cxx-4.7.so(_ZN3Dbc3getEP3DbtS1_j+0x3f) [0xb7d66feb]
    ...(user code stack layers)...
    /lib/tls/i686/cmov/libpthread.so.0 [0xb79a950f]
    /lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0xb7a9ea0e]
    Here is the output of the waits for table:
    Waiter:     Waiting on:
    80002249/50:     957608
    6/50:     80002249 957208
    Waitsfor array
    Waiter:     Waiting on:
    8000224a/28:     957288
    a/28:     8000224a 957608
    Waitsfor array
    Waiter:     Waiting on:
    8000224c/22:     957608
    6/22:     8000224c 957368
    Waitsfor array
    Waiter:     Waiting on:
    8000224c/22:     957608
    6/22:     8000224c 957368
    4/22:     8000224c 957048
    Waitsfor array
    Waiter:     Waiting on:
    8000224d/25:     957528
    7/25:     8000224d 957608
    Waitsfor array
    Waiter:     Waiting on:
    8000224d/25:     957528
    7/25:     8000224d 957608
    6/25:     8000224d 957208
    Waitsfor array
    Waiter:     Waiting on:
    8000224d/25:     957528
    7/25:     8000224d 957608
    6/25:     8000224d 957208
    4/25:     8000224d 957288
    Waitsfor array
    Waiter:     Waiting on:
    80002251/10:     957048
    a/10:     80002251 957128
    Waitsfor array
    Waiter:     Waiting on:
    80002257/39:     80002254 957368
    80002254/39:     957288
    Waitsfor array
    Waiter:     Waiting on:
    80002258/14:     957048
    4/14:     80002258 957608
    Waitsfor array
    Waiter:     Waiting on:
    80002258/14:     957048
    8/14:     80002258 957208
    4/14:     80002258 957608
    Waitsfor array
    Waiter:     Waiting on:
    80002259/39:     80002257 957448
    80002258/14:     957048
    80002257/39:     957368
    8/14:     80002258 957208
    4/14:     80002258 957608
    Waitsfor array
    Waiter:     Waiting on:
    80002259/39:     957448
    8/39:     80002259 957288
    7/39:     80002259 957048
    6/39:     80002259 957528
    Waitsfor array
    Waiter:     Waiting on:
    80002259/0:     0
    80002257/0:     0
    Waitsfor array
    Waiter:     Waiting on:
    8000225a/40:     956968
    7/40:     8000225a 956888
    Waitsfor array
    Waiter:     Waiting on:
    8000225a/40:     956968
    7/40:     8000225a 956888
    4/40:     8000225a 957608
    It looks like there is a similar pattern here at the end with the two entries waiting on zero ("80002259/0:     0 80002257/0:     0"), which is why I suspect its the same error just manifesting itself in a slightly different manner.
    I am using lock detection, I currently have it set to use DB_LOCK_MAXLOCKS, I have tried others as well with not change in behavior.
    Most of my transaction code takes the following form, so if the get is successful (the id exists) then the data is updated and written back to the database. If an exception is thrown then it is caught and the transaction is aborted. As far as I can tell this should not leave and transaction handles left open or anything along those lines as the error message suggests.
    void do_txn()
    DbTxn *txn = NULL;
    try
    db->txn_begin(NULL, &txn, 0);
    Data d;
    //does a db->get using the txn pointer and a DB_RMW lock
    //returns do_get returns false if the id does not exist
    bool success = do_get(id, &d, txn);
    if( !success )
    txn->abort();
    return;
    //update data as necessary
    //does a db->put using the txn pointer
    do_put(id, &d, txn);
    txn->commit(0);
    } catch (DbDeadlockException &de) {
    cout << de.what() << endl;
    if( txn != NULL )
    txn->abort();
    }

  • BI Planning / lock is not working

    Hello all,
    I have created a Real-time-Cube and a aggregation layer and also a user entry query in order to enter data in the real-time cube. About 30 user from different sales offices should be able to enter the data.
    It is not possible, that more then one user can access the planning scenario although the lock setting in TA RSPLSE is done. As soon as another user access the tool, even from a different sales office, the warning message "tool is locked" appears and no entry is possible.
    In the tab "lock table" I have selected shared object memory of server.
    In the tab "lock characteristics" I have selected the real-time-cube and put the characteristic 0SALES_OFF underneath lock characteristics.
    Is this setting correct?
    The BI version is 7.0 Any help would be great.
    Best regards,
    Stefan from Munich/Germany.

    Hi,
    make sure that you use the characteristic 0SALES_OFF as lock relevant, i.e. put this characteristic in the right table on tab 'Lock characteristics'. Please also check the last lock conflict in RSPLSE. Make sure that different users have disjoined selections for 0SALES_OFF in the filter of the query (not only in the default values of the filter).
    Regards,
    Gregor

  • Why not a read lock?

    Hi,
    I use dbsql operate the database, when i begin a transaction, followed by executing a query, by observing its lock and found it produced a write lock, instead of reading a lock?
    Why is it? Do the following:
    [root@iZ28aslsffdZ db_sql]# dbsql test.db
    Berkeley DB 12c Release 1, library version 12.1.6.1.19: (June 10, 2014)
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    dbsql> create table t (a int);
    dbsql> insert into t values (1),(2),(3);
    dbsql> begin;
    dbsql> select * from t where a = 1;
    1
    [root@iZ28aslsffdZ test.db-journal]# db_stat -CA
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Lock conflict matrix:
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    80000014 dd= 0 locks held 1
    write locks 1
    pid/thread 30420/140133200996096 flags 0
    priority 100  
    80000014 WRITE    
    3 HELD      
    test.db:table00003 database  
    0

    That is expected behavior.  It is due to an internal optimization for single threaded access to the database.  The first time two threads clash trying to get access to the database schema table (which is what table00003 is), the database will stop getting a write lock on the table and will instead just get a read lock.
    Lauren Foutz

  • Lock for data in data partition/data slice

    Hi
    we are on SAP BI IP and we have the following scenario.
    We defined a planning web tempate "WT AA0"  based using char Version with value "AA0".
    User A plans data and then "locks" them using a data slice/partition.
    User B  works a planning web template "WT AA1" where char Version has value "AA1" ; as soon as user B runs a planning function (based on custom class using IF_RSPLFA_SRVTYPE_IMP_EXEC) and user A opens web template "WT AA0" , user B is locked.
    Now I have two questions:
    1. is correct that data "locked" from partitions/data slice are used in lock?
    2. if use in the class the if IF_RSPLFA_SRVTYPE_IMP_EXEC_REF, and change the filter on char Version (using only AA1), can I avoid this lock??
    many thanks in advance.
    S.

    Hi Stefania,
    just for clarification: data slices have nothing to do with transaction data locks.
    Data slices protect records from being changed at run time. Data slices can be changed at run time, e.g. in an exit implementation. This is why data slices have no effect on transaction data locks.
    Transaction data locks ensure that the set of data records described by filter of a query or planning function can only be changed by one user (concurreny locks) in one user session. The filter used at run time to set the transaction data locks will be determined at run time:
    - query: the filter of the query and restricted key figures with the 'lock relevant setting' (cf. Query Designer) will be used to compute the filter to be used to set the lock
    - planning function: the filter used in the configuration will be used to set the lock; reference data will not be used to set exclusive locks
    In your example the queries use different versions in the filter, so two users using these 'their' version will not lead to a lock conflict. If a planning function needs version AA0 as reference to change data for version AA1 you have to use AA0 as reference data and only AA1 in the filter of the planning function.
    Regards,
    Gregor

  • How to implement locking in ABAP

    Hello everyone,
        I am doing dialog programming and I have a screen that creates some template. When the user opens up the screen it defualts to next available template number to be created (for example if template No 1 exists then it will default to template no 2 so template 2 will be created). But if multiple users open up the screen then it will show template 2 for both of them and I want to avoid this, i.e. I like to implement some locking mechanism so one user opens up the screen that template is locked and the other cannot create the same template. Please share any ideas and suggestions, how I can imeplement this!
    Thanks.
    Mithun

    Hai  Mithun Dha
    Lock Objects
    The R/3 System synchronizes simultaneous access of several users to the same data records with a lock mechanism. When interactive transactions are programmed, locks are set and released by calling function modules (see Function Modules for Lock Requests). These function modules are automatically generated from the definition of lock objects in the ABAP Dictionary.
    Structure of a Lock Object
    The tables in which data records should be locked with a lock request are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also be added using foreign key relationships (see also Conditions for Foreign Keys).
    Lock Arguments
    The lock argument of a table in the lock object consists of the key fields of the table.
    The lock argument fields of a lock object are used as input parameters in the function modules for setting and removing locks generated from the lock object definition. When these function modules are called, the table rows to be locked or unlocked are specified by defining certain values in these fields. These values can also be generic. The lock argument fields therefore define which subset of the table rows should be locked.
    The simplest case of a lock object consists of exactly one table and the lock argument of the table is the primary key of this table. Several tables can also be included in a lock object. A lock request therefore can lock an entire logical object, and not only a record of a table. Such a logical object can be for example a document comprising an entry in a header table and N entries in a position table.
    Locks can also be set from programs in other systems with the corresponding interfaces if the lock object was defined with RFC authorization.
    A lock mode can be assigned for each table in the lock object. This mode defines how other users can access a locked record of the table.
    Table SFLIGHT in the  flight model contains all the scheduled flights of a carrier. Field SEATSMAX contains the number of seats available. Field SEATSOCC contains the number of seats already booked. If a booking is made for a customer (by a travel agency or sales desk), you must check whether there are enough seats available. The number of seats booked is incremented when the booking is made.
    This mechanism must ensure that two sales desks do not make the same booking at the same time and that the flight is not overbooked.
    This can be done by creating lock object ESFLIGHT. Only the table SFLIGHT must be included in this lock object. The flight can then be locked (with the function modules generated from the lock object) when booking. If another sales desk also wants to book seats for this flight, the lock will prevent the flight from being overbooked.
    Activating a lock object in the ABAP Dictionary automatically creates function modules for setting (ENQUEUE_<lock object name>) and releasing (DEQUEUE_<lock object name>) locks.
    The generated function modules are automatically assigned to function groups. You should not change these function modules and their assignment to function groups since the function modules are generated again each time the lock object is activated.
    Never transport the function groups, which contain the automatically generated function modules. The generated function modules of a lock object could reside in a different function group in the target system. Always transport the lock objects. When a lock object is activated in the target system, the function modules are generated again and correctly assigned to function groups.
    Parameters of the Function Modules
    Field Names of the Lock Object
    The keys to be locked must be passed here.
    A further parameter X_<field> that defines the lock behavior when the initial value is passed exists for every lock field <field>. If the initial value is assigned to <field> and X_<field>, then a generic lock is initialized with respect to <field>. If <field> is assigned the initial value and X_<field> is defined as X, the lock is set with exactly the initial value of <field>.
    Parameters for Passing Locks to the Update Program
    A lock is generally removed at the end of the transaction or when the corresponding DEQUEUE function module is called. However, this is not the case if the transaction has called update routines. In this case a parameter must check that the lock has been removed.
    Parameter _SCOPE controls how the lock or lock release is passed to the update program (see The Owner Concept for Locks). You have the following options:
    _SCOPE = 1: Locks and lock releases are not passed to the update program. The lock is removed when the transaction is ended.
    _SCOPE = 2: The lock or lock release is passed to the update program. The update program is responsible for removing the lock. The interactive program with which the lock was requested no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
    _SCOPE = 3: The lock or lock release is also passed to the update program. The lock must be removed in both the interactive program and in the update program. This is the standard setting for the DEQUEUE function module.
    Parameters for Lock Mode
    A parameter MODE_<TAB> exists for each base table TAB of the lock object. The lock mode for this base table can be set dynamically with this parameter. Valid values for this parameter are S (shared), E (exclusive) and X (exclusive but not cumulative).
    The lock mode specified when the lock object for the table is created is the default value for this parameter. This default value can however be overridden as required when the function module is called.
    If a lock set with a lock mode is to be removed by calling the DEQUEUE function module, this call must have the same value for the parameter MODE_<TAB>.
    Controlling Lock Transmission
    Parameter _COLLECT controls whether the lock request or lock release should be performed directly or whether it should first be written to the local lock container. This parameter can have the following values:
    Initial value: The lock request or lock release is sent directly to the lock server.
    X : The lock request or lock release is placed in the local lock container. The lock requests and lock releases collected in this lock container can then be sent to the lock server at a later time as a group by calling the function module FLUSH_ENQUEUE.
    Behavior for Lock Conflicts (ENQUEUE only)
    The ENQUEUE function module also has the parameter _WAIT. This parameter determines the lock behavior when there is a lock conflict.
    You have the following options:
    Initial value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is triggered.
    X : If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed since the first lock attempt. The waiting time and the time limit are defined by profile parameters.
    Controlling Deletion of the Lock Entry (DEQUEUE only)
    The DEQUEUE function module also has the parameter _SYNCHRON.
    If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table. Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the lock is removed, the entry in the lock table may still exist.
    Exceptions of the ENQUEUE Function Module
    FOREIGN_LOCK: A competing lock already exists. You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.
    SYSTEM_FAILURE: This exception is triggered when the lock server reports that a problem occurred while setting the lock. In this case, the lock could not be set.
    If the exceptions are not processed by the calling program itself, appropriate messages are issued for all exceptions.
    Reference Fields for RFC-Enabled Lock Objects
    The type of an RFC-enabled function module must be completely defined. The parameters of the generated function module therefore have the following reference fields for RFC-enabled lock objects:
    Parameters
    Reference fields
    X_<field name>
    DDENQ_LIKE-XPARFLAG
    _WAIT
    DDENQ_LIKE-WAITFLAG
    _SCOPE
    DDENQ_LIKE-SCOPE
    _SYNCHRON
    DDENQ_LIKE-SYNCHRON
    All the tables that can be included in a lock object must be linked with  foreign keys. There are a number of restrictions to the valid relationships.
    The foreign key relationships of the tables of the lock object must form a tree. The tables are the nodes of the tree. The links of the tree mean is the check table of.
    The foreign key fields must be key fields of the foreign key table.
    The foreign key relationships defined between the base tables of the lock objects may not have any field that is checked against more than one other field. A field therefore may not occur twice as foreign key field in a relationship and may not be checked against two different fields in two different foreign key relationships.
    You must keep one restriction in mind for  multi-structured foreign keys. If a field is assigned to a field that is outside the check table, the table containing this field must be in a sub-tree that contains the check table of this foreign key relationship as a root.
    These conditions are always satisfied if the key of the foreign key table is an extension of the key of the check table.
    Conditions 2, 3 and 4 are meaningless if the particular foreign key field was excluded from the assignment to the key fields of the check table by  marking it as generic or setting it to a constant. This is also true for multi-structured foreign keys if the foreign key field refers to a table that is not contained in the lock object.
    Regards.
    Eshwar.

  • Re: lock objects

    Hi,
         Iam implementing some screens. I created some lock objects. I could not able to  under these concepts. Even though I studied some documents, i could not get the below concepts. can anybody explain.
    1. what is the enqueue mode
    2. what is the scope
    3.what is the wait parametrs
    rgds
    p.kp

    Hi paluri,
    Info taken from standard sap help.
    1. Enqueu Mode.
    The lock mode controls whether several users can access data records at the same time. The lock mode can be assigned separately for each table in the lock object. When the lock is set, the corresponding lock entry is stored in the lock table of the system for each table.
    Access by more than one user can be synchronized in the following ways:
    Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
    Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
    Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
    2. Scope
    Parameter _SCOPE controls how the lock or lock release is passed to the update program (see The Owner Concept for Locks). You have the following options:
    _SCOPE = 1: Locks and lock releases are not passed to the update program. The lock is removed when the transaction is ended.
    _SCOPE = 2: The lock or lock release is passed to the update program. The update program is responsible for removing the lock. The interactive program with which the lock was requested no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
    _SCOPE = 3: The lock or lock release is also passed to the update program. The lock must be removed in both the interactive program and in the update program. This is the standard setting for the DEQUEUE function module.
    3. WAIT
    The ENQUEUE function module also has the parameter _WAIT. This parameter determines the lock behavior when there is a lock conflict.
    You have the following options:
    Initial value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is triggered.
    X : If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed since the first lock attempt. The waiting time and the time limit are defined by profile parameters.
    regards,
    amit m.

Maybe you are looking for