Bug #96988 Parallel read index may skip some records to get wrong result
Submitted: 24 Sep 2019 8:01 Modified: 25 Oct 2019 11:58
Reporter: Qingda Hu Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version: OS:Any (8.0)
Assigned to: CPU Architecture:Any

[24 Sep 2019 8:01] Qingda Hu
Description:
In function PCursor::yield(), after yielding for another thread, it calls restore_position() to restore cursor position on the record.

That is, in function class PCursor::restore_position(), it calls btr_pcur_t::restore_position() to restore the cursor. If relative is BTR_PCUR_ON and equal is not true, this means that the cursor is now on a record less than the old user record. So it calls page_cur_move_to_next() to move to the next record 'A'. 

However, after calling restore_position(), PCursor::yield() may call m_pcur->move_to_next_on_page again, which may skip the record 'A' to get wrong result.

How to repeat:
The error is hard to repeat, so I try to describe the bug.

Assume there are some records on a page: 'A' -> 'B' -> 'C'.

Time1 (thread 1): 
call PCursor::yield(), store the m_pcur on the record 'C', and then go to yield.

Time2 (thread 2):
insert records 'D'/'E',  and then delete and purge record 'C'.
Now,  there are some records on a page: 'A' -> 'B' -> 'C' -> 'D'

Time 3(thread 1):
restore the m_pcur in PCursor::restore_position() in 'B', and then move to 'C'. 
Then, it move to 'D' in PCursor::yield()
[24 Sep 2019 8:21] Qingda Hu
I am sorry that the above repeat process is not clear.

How to repeat:

The error is hard to repeat, so I try to describe the bug.

Assume there are some records on a page: 'A' -> 'B' -> 'C'.

Time1 (thread 1): 
call PCursor::yield(), store the m_pcur on the record 'C', and then go to yield.

Time2 (thread 2):
insert records 'D'/'E',  and then delete and purge record 'C'.
Now,  there are some records on a page: 'A' -> 'B' -> 'D' -> 'E'

Time 3(thread 1):
restore the m_pcur in PCursor::restore_position() in 'B', and then move to 'D'. 
Then, it move to 'E' in PCursor::yield(), and so skip 'D"
[24 Sep 2019 12:08] MySQL Verification Team
Hi Mr. Hu,

Thank you for your bug report.

Unfortunately, your report is totally unclear.

What are the real consequences of this potential bug ??? How does it manifest itself when you run a query ???

What should the code really look like, in your opinion ???

We also need a fully repeatable test case. That means a set of multiple SQL statements, which could be run in parallel, but would ALWAYS lead to the error. We can not proceed without it ...

Last, but not least, you should try to repeat this behaviour with 8.0.17 or, even better, 8.0.18 , which should be released in the near future.

Thanks in advance.
[25 Oct 2019 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".