I faced an issue in MySql 5.7 that when I select 14 or more rows with FOR UPDATE a whole table is locked. Even though I select them by primary key (so, it's indexed and unique). Literally it looks like this. When I run this query:
select * from mytable
where id in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
for update;
Everything works fine and only rows selected are locked. But this query:
select * from mytable
where id in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
for update;
locks whole table. I can't update any other entry nor I can insert a new row. The table is locked. Ids can be different what matters is their number (14 or more). I tried to google for it but didn't find anything.
Is it some strict MySql (we use version 5.7) limitation for row lock (13 rows) and if you select more then a table lock is applied? Can it be changed somehow? Or is it only our specific problem and we need to dig deeper?