Bug #83575 InnoDB atomics bs: os_alloc_block
Submitted: 27 Oct 2016 11:55 Modified: 28 Nov 2016 5:31
Reporter: Sergey Vojtovich Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:ARM

[27 Oct 2016 11:55] Sergey Vojtovich
Description:
There're os_alloc_block() and os_free_block() in os/os0file.cc. The former takes block from cache, the latter releases block back to cache.

Each block has m_in_use member, which indicates if block is used or not. m_in_use is updated atomically using TAS().

Thread that is releasing block to cache must complete all modifications of block members before another concurrent thread starts using it. However it is not enforced properly, because TAS() doesn't issue correct memory barriers (see BUG#83532 for description about TAS() issues). This is prone to race conditions.

os_alloc_block() should issue acquire memory barrier
os_free_block() should issue release memory barrier

Currently they issue either acquire-acquire, or release-release, or full-full.

How to repeat:
Code analysis.

Suggested fix:
Issue proper memory barriers.
[28 Nov 2016 5:31] MySQL Verification Team
Hello Sergey Vojtovich,

Thank you for your bug report. At this time we don't see any correctness issues. Our testing on Intel HW doesn't demonstrate any issues. We will triage and analyse the suggested changes as part of our process.

Thanks,
Umesh