Reputation: 958
I have concurrent batch inserts with around 1000 records per batch, on a TokuDB 7.5. Each batch update is done within a single transaction. The table contains around 100 million records too.
The issue is that it throws the following exception time to time.
java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction
The transaction isolation level used is Repeatable_Read and I read in an article that using Repeatable_Read would result in gap locks for SELECT queries.
But at the moment we have only INSERTS.
Could this lock timeout be due to gap locks and if so how does concurrent INSERTS get affected by gap locks?
The schema
CREATE TABLE `message` (
`id` BIGINT(20) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
`message_id` VARCHAR(255) NOT NULL,
`sent_time` TIMESTAMP DEFAULT '0000-00-00 00:00:00' ,
`type_id` TINYINT(4) NOT NULL,
`correlation_id` BIGINT(20) NOT NULL,
`origination_address` VARCHAR(16) NOT NULL,
`destination_address` VARCHAR(16) NOT NULL,
`created_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
UNIQUE KEY (`message_id`,`sent_time`, `type_id`, `correlation_id`),
KEY `OA` (`origination_address`),
KEY `DA` (`destination_address`)
)
Upvotes: 0
Views: 319