I am trapping Error 1205 (innodb_lock_wait_timeout), so I would like to find out who is the user that has an Exclusive Lock for that row when this Error occurs.
Using InnoDB storage and MySQL 5.0.18, VS 2005 - C#.
I am using this strategy:
SET AUTOCOMMIT=0
START TRANSACTION
SELECT * FROM sometable WHERE id = 1 FOR UPDATE;
Code: Select all
DbCommandBase myCommand = new CoreLab.MySql.MySqlCommand("SELECT * FROM sometable WHERE id = 1 FOR UPDATE", mySQLConnection);
DbDataReader myReader = null;
IAsyncResult result = null;
try{
result = myCommand.BeginExecuteReader(null, null, System.Data.CommandBehavior.SingleRow);
while(!result.IsCompleted){
/// ... Display process window
}
myReader = myCommand.EndExecuteReader(result);
// ... Get the data fields
}
catch(MySqlException ex){
switch(ex.Code){
case 1205:
// Here I want to find out the user that holds that lock for this record.
break;
.....
}
}
Thanks.
Kaz