views:

24

answers:

2

I get a lock timeout when updating a certain row in the database. Other rows update okay.

#1205 - Lock wait timeout exceeded; try restarting transaction

How can I unlock this particular row?

Here are the two related tables. I'm trying to update the email on user. I don't think tenant should be causing any problems though.

CREATE  TABLE IF NOT EXISTS `mydb`.`user` (
  `username` VARCHAR(45) NOT NULL ,
  `email` VARCHAR(60) NOT NULL ,
  `password` VARCHAR(45) NOT NULL ,
  `created` TIMESTAMP NULL DEFAULT NULL ,
  `last_login` TIMESTAMP NULL ,
  PRIMARY KEY (`username`) )

ENGINE = InnoDB;


CREATE  TABLE IF NOT EXISTS `mydb`.`tenant` (
  `id` INT NOT NULL AUTO_INCREMENT ,
  `username` VARCHAR(45) NOT NULL ,
  `address` VARCHAR(90) NULL ,
  `company` VARCHAR(45) NULL ,
  `phone` VARCHAR(25) NOT NULL ,
  `fax` VARCHAR(25) NULL ,
  `notes` TEXT NULL ,
  `contacts` TEXT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_tenant_user1` (`username` ASC) ,
  CONSTRAINT `fk_tenant_user1`
    FOREIGN KEY (`username` )
    REFERENCES `mydb`.`user` (`username` )
    ON DELETE CASCADE
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
+1  A: 

Try running the following in an interactive mysql client:

SHOW ENGINE INNODB STATUS\G

And look at the currently open transactions. See if one of them is causing the row to be locked.

Amber
I found an operation called flush in phpmyadmin. Rows not locked anymore.
Keyo
A: 

I ended up just running FLUSH TABLE user and it seems fine now.

Keyo