tags:

views:

367

answers:

1

Hi There

I have a problem here. I have a DB2 v8.1 where I have this particular table which I cannot query or open. Whenever I tried to query or sample data it will tell me its a timeout/deadlock issue after for long time. No one is using the table so it cant be deadlock. Is there anyway i can recover this table? thanks.

+3  A: 

Can you just do a select with an UNCOMMITED READ isolation level in order to bypass all the eventual locks :

SELECT * FROM YOUR_TABLE 
FETCH FIRST 10 ROWS ONLY
WITH UR

This way it will retrieve 10 rows from the table. If it works, just do it again without the FETCH FIRST clause : it was effectively locked by some other connection.

You can also try with changing the optimisation level by issuing

SET CURRENT QUERY OPTIMIZATION 0

in order to just activate INDEX SCAN, FULL SCAN & NESTED LOOPS without all those efficient, but often expensive HASH JOIN & friends that could be the culprit here if the stats are miscalculated.

Edit:

With the comments, I think that your best bet would be with db2dart to check your database.

Steve Schnepp
Hi there this is the error that I got when executing it.DBA2191E SQL execution error.com.ibm.db.DataException: A database manager error occurred. : [IBM][CLI Driver][DB2/NT] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001
Steve Schnepp
Could you try with a "FOR READ ONLY" at the end of the request ?
Steve Schnepp
Hi there.It doesnt work :( same problem.
Hmmm... Stop/start the DB ? BTW, what is you lock_timeout configuration value ?
Steve Schnepp
i think I tried before stop and start still the same. how do you go to the lock_timeout config value? thanks for the help
http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0000329.htm
Steve Schnepp
Is it possible my table is corrupted? I cannot even export the table. as I can see the exported file but its 0 bytes. :(
This is my error msgSQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "".Explanation: The current unit of work was involved in an unresolved contention for use of an object and had to be rolled back. The reason codes are as follows: 2 transaction rolled back due to deadlock. 68 transaction rolled back due to lock timeout. 72 transaction rolled back due to an error concerning a DB2 Data Links Manager involved in the transaction. Note: The changes associated with the unit of work must be entered again.
(cont) The application is rolled back to the previous COMMIT. User Response: To help avoid deadlock or lock timeout, issue frequent COMMIT operations, if possible, for a long-running application, or for an application likely to encounter a deadlock.
Federated system users: the deadlock can occur at the federated server or at the data source. There is no mechanism to detect deadlocks that span data sources and potentially the federated system. It is possible to identify the data source failing the requestDeadlocks are often normal or expected while processing certain combinations of SQL statements. It is recommended that you design applications to avoid deadlocks to the extent possible. sqlcode : -911 sqlstate : 40001
I updated the answer with a link to db2dart
Steve Schnepp