Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22593

InnoDB: don't take trx_sys.mutex in ReadView::open()

Details

    Description

      This is something that wasn't addressed during the large trx_sys refactoring. Taking trx_sys.mutex is bad for 2 reasons:

      • it is not intended for synchronisation between purge and connection threads
      • it is a global mutex on a hot-path that can be avoided.

      Attachments

        Issue Links

          Activity

            marko, please review 2 patches on top of https://github.com/MariaDB/server/commits/bb-10.5-svoj-MDEV-22593. Transition to trx->read_view.mutex will need extra polishing if we decide to take it (specifically purge_tag).

            svoj Sergey Vojtovich added a comment - marko , please review 2 patches on top of https://github.com/MariaDB/server/commits/bb-10.5-svoj-MDEV-22593 . Transition to trx->read_view.mutex will need extra polishing if we decide to take it (specifically purge_tag).

            Very good. I did not find any correctness issue. I requested some clarification to comments and addition of debug assertions.

            marko Marko Mäkelä added a comment - Very good. I did not find any correctness issue. I requested some clarification to comments and addition of debug assertions.

            I had minor comments on the squashed patch.
            mleich is testing it and should give his verdict soon.

            marko Marko Mäkelä added a comment - I had minor comments on the squashed patch. mleich is testing it and should give his verdict soon.

            kvm-asan is not happy: the test main.implicit_commit fails.

            10.5 03dcdad251c414f387e074643f8e4187edcf6c02

            CURRENT_TEST: main.implicit_commit
            mysqltest: In included file "./include/implicit_commit_helper.inc": 
            included from /home/buildbot/buildbot/build/mariadb-10.5.4/mysql-test/main/implicit_commit.test at line 221:
            At line 3: query '$statement' failed: 2013: Lost connection to MySQL server during query
            ==87490==ERROR: AddressSanitizer: use-after-poison on address 0x7ff366bdba48 at pc 0x000001b913ca bp 0x7ff35ef749b0 sp 0x7ff35ef749a8
            READ of size 4 at 0x7ff366bdba48 thread T17
                #0 0x1b913c9 in ShowStatus::GetCount::operator()(LatchCounter::Count*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16198:15
                #1 0x1b8240e in void LatchCounter::iterate<ShowStatus::GetCount>(ShowStatus::GetCount&) const /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/sync0types.h:664:4
                #2 0x1b8240e in ShowStatus::operator()(LatchMeta<LatchCounter>&) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16230:12
                #3 0x1b8240e in bool MutexMonitor::iterate<ShowStatus>(ShowStatus&) const /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0mutex.h:149:15
                #4 0x1b8240e in innodb_show_mutex_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long)) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16328:16
                #5 0x1b8240e in innodb_show_latch_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long)) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16450:12
                #6 0x1b8240e in innobase_show_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long), ha_stat_type) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16480:10
                #7 0x11383ed in showstat_handlerton(THD*, st_plugin_int*, void*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:6329:7
                #8 0xaa2ed1 in plugin_foreach_with_mask(THD*, char (*)(THD*, st_plugin_int*, void*), int, unsigned int, void*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:2470:15
                #9 0x1137e3b in ha_show_status(THD*, handlerton*, ha_stat_type) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:6355:13
                #10 0xa72ce5 in mysql_execute_command(THD*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:4168:13
                #11 0xa60279 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:7991:18
                #12 0xa57f2a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:1874:7
                #13 0xa610c6 in do_command(THD*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:1355:17
                #14 0xdd8276 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_connect.cc:1411:11
                #15 0xdd791f in handle_one_connection /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_connect.cc:1313:5
                #16 0x198739a in pfs_spawn_thread /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/pfs.cc:2201:3
                #17 0x7ff37023a608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
                #18 0x7ff36fdc3152 in clone (/lib/x86_64-linux-gnu/libc.so.6+0x122152)
             
            0x7ff366bdba48 is located 8776 bytes inside of 4194328-byte region [0x7ff366bd9800,0x7ff366fd9818)
            allocated by thread T0 here:
                #0 0x782b52 in calloc (/home/buildbot/buildbot/build/mariadb-10.5.4/sql/mariadbd+0x782b52)
                #1 0x1b89efc in ut_allocator<unsigned char, true>::allocate(unsigned long, unsigned char const*, char const*, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0new.h:370:11
                #2 0x1ee9c7f in Pool<trx_t, TrxFactory, TrxPoolLock>::Pool(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:65:40
                #3 0x1ee94b4 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::add_pool(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:320:11
                #4 0x1ee5a97 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::create() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:348:3
                #5 0x1ee5a97 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::PoolManager(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:232:3
                #6 0x1ed9ea7 in trx_pool_init() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/trx/trx0trx.cc:333:14
                #7 0x1e4c287 in srv_boot() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/srv/srv0srv.cc:810:2
                #8 0x1e59b85 in srv_start(bool) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/srv/srv0start.cc:1221:2
                #9 0x1b785a4 in innodb_init(void*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:4005:8
                #10 0x1112c7c in ha_initialize_handlerton(st_plugin_int*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:585:31
                #11 0xa9cae5 in plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:1459:9
                #12 0xa9adbb in plugin_init(int*, char**, int) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:1752:15
                #13 0x7c2edf in init_server_components() /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:4894:7
                #14 0x7bb77f in mysqld_main(int, char**) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5449:7
                #15 0x7ff36fcc80b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
             
            Thread T17 created by T0 here:
                #0 0x76d78a in pthread_create (/home/buildbot/buildbot/build/mariadb-10.5.4/sql/mariadbd+0x76d78a)
                #1 0x198765d in my_thread_create(unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/my_thread.h:34:10
                #2 0x198765d in pfs_spawn_thread_v1 /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/pfs.cc:2252:15
                #3 0x7c5726 in inline_mysql_thread_create(unsigned int, unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /home/buildbot/buildbot/build/mariadb-10.5.4/include/mysql/psi/mysql_thread.h:1321:11
                #4 0x7c5726 in create_thread_to_handle_connection(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5952:19
                #5 0x7c670b in create_new_thread(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6011:3
                #6 0x7c670b in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6076:5
                #7 0x7c448a in handle_connections_sockets() /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6203:9
                #8 0x7bd242 in mysqld_main(int, char**) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5621:3
                #9 0x7ff36fcc80b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
             
            SUMMARY: AddressSanitizer: use-after-poison /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16198:15 in ShowStatus::GetCount::operator()(LatchCounter::Count*)
            Shadow bytes around the buggy address:
              0x0ffeecd736f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              0x0ffeecd73700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              0x0ffeecd73710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              0x0ffeecd73720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              0x0ffeecd73730: 00 00 00 00 00 00 f7 00 00 00 00 00 00 f7 f7 f7
            =>0x0ffeecd73740: f7 f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 f7 f7 f7 f7 f7
              0x0ffeecd73750: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
              0x0ffeecd73760: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
              0x0ffeecd73770: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
              0x0ffeecd73780: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
              0x0ffeecd73790: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
            

            marko Marko Mäkelä added a comment - kvm-asan is not happy : the test main.implicit_commit fails. 10.5 03dcdad251c414f387e074643f8e4187edcf6c02 CURRENT_TEST: main.implicit_commit mysqltest: In included file "./include/implicit_commit_helper.inc": included from /home/buildbot/buildbot/build/mariadb-10.5.4/mysql-test/main/implicit_commit.test at line 221: At line 3: query '$statement' failed: 2013: Lost connection to MySQL server during query … ==87490==ERROR: AddressSanitizer: use-after-poison on address 0x7ff366bdba48 at pc 0x000001b913ca bp 0x7ff35ef749b0 sp 0x7ff35ef749a8 READ of size 4 at 0x7ff366bdba48 thread T17 #0 0x1b913c9 in ShowStatus::GetCount::operator()(LatchCounter::Count*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16198:15 #1 0x1b8240e in void LatchCounter::iterate<ShowStatus::GetCount>(ShowStatus::GetCount&) const /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/sync0types.h:664:4 #2 0x1b8240e in ShowStatus::operator()(LatchMeta<LatchCounter>&) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16230:12 #3 0x1b8240e in bool MutexMonitor::iterate<ShowStatus>(ShowStatus&) const /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0mutex.h:149:15 #4 0x1b8240e in innodb_show_mutex_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long)) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16328:16 #5 0x1b8240e in innodb_show_latch_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long)) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16450:12 #6 0x1b8240e in innobase_show_status(handlerton*, THD*, bool (*)(THD*, char const*, unsigned long, char const*, unsigned long, char const*, unsigned long), ha_stat_type) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16480:10 #7 0x11383ed in showstat_handlerton(THD*, st_plugin_int*, void*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:6329:7 #8 0xaa2ed1 in plugin_foreach_with_mask(THD*, char (*)(THD*, st_plugin_int*, void*), int, unsigned int, void*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:2470:15 #9 0x1137e3b in ha_show_status(THD*, handlerton*, ha_stat_type) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:6355:13 #10 0xa72ce5 in mysql_execute_command(THD*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:4168:13 #11 0xa60279 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:7991:18 #12 0xa57f2a in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:1874:7 #13 0xa610c6 in do_command(THD*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_parse.cc:1355:17 #14 0xdd8276 in do_handle_one_connection(CONNECT*, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_connect.cc:1411:11 #15 0xdd791f in handle_one_connection /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_connect.cc:1313:5 #16 0x198739a in pfs_spawn_thread /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/pfs.cc:2201:3 #17 0x7ff37023a608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608) #18 0x7ff36fdc3152 in clone (/lib/x86_64-linux-gnu/libc.so.6+0x122152)   0x7ff366bdba48 is located 8776 bytes inside of 4194328-byte region [0x7ff366bd9800,0x7ff366fd9818) allocated by thread T0 here: #0 0x782b52 in calloc (/home/buildbot/buildbot/build/mariadb-10.5.4/sql/mariadbd+0x782b52) #1 0x1b89efc in ut_allocator<unsigned char, true>::allocate(unsigned long, unsigned char const*, char const*, bool, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0new.h:370:11 #2 0x1ee9c7f in Pool<trx_t, TrxFactory, TrxPoolLock>::Pool(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:65:40 #3 0x1ee94b4 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::add_pool(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:320:11 #4 0x1ee5a97 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::create() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:348:3 #5 0x1ee5a97 in PoolManager<Pool<trx_t, TrxFactory, TrxPoolLock>, TrxPoolManagerLock>::PoolManager(unsigned long) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/include/ut0pool.h:232:3 #6 0x1ed9ea7 in trx_pool_init() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/trx/trx0trx.cc:333:14 #7 0x1e4c287 in srv_boot() /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/srv/srv0srv.cc:810:2 #8 0x1e59b85 in srv_start(bool) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/srv/srv0start.cc:1221:2 #9 0x1b785a4 in innodb_init(void*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:4005:8 #10 0x1112c7c in ha_initialize_handlerton(st_plugin_int*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/handler.cc:585:31 #11 0xa9cae5 in plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:1459:9 #12 0xa9adbb in plugin_init(int*, char**, int) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/sql_plugin.cc:1752:15 #13 0x7c2edf in init_server_components() /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:4894:7 #14 0x7bb77f in mysqld_main(int, char**) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5449:7 #15 0x7ff36fcc80b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)   Thread T17 created by T0 here: #0 0x76d78a in pthread_create (/home/buildbot/buildbot/build/mariadb-10.5.4/sql/mariadbd+0x76d78a) #1 0x198765d in my_thread_create(unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/my_thread.h:34:10 #2 0x198765d in pfs_spawn_thread_v1 /home/buildbot/buildbot/build/mariadb-10.5.4/storage/perfschema/pfs.cc:2252:15 #3 0x7c5726 in inline_mysql_thread_create(unsigned int, unsigned long*, pthread_attr_t const*, void* (*)(void*), void*) /home/buildbot/buildbot/build/mariadb-10.5.4/include/mysql/psi/mysql_thread.h:1321:11 #4 0x7c5726 in create_thread_to_handle_connection(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5952:19 #5 0x7c670b in create_new_thread(CONNECT*) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6011:3 #6 0x7c670b in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6076:5 #7 0x7c448a in handle_connections_sockets() /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:6203:9 #8 0x7bd242 in mysqld_main(int, char**) /home/buildbot/buildbot/build/mariadb-10.5.4/sql/mysqld.cc:5621:3 #9 0x7ff36fcc80b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)   SUMMARY: AddressSanitizer: use-after-poison /home/buildbot/buildbot/build/mariadb-10.5.4/storage/innobase/handler/ha_innodb.cc:16198:15 in ShowStatus::GetCount::operator()(LatchCounter::Count*) Shadow bytes around the buggy address: 0x0ffeecd736f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ffeecd73700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ffeecd73710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ffeecd73720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ffeecd73730: 00 00 00 00 00 00 f7 00 00 00 00 00 00 f7 f7 f7 =>0x0ffeecd73740: f7 f7 f7 f7 f7 f7 f7 f7 f7[f7]f7 f7 f7 f7 f7 f7 0x0ffeecd73750: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 0x0ffeecd73760: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 0x0ffeecd73770: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 0x0ffeecd73780: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 0x0ffeecd73790: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
            marko Marko Mäkelä added a comment - The omission in ASAN and Valgrind instrumentation was fixed.

            People

              svoj Sergey Vojtovich
              svoj Sergey Vojtovich
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.