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

safe_mutex: Found wrong usage of mutex 'LOCK_thd_data' and 'LOCK_plugin'

Details

    Description

      Issue initially observed during testing of MDEV-28856, but present in trunk also:

      preview-11.3-preview a4031e4c051d4fc69f466a5678ceb5d3598bf525 (Debug)

      safe_mutex: Found wrong usage of mutex 'LOCK_thd_data' and 'LOCK_plugin'
      Mutex currently locked (in reverse order):
      LOCK_plugin                       /test/git-bisect/preview-11.3-preview_MDEV-28856_patched_dbg/sql/sql_plugin.cc  line 2481
      LOCK_thd_data                     /test/git-bisect/preview-11.3-preview_MDEV-28856_patched_dbg/sql/sql_class.h  line 3967
      LOCK_thd_kill                     /test/git-bisect/preview-11.3-preview_MDEV-28856_patched_dbg/sql/sql_class.h  line 3966
      

      The issue can be seen either during normal operation, or during SHUTDOWN. Possibly these are different issues leading to the same outcome.
      The issues is highly sporadic, yet regularly seen. Testcase reduction has proven to be very difficult. However, a single occurrence reduced to this SHUTDOWN-based testcase:

      INSTALL PLUGIN spider SONAME 'ha_spider.so';
      CREATE TABLE t (c INT) ENGINE=Spider;
      SET max_session_mem_used=8192;
      UNINSTALL SONAME 'ha_spider';
      SHUTDOWN;
      

      This testcase may not be representative of all issues and should not be taken as a typical example, as this issue is during SHUTDOWN and reduced readily compared with the other sporadic occurrences, which do not reduce. Still, it may provide an indication in the code as to the actual bug(s).

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar added a comment - - edited

            Please also note MDEV-33443, on LOCK_thd_kill

            Roel Roel Van de Paar added a comment - - edited Please also note MDEV-33443 , on LOCK_thd_kill
            Roel Roel Van de Paar added a comment - - edited

            Issue is still reproducible in 11.4 debug build 6 Feb 24.

            11.4.0 9b1ea6904965dd345478dedd80e181ad54c767da (Debug)

            11.4.0-dbg>SET @@max_session_mem_used=500000;  # Set smaller if needed
            Query OK, 0 rows affected (0.000 sec)
             
            11.4.0-dbg>SET @@session.query_alloc_block_size=655536;
            Query OK, 0 rows affected, 1 warning (0.001 sec)
             
            11.4.0-dbg>UNINSTALL PLUGIN IF EXISTS example;
            Query OK, 0 rows affected, 1 warning (0.002 sec)
             
            11.4.0-dbg>SHUTDOWN;
            Query OK, 0 rows affected (0.000 sec)
             
            11.4.0-dbg>Ctrl-C -- exit!
            Aborted
            /test/MD060224-mariadb-11.4.0-linux-x86_64-dbg$ t
            MUTEX_ERROR|safe_mutex: Found wrong usage of mutex LOCK_thd_data and LOCK_plugin
            

            Roel Roel Van de Paar added a comment - - edited Issue is still reproducible in 11.4 debug build 6 Feb 24. 11.4.0 9b1ea6904965dd345478dedd80e181ad54c767da (Debug) 11.4.0-dbg>SET @@max_session_mem_used=500000; # Set smaller if needed Query OK, 0 rows affected (0.000 sec)   11.4.0-dbg>SET @@session.query_alloc_block_size=655536; Query OK, 0 rows affected, 1 warning (0.001 sec)   11.4.0-dbg>UNINSTALL PLUGIN IF EXISTS example; Query OK, 0 rows affected, 1 warning (0.002 sec)   11.4.0-dbg>SHUTDOWN; Query OK, 0 rows affected (0.000 sec)   11.4.0-dbg>Ctrl-C -- exit! Aborted /test/MD060224-mariadb-11.4.0-linux-x86_64-dbg$ t MUTEX_ERROR|safe_mutex: Found wrong usage of mutex LOCK_thd_data and LOCK_plugin

            Original testcase also reproduces for me in MTR:

            INSTALL PLUGIN spider SONAME 'ha_spider.so';
            CREATE TABLE t (c INT) ENGINE=Spider;
            SET max_session_mem_used=8192;
            --error ER_SP_DOES_NOT_EXIST
            UNINSTALL SONAME 'ha_spider';
            SHUTDOWN;
            

            Leads to:

            11.4.0 9b1ea6904965dd345478dedd80e181ad54c767da (Debug)

            2024-02-12 13:50:52 0 [Note] /test/MD060224-mariadb-11.4.0-linux-x86_64-dbg/bin/mariadbd (initiated by: root[root] @ localhost []): Normal shutdown
            safe_mutex: Found wrong usage of mutex 'LOCK_thd_data' and 'LOCK_plugin'
            Mutex currently locked (in reverse order):
            LOCK_plugin                       /test/11.4_dbg/sql/sql_plugin.cc  line 2525
            LOCK_thd_data                     /test/11.4_dbg/sql/sql_class.h  line 4053
            LOCK_thd_kill                     /test/11.4_dbg/sql/sql_class.h  line 4052
            

            Roel Roel Van de Paar added a comment - Original testcase also reproduces for me in MTR: INSTALL PLUGIN spider SONAME 'ha_spider.so' ; CREATE TABLE t (c INT ) ENGINE=Spider; SET max_session_mem_used=8192; --error ER_SP_DOES_NOT_EXIST UNINSTALL SONAME 'ha_spider' ; SHUTDOWN; Leads to: 11.4.0 9b1ea6904965dd345478dedd80e181ad54c767da (Debug) 2024-02-12 13:50:52 0 [Note] /test/MD060224-mariadb-11.4.0-linux-x86_64-dbg/bin/mariadbd (initiated by: root[root] @ localhost []): Normal shutdown safe_mutex: Found wrong usage of mutex 'LOCK_thd_data' and 'LOCK_plugin' Mutex currently locked (in reverse order): LOCK_plugin /test/11.4_dbg/sql/sql_plugin.cc line 2525 LOCK_thd_data /test/11.4_dbg/sql/sql_class.h line 4053 LOCK_thd_kill /test/11.4_dbg/sql/sql_class.h line 4052

            Assigning to knielsen for closure as he mentioned this bug would be fixed by the patch for MDEV-33443 as well.

            Roel Roel Van de Paar added a comment - Assigning to knielsen for closure as he mentioned this bug would be fixed by the patch for MDEV-33443 as well.

            Duplicate of MDEV-33443

            knielsen Kristian Nielsen added a comment - Duplicate of MDEV-33443

            People

              knielsen Kristian Nielsen
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.