[MDEV-10476] MariaDB 10.x.y does not include fix for upstream bug #68079 Created: 2016-08-01  Updated: 2022-02-08  Resolved: 2016-11-02

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Storage Engine - InnoDB
Affects Version/s: 10.0.23, 10.1.16
Fix Version/s: 10.2.2

Type: Bug Priority: Major
Reporter: Valerii Kravchuk Assignee: Sergey Vojtovich
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-27767 poor scaling with InnoDB and utf8mb3 ... Closed

 Description   

Upstream bug https://bugs.mysql.com/bug.php?id=68079 is fixed since 5.6.16. To fix it new CMake option was introduced, INNODB_PAGE_ATOMIC_REF_COUNT.

This option is visible in the code (MariaDB 10.1, cloned today):

[openxs@centos server]$ git branch
* 10.1
[openxs@centos server]$ grep -rni INNODB_PAGE_ATOMIC_REF_COUNT *
storage/innobase/include/buf0types.h:29:#if defined(INNODB_PAGE_ATOMIC_REF_COUNT) && defined(HAVE_ATOMIC_BUILTINS)
storage/innobase/include/buf0types.h:31:#endif /* INNODB_PAGE_ATOMIC_REF_COUNT && HAVE_ATOMIC_BUILTINS */
storage/xtradb/include/buf0types.h:29:#if defined(INNODB_PAGE_ATOMIC_REF_COUNT) && defined(HAVE_ATOMIC_BUILTINS)
storage/xtradb/include/buf0types.h:31:#endif /* INNODB_PAGE_ATOMIC_REF_COUNT && HAVE_ATOMIC_BUILTINS */
[openxs@centos server]$

But, as you can see, it is not mentioned in CMakeLists.txt and (probably for this reason) is not used. In the error logs of 10.0.23 we see:

160721 14:22:06 [Note] /home/openxs/10.0.23/bin/mysqld (mysqld 10.0.23-MariaDB-log) starting as process 2418 ...
160721 14:22:06 [Note] InnoDB: Using mutexes to ref count buffer pool pages

even though this version already uses InnoDB 5.6.26. For comparison, Percona Server 5.6.28 starts like this:

 
...
2016-02-24 18:25:37 1814 [Note] InnoDB: Using atomics to ref count buffer pool p
ages
2016-02-24 18:25:37 1814 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-24 18:25:37 1814 [Note] InnoDB: Mutexes and rw_locks use GCC atomic buil
tins
2016-02-24 18:25:37 1814 [Note] InnoDB: Memory barrier is not used
2016-02-24 18:25:37 1814 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-24 18:25:37 1814 [Note] InnoDB: Using Linux native AIO
2016-02-24 18:25:37 1814 [Note] InnoDB: Not using CPU crc32 instructions
2016-02-24 18:25:37 1814 [Note] InnoDB: Initializing buffer pool, size = 5.0M
2016-02-24 18:25:37 1814 [Note] InnoDB: Completed initialization of buffer pool
2016-02-24 18:25:37 1814 [Note] InnoDB: Highest supported file format is Barracu
da.
2016-02-24 18:25:38 1814 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-24 18:25:38 1814 [Note] InnoDB: Waiting for purge to start
2016-02-24 18:25:39 1814 [Note] InnoDB: Percona XtraDB (http://www.percona.com)
5.6.28-76.1 started; log sequence number 1017098584
...

In the code of current upstream MySQL 5.6 we see:

[openxs@centos mysql-server]$ grep -rni INNODB_PAGE_ATOMIC_REF_COUNT *
CMakeLists.txt:332:OPTION(INNODB_PAGE_ATOMIC_REF_COUNT "Use atomics for the page reference count"
CMakeLists.txt:334:MARK_AS_ADVANCED(INNODB_PAGE_ATOMIC_REF_COUNT)
config.h.cmake:552:#cmakedefine INNODB_PAGE_ATOMIC_REF_COUNT
storage/innobase/include/buf0types.h:29:#if defined(INNODB_PAGE_ATOMIC_REF_COUNT) && defined(HAVE_ATOMIC_BUILTINS)
storage/innobase/include/buf0types.h:31:#endif /* INNODB_PAGE_ATOMIC_REF_COUNT && HAVE_ATOMIC_BUILTINS */
[openxs@centos mysql-server]$ git branch
* 5.6
  5.7

I know there were problems with this option on Windows long time ago, but is it a good reason to NOT use it and related InnoDB scalability improvements?



 Comments   
Comment by Jan Lindström (Inactive) [ 2016-08-02 ]

svoj Can you have a look if these optimizations are correct for (most) platforms?

Comment by Sergey Vojtovich [ 2016-08-03 ]

There was 1 original commit + 7 follow-up patches. We should be carefull with this code.

commit d3748c32261c5371bb2cab7cf062aec26ae668ae
Author: Sunny Bains <Sunny.Bains@Oracle.Com>
Date:   Tue Dec 10 14:30:34 2013 +0530
 
    Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
 
    Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
 
    If this option is enabled then use atomic reference counting to track
    block use. If it is off then use the old way.
 
    Approved by Yasufumi Kinoshita rb#3958.
 
commit 1fd7ffd925bce9567505ed309f3a65a83f86f725
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Fri Dec 13 12:52:47 2013 +0900
 
    The adjustment about UNIV_SUNC_DEBUG is needed for Bug#16249481 fix
 
    Approved by Sunny Bains (IM)
 
      * revno: 5677
      * committer: Sunny Bains <Sunny.Bains@Oracle.Com>
      * branch nick: 5.6
      * timestamp: Tue 2013-12-10 14:30:34 +0530
      * message:
      *  Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
      *
      *  Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
      *
      *  If this option is enabled then use atomic reference counting to track
      *  block use. If it is off then use the old way.
      *
      *  Approved by Yasufumi Kinoshita rb#3958.
 
commit ca5ba29de6f3ddeb92684960f28420824f30c7e1
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Fri Dec 13 13:23:34 2013 +0900
 
    Fix the possibile rare race condition at Bug#16249481 fix.
 
    Approved by Sunny Bains (IM)
 
      * revno: 5677
      * committer: Sunny Bains <Sunny.Bains@Oracle.Com>
      * branch nick: 5.6
      * timestamp: Tue 2013-12-10 14:30:34 +0530
      * message:
      *  Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
      *
      *  Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
      *
      *  If this option is enabled then use atomic reference counting to track
      *  block use. If it is off then use the old way.
      *
      *  Approved by Yasufumi Kinoshita rb#3958.
 
commit b250bb745aef2a69609f10979f1b9b93382c9569
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Mon Dec 16 21:03:59 2013 +0900
 
    The fix for Bug#16249481 was not enabled for builds.
 
    "#cmakedefine INNODB_PAGE_ATOMIC_REF_COUNT" is added to config.h.cmake
 
    Patch made by Sunny Bains (by mail)
    Approved by Yasufumi Kinoshita
 
      * revno: 5677
      * committer: Sunny Bains <Sunny.Bains@Oracle.Com>
      * branch nick: 5.6
      * timestamp: Tue 2013-12-10 14:30:34 +0530
      * message:
      *  Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
      *
      *  Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
      *
      *  If this option is enabled then use atomic reference counting to track
      *  block use. If it is off then use the old way.
      *
      *  Approved by Yasufumi Kinoshita rb#3958.
 
commit 20b3af993ef76649b31eaa49db7e2d5ad6e1c1a4
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Tue Dec 17 20:03:26 2013 +0900
 
    Follow up for Bug#16249481 fix.
    Atomic operation macro for Soralis and Windows added by Bug#16249481 fix were wrong.
    Aligned same for mysql-trunk.
 
      * revno: 5677
      * committer: Sunny Bains <Sunny.Bains@Oracle.Com>
      * branch nick: 5.6
      * timestamp: Tue 2013-12-10 14:30:34 +0530
      * message:
      *  Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
      *
      *  Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
      *
      *  If this option is enabled then use atomic reference counting to track
      *  block use. If it is off then use the old way.
      *
      *  Approved by Yasufumi Kinoshita rb#3958.
 
commit 4b32d8df5c27931719397a0aacbdb6efd1c5bbea
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Tue Dec 17 20:30:16 2013 +0900
 
    Follow up for Bug#16249481 fix.
    backport from mysql-trunk
 
      revno: 7152
      committer: Vasil Dimov <vasil.dimov@oracle.com>
      branch nick: mysql-trunk
      timestamp: Tue 2013-12-17 11:29:47 +0200
      message:
        Followup to sunny.bains@oracle.com-20131210092144-0xfzdmj5vgqlqpq2
 
        Fix a compilation failure on Win32:
 
          buf0buf.ic(1016): error C2664: '_InterlockedExchangeAdd' : cannot
          convert parameter 1 from 'ib_uint32_t *' to 'volatile long *'
          Types pointed to are unrelated; conversion requires reinterpret_cast,
          C-style cast or function-style cast
 
commit 0bac43f323247047ec24b1bbad8a138fb2ee5700
Author: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
Date:   Tue Dec 31 12:29:00 2013 +0900
 
    Follow up for Bug#16249481 fix.
    If flush_rbt is active (in recovery phase), buf_page_t::space and buf_page_t::offset cannot be invalidated until the bpage is removed from flush_list.
 
      * revno: 5677
      * committer: Sunny Bains <Sunny.Bains@Oracle.Com>
      * branch nick: 5.6
      * timestamp: Tue 2013-12-10 14:30:34 +0530
      * message:
      *  Bug#16249481 - INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR SPECIFIC ALL IN MEMORY SELECT
      *
      *  Add a new build option: INNODB_PAGE_ATOMIC_REF_COUNT, default is ON.
      *
      *  If this option is enabled then use atomic reference counting to track
      *  block use. If it is off then use the old way.
      *   *  Approved by Yasufumi Kinoshita rb#3958.
 
commit 3c1c0c0107e0c322097b35261c72e67c5c52e84c
Author: Marko Mäkelä <marko.makela@oracle.com>
Date:   Fri Apr 4 12:17:07 2014 +0300
 
    Remove some Valgrind check requests that were broken by the following:
 
    Bug#16249481 INNODB DOES NOT SCALE WELL ON 12 CORE SYSTEM FOR
    SPECIFIC ALL IN MEMORY SELECT
 
         This fix increased sizeof(buf_page_t) from 64 bytes even on
         32-bit systems.
 
    WL#5522 Fix the IMPORT tablespace performance.
 
         This fix made sizeof(page_zip_des_t) something else than a power
         of two.
 
    The removed UNIV_MEM_ASSERT_RW() checks were only enabled on 32-bit
    systems. Since the above changes, they would emit bogus warnings about
    unused "pad" bytes being uninitialized.

Comment by Sergey Vojtovich [ 2016-08-09 ]

jplindst, the code is generally not better than mutex code. It is not completely correct even for x86, but it may work due to implicit invariants between buf_fix_count and other variables. I'll have to spend about a week to track them all. I estimate 20% higher probability of breakage on non-x86.

While it may improve scalability, it may cause performance regression since these atomic operations use heavyweight full memory barrier.

Comment by Jan Lindström (Inactive) [ 2016-08-09 ]

Opened for 10.2 for correct and improved fix.

Comment by Sergey Vojtovich [ 2016-08-22 ]

We already have code for this feature and enabling it in 10.2 is fine. But we must think 10x before enabling it in GA versions.

IIRC we declared support for P8 and Z at least.

Comment by Sergey Vojtovich [ 2016-11-02 ]

This was fixed along with InnoDB 5.7 merge. This option was removed and atomic primitives are used by default:

commit fad82cd80b23a22885ecd1fb9d0470f1c508d170
Author: Marko Mäkelä <marko.makela@oracle.com>
Date:   Fri Jul 4 06:01:03 2014 +0300
 
    Bug#19061440 CMAKE -DINNODB_PAGE_ATOMIC_REF_COUNT:BOOL=OFF IS BROKEN
 
    The configuration option
    cmake -DINNODB_PAGE_ATOMIC_REF_COUNT:BOOL=OFF
 
    is broken ever since WL#7682 was merged.
 
    It is also useless since WL#7655, because MySQL 5.7 can no longer
    be built on systems that do not support atomic memory access primitives.
 
    This patch removes the option. It should be a non-functional change,
    because the undocumented build-time option was ON by default.
 
    rb#5844 approved by Yasufumi Kinoshita

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