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

Data race in ib_counter_t

    XMLWordPrintable

    Details

      Description

      Make `m_counter` accesses relaxed atomical. This will fix data race. Precision is not relevant here by design.

      Data race looks like this:

      WARNING: ThreadSanitizer: data race (pid=12638)
        Write of size 8 at 0x000003917c88 by thread T19:
          #0 ib_counter_t<long, 64, counter_indexer_t>::add(unsigned long, long) /work/mariadb/storage/innobase/include/ut0counter.h:132:16 (mysqld+0x18cb656)
          #1 ib_counter_t<long, 64, counter_indexer_t>::add(long) /work/mariadb/storage/innobase/include/ut0counter.h:122:34 (mysqld+0x18ca9b2)
          #2 rw_lock_x_lock_wait_func(rw_lock_t*, unsigned long, long, char const*, unsigned int) /work/mariadb/storage/innobase/sync/sync0rw.cc:484:38 (mysqld+0x18ca29d)
          #3 rw_lock_x_lock_low(rw_lock_t*, unsigned long, char const*, unsigned int) /work/mariadb/storage/innobase/sync/sync0rw.cc:533:3 (mysqld+0x18c81f9)
          #4 rw_lock_x_lock_func(rw_lock_t*, unsigned long, char const*, unsigned int) /work/mariadb/storage/innobase/sync/sync0rw.cc:693:6 (mysqld+0x18c7b49)
          #5 pfs_rw_lock_x_lock_func(rw_lock_t*, unsigned long, char const*, unsigned int) /work/mariadb/storage/innobase/include/sync0rw.ic:567:3 (mysqld+0x1a45f64)
          #6 buf_page_get_gen(page_id_t const&, page_size_t const&, unsigned long, buf_block_t*, unsigned long, char const*, unsigned int, mtr_t*, dberr_t*) /work/mariadb/storage/innobase/buf/buf0buf.cc:5000:3 (mysqld+0x1a4ebb0)
          #7 btr_cur_search_to_nth_level_func(dict_index_t*, unsigned long, dtuple_t const*, page_cur_mode_t, unsigned long, btr_cur_t*, rw_lock_t*, char const*, unsigned int, mtr_t*, unsigned long) /work/mariadb/storage/innobase/btr/btr0cur.cc:1407:10 (mysqld+0x19c69dc)
          #8 btr_pcur_open_low(dict_index_t*, unsigned long, dtuple_t const*, page_cur_mode_t, unsigned long, btr_pcur_t*, char const*, unsigned int, unsigned long, mtr_t*) /work/mariadb/storage/innobase/include/btr0pcur.ic:459:8 (mysqld+0x181192e)
          #9 row_search_on_row_ref(btr_pcur_t*, unsigned long, dict_table_t const*, dtuple_t const*, mtr_t*) /work/mariadb/storage/innobase/row/row0row.cc:1053:3 (mysqld+0x1810e1e)
          #10 row_purge_reposition_pcur(unsigned long, purge_node_t*, mtr_t*) /work/mariadb/storage/innobase/row/row0purge.cc:103:23 (mysqld+0x17f9dcf)
          #11 row_purge_reset_trx_id(purge_node_t*, mtr_t*) /work/mariadb/storage/innobase/row/row0purge.cc:813:6 (mysqld+0x17feed0)
          #12 row_purge_record_func(purge_node_t*, unsigned char*, que_thr_t const*, bool) /work/mariadb/storage/innobase/row/row0purge.cc:1196:4 (mysqld+0x17fd882)
          #13 row_purge(purge_node_t*, unsigned char*, que_thr_t*) /work/mariadb/storage/innobase/row/row0purge.cc:1245:18 (mysqld+0x17faa04)
          #14 row_purge_step(que_thr_t*) /work/mariadb/storage/innobase/row/row0purge.cc:1331:3 (mysqld+0x17fa67c)
          #15 que_thr_step(que_thr_t*) /work/mariadb/storage/innobase/que/que0que.cc:1046:9 (mysqld+0x16f7cff)
          #16 que_run_threads_low(que_thr_t*) /work/mariadb/storage/innobase/que/que0que.cc:1108:14 (mysqld+0x16f600e)
          #17 que_run_threads(que_thr_t*) /work/mariadb/storage/innobase/que/que0que.cc:1148:2 (mysqld+0x16f5bb8)
          #18 trx_purge(unsigned long, bool) /work/mariadb/storage/innobase/trx/trx0purge.cc:1614:2 (mysqld+0x18ffa06)
          #19 srv_do_purge(unsigned long*) /work/mariadb/storage/innobase/srv/srv0srv.cc:2596:20 (mysqld+0x18a733a)
          #20 srv_purge_coordinator_thread /work/mariadb/storage/innobase/srv/srv0srv.cc:2721:22 (mysqld+0x18a663b)
       
        Previous write of size 8 at 0x000003917c88 by main thread:
          #0 ib_counter_t<long, 64, counter_indexer_t>::add(unsigned long, long) /work/mariadb/storage/innobase/include/ut0counter.h:132:16 (mysqld+0x18cb656)
          #1 ib_counter_t<long, 64, counter_indexer_t>::add(long) /work/mariadb/storage/innobase/include/ut0counter.h:122:34 (mysqld+0x18ca9b2)
          #2 rw_lock_x_lock_func(rw_lock_t*, unsigned long, char const*, unsigned int) /work/mariadb/storage/innobase/sync/sync0rw.cc:701:39 (mysqld+0x18c7bcd)
          #3 pfs_rw_lock_x_lock_func(rw_lock_t*, unsigned long, char const*, unsigned int) /work/mariadb/storage/innobase/include/sync0rw.ic:567:3 (mysqld+0x1a45f64)
          #4 buf_page_init_for_read(dberr_t*, unsigned long, page_id_t const&, page_size_t const&, bool) /work/mariadb/storage/innobase/buf/buf0buf.cc:5563:3 (mysqld+0x1a554ce)
          #5 buf_read_page_low(dberr_t*, bool, unsigned long, unsigned long, page_id_t const&, page_size_t const&, bool, bool) /work/mariadb/storage/innobase/buf/buf0rea.cc:152:10 (mysqld+0x1abadc9)
          #6 buf_read_page(page_id_t const&, page_size_t const&) /work/mariadb/storage/innobase/buf/buf0rea.cc:434:10 (mysqld+0x1abb733)
          #7 buf_page_get_gen(page_id_t const&, page_size_t const&, unsigned long, buf_block_t*, unsigned long, char const*, unsigned int, mtr_t*, dberr_t*) /work/mariadb/storage/innobase/buf/buf0buf.cc:4518:23 (mysqld+0x1a4bf3d)
          #8 btr_cur_open_at_index_side_func(bool, dict_index_t*, unsigned long, btr_cur_t*, unsigned long, char const*, unsigned int, mtr_t*) /work/mariadb/storage/innobase/btr/btr0cur.cc:2458:11 (mysqld+0x19d0e44)
          #9 btr_pcur_open_at_index_side(bool, dict_index_t*, unsigned long, btr_pcur_t*, bool, unsigned long, mtr_t*) /work/mariadb/storage/innobase/include/btr0pcur.ic:563:8 (mysqld+0x15b9b1c)
          #10 ibuf_update_max_tablespace_id() /work/mariadb/storage/innobase/ibuf/ibuf0ibuf.cc:3169:2 (mysqld+0x15b95de)
          #11 srv_start(bool) /work/mariadb/storage/innobase/srv/srv0start.cc:2509:3 (mysqld+0x18b5539)
          #12 innodb_init(void*) /work/mariadb/storage/innobase/handler/ha_innodb.cc:4252:8 (mysqld+0x14eda4c)
          #13 ha_initialize_handlerton(st_plugin_int*) /work/mariadb/sql/handler.cc:522:31 (mysqld+0x1010b99)
          #14 plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) /work/mariadb/sql/sql_plugin.cc:1432:9 (mysqld+0x9b005d)
          #15 plugin_init(int*, char**, int) /work/mariadb/sql/sql_plugin.cc:1714:15 (mysqld+0x9af4c3)
          #16 init_server_components() /work/mariadb/sql/mysqld.cc:5375:7 (mysqld+0x6f1209)
          #17 mysqld_main(int, char**) /work/mariadb/sql/mysqld.cc:5987:7 (mysqld+0x6eae63)
          #18 main /work/mariadb/sql/main.cc:25:10 (mysqld+0x6e37eb)
       
      Location is global 'rw_lock_stats' of size 38016 at 0x000003912c40 (mysqld+0x000003917c88)
      

        Attachments

          Activity

            People

            Assignee:
            kevg Eugene Kosov
            Reporter:
            kevg Eugene Kosov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: