diff -urNad mysql-5.7.18/storage/innobase/page/page0cur.cc mysql-5.7.18.new/storage/innobase/page/page0cur.cc --- mysql-5.7.18/storage/innobase/page/page0cur.cc 2017-03-18 15:45:14.000000000 +0800 +++ mysql-5.7.18.new/storage/innobase/page/page0cur.cc 2017-06-14 17:41:10.000000000 +0800 @@ -645,8 +645,16 @@ goto up_rec_match; } } - - if (mode <= PAGE_CUR_GE) { + /* if find the key in the no-leaf node(cmp = 0), do not use + * the pre-node for searching, just use the up_rec, because + * if the row is the first one on a page, use pre-node will + * lock the supremum , keys like below: + * (infimum, 1,2,...,supremum),(infimum, 5,6,..., supremum), + * if do "select * from tbl where id = 5 for update", if use pre-node + * for searching, the supremum & id=5, will be locked, but if the + * id = 5 is not the first row of that page, only id=5 will be locked, + * different locations maybe resulting difference*/ + if (mode <= PAGE_CUR_GE || cmp == 0) { page_cur_position(up_rec, block, cursor); } else { page_cur_position(low_rec, block, cursor);