In mysql 5.7 documentation, it says that for READ-COMMITTED isolation level, there wouldn't be any next-key locks or gap locks placed on an update query. But I'm getting frequent deadlocks for the following query.
UPDATE customer SET status ='SUCCESS' WHERE subscriber_id IN (146,148,150,152,153,154,155,156,157,158)
The subscriber_id is an indexed field but not unique.
When I checked for the innodb status following was found.
For the first transaction
(1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 57008 page no 6 n bits 224 index subscriber_id of table
customer
.subscriber_id
/* Partitionmonthly_rest
*/ trx id 1340735 lock_mode X locks rec but not gap waitingRecord lock, heap no 144 PHYSICAL RECORD: n_fields 2; compact format; > info bits 0
0: len 8; hex 8000000000000093; asc ;;
1: len 5; hex 999b870acb; asc ;;For the second transaction
*** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 57008 page no 6 n bits 224 index subscriber_id of table
customer
.subscriber_id
/* Partitionmonthly_rest
*/ trx id 1340730 lock_mode X locks rec but not gapRecord lock, heap no 136 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
0: len 8; hex 8000000000000093; asc ;;
1: len 5; hex 999b870acb; asc ;;
I've only put an excerpt of the lock details here.
It seems like the subscriber_id field has been locked with a next-key lock.
Is it possible even with READ-COMMITTED in mysql 5.7 to get a next-key lock ?
Could that be due to using a non-unique key ?
It would be an immense help if someone can provide an explanation