Reputation: 75
I have created database table. But there is a strange thing I can insert row into table, but when I want to delete or update database row it throws an error:
/* SQL Error (1205): Lock wait timeout exceeded; try restarting transaction */
In other tables there is no errors, and everything works pretty fine.
Here is a table structure:
CREATE TABLE `cruises` (
`id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`enable_text` ENUM('true','false') NOT NULL,
`enable_file` ENUM('true','false') NOT NULL,
`title` VARCHAR(256) NOT NULL,
`full_text` MEDIUMTEXT NOT NULL,
`description` VARCHAR(256) NULL,
`date_of_departure` DATE NOT NULL,
`number_of_nights` INT(10) UNSIGNED NOT NULL,
`point_of_departure` VARCHAR(256) NOT NULL,
`cruise_type` BIGINT(10) UNSIGNED NOT NULL,
`cruises_document_id` BIGINT(10) UNSIGNED NOT NULL,
`price` FLOAT(5,0) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
INDEX `FK_cruises_cruises_types` (`cruise_type`),
INDEX `FK_cruises_cruises_documents` (`cruises_document_id`),
CONSTRAINT `FK_cruises_cruises_documents` FOREIGN KEY (`cruises_document_id`) REFERENCES `cruises_documents` (`id`),
CONSTRAINT `FK_cruises_cruises_types` FOREIGN KEY (`cruise_type`) REFERENCES `cruises_types` (`id`)
)
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
I have tried this thing on 2 different databases, but the same problem appears all the time. Any ideas?
Upvotes: 2
Views: 9656
Reputation: 31647
This is problem of lock contention, which ultimately result in a time-out on one of the lock. Here are a few suggestions:
Also check if you are obtaining two connections. Because of that two transaction will get mixed and you will get above error!!!
Also check this link.. this might help you...
Upvotes: 7