gregsimpson,
Thanks for the suggestions.
I`m using W2K as OS, and DB2 UDB V8.14 .
I`ll take a look on the DGI site maybe they offer something for W2K as well. At least I`ll get some usefull keywords for google
> Without sounding insulting..
Don't worry about that, I'm greatfull for your help. Feel free to asume what ever might help.
I'll be a bit more detailed this time. This might be helpfull for others who encounter the same problem.
On the other hand you or someone else might see the cause
of my problem and provide help.
> tests indicative of the real world..
My Test is simulating a series of similar transactions but each of them working on different entries in the target table :
Transaction T1 - repeats 10 times
1) INSERT INTO RFunction ..
2) COMMIT
Transaction T2 - repeates 10 times for each T1
1) INSERT INTO RFunction ..
2) INSERT INTO RFuncNode ...
3) SELECT ... FROM RFuncNode WHERE Col2 = ? AND Col3 < ? ORDERBY Col3 ASC
4) UPDATE ... RFuncNode ..
5) SELECT ... FROM RFuncNode WHERE Col5 = ? ...
6) UPDATE ... RFuncNode ..
7) COMMIT
Comments:
- The Selects in 3 & 5 define a subset of the RFuncNode Table that dosen`t include the newly inserted RFuncNode entry in step 2.
- The Update's change only the the newly inserted RFuncNode entry in step 2.
- The successfull Inserts grant that each transaction works on entries that are not directly accessed by other processes or subsequent Transactions.
- This Test simulates 2 common and usually subsequent Actions of a User:
1) Submit new Systemelement
2) Connect new Function to the previously created Systemelement.
Initially I wouldn't expect any dedlocks or locktimeouts for this test scenario even if 100 processes are running concurrently.
Still this is the problem CLI is reporting:
SQLSTATE = 40001
Native Error Code = -911
[IBM][CLI Driver][DB2/NT] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001
Since the transactions have a avarege duration between 100ms to 600ms, and the LOCKTIMEOUT is set to 30s I would expect locktimeouts earliest up to 60 parallel running processes. actually I encounterthem already with 2 concurrent instances of the TestAPP.
After deeper investigations on isolation levels and locking issues in DB2 I came to a more or less satisfactory solution ( read at the end of the posting ).
STILL there are open questions I couldn't answer!?!
There is a deadlock situation I encounter:
success/process A B
--------------------------------------------
true INSERT
true INSERT
false SELECT
false SELECT
DEADLOCK!!
Following settings are active:
- We have 1 persistent connection per process to the same DB,using the CS - Isolation level, AutoCommit Off and Read Write Access Mode.
- Each step of the transaction allocates a new statement handle and frees the handle after execution and eventual fetch's using always the central allocated connection handle.
- Following Statement attributes are used:
Close Behaviour = CC_RELEASE
Concurrency = CONCUR_LOCK
Cursor Hold = CURSOR_HOLD_ON
Scrollable = NONSCROLLABLE
Sensitivity = UNSPECIFIED
Cursor Type = FORWARD_ONLY
Prefetch = PREFETCH_ON
Query Optimization Level = 3
Stmt Isolation = READ_COMMITED ( = CS )
Comment:
The SELECT I'm talking here of is the step 3 or 5, and the INSERT is step 2 of the Transaction 2.
Both statements access the same table RFuncNode!
Questions:
Why is the INSERT of B allowed but the SELECT is not?
( as mentioned the set of entries defined by the SELECT dose not include the new inserted entry! )
Solution( but not satisfactory )
The only way to overcome this situation was to explicitely Lock the complete table exclusively till to the next COMMIT.
Our target was to take advantage of the rowlevel locking capabilities of DB2 and encrease the cuncurrency performance of our application.
Moreover this behaviour of DB2 is not understandable. Eather this is a bug, or I am still missing something!?!
My monitoring and snapshot sessions show me that there are no Lockescalations or deadlocks only locktimeouts:
Locks held currently = 18
Lock waits = 370
Time database waited on locks (ms) = 880936
Lock list memory in use (Bytes) = 2880
Deadlocks detected = 0
Lock escalations = 0
Exclusive lock escalations = 0
Agents currently waiting on locks = 1
Lock Timeouts = 13
Number of indoubt transactions = 0
A overall Solution was reached using following constellation:
1) Exclusive locking of target table before inserts.
2) speciffics for Read Only Transactions:
a) Read Only Access Mode for the connection
b) Read Uncommited statement isolation level
3) speciffics for Read Write Transactions
a) Read Write Access Mode for the connection
b) Read Commited statement isolation level
4) average Connection attributes
a) Autocommit - off
b) Connect Type - coordinated transaction
c) Sync point - Two Phase
d) Isolation Level - READ_COMMITED ( = CS )
5) average Statement attributes
a) Close Behaviour = CC_RELEASE
b) Concurrency = CONCUR_LOCK
c) Cursor Hold = CURSOR_HOLD_ON
d) Scrollable = NONSCROLLABLE
e) Sensitivity = UNSPECIFIED
f) Cursor Type = FORWARD_ONLY
g) Prefetch = PREFETCH_ON
h) Query Optimization Level = 3
Last but not least,
I would like to eliminate point 1 ( Table locking ) but I don't know how to solve the deadlock situation discribed
above.
I'm greatfull for any suggestions and help?
Thanks,