[MDEV-26623] Possible race condition between statistics and bulk insert Created: 2021-09-16  Updated: 2021-09-21  Resolved: 2021-09-17

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6
Fix Version/s: 10.6.5, 10.7.0

Type: Bug Priority: Critical
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance, race, regression-10.6

Issue Links:
Blocks
blocks MDEV-24621 In bulk insert, pre-sort and build in... Closed
Problem/Incident
is caused by MDEV-515 innodb bulk insert Closed

 Description   

This issue was found during the testing of MDEV-24621, by an intermittent failure of the test innodb.insert_into_empty. The failure occurred during the ROLLBACK of an INSERT into a table that was empty.

I was not able to repeat a failure on 10.6, but I think that a similar race condition is present. When we are computing statistics for an index tree, we failed to check whether an insert into an empty table is in progress by an active transaction. If yes, we should do what MVCC reads do: pretend that the table is empty.

No crash or other problem is known in the current 10.6 or in 10.7, but I think that it is better to treat this situation in a safe and consistent manner.



 Comments   
Comment by Marko Mäkelä [ 2021-09-16 ]

After conducting some research and developing a fix, I do think any ill effects of this are unlikely before MDEV-24621. With MDEV-24621, it is a completely different matter, because the B-tree could be in internally inconsistent state while the bulk index creation is in progress.

Nevertheless, it is good to avoid unnecessary work and avoid statistics recomputation while we know that a bulk insert is in progress.

Generated at Thu Feb 08 09:46:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.