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

DEBUG_SYNC does not reset mysys_var->current_mutex, causes assertion "Trying to unlock mutex that wasn't locked"

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.13
    • 10.0.16
    • Tests
    • None

    Description

      https://buildbot.askmonty.org/buildbot/builders/work-amd64-valgrind/builds/5937

      rpl_parallel.test asserts with the following stack trace:

      safe_mutex: Trying to unlock mutex LOCK_wait_commit that wasn't locked at /var/lib/buildbot/maria-slave/work-opensuse-amd64/build/sql/sql_class.cc, line 1817
      Last used at /var/lib/buildbot/maria-slave/work-opensuse-amd64/build/sql/log.cc, line: 6791
       
      mysys/thr_mutex.c:424(safe_mutex_unlock)[0xe1c6f6]
      sql/sql_class.cc:1817(THD::awake(killed_state))[0x5b88af]
      psi/mysql_thread.h:756(inline_mysql_mutex_unlock)[0x5e59e9]
      sql/sql_parse.cc:7453(sql_kill)[0x5e5a52]
      sql/sql_parse.cc:4313(mysql_execute_command(THD*))[0x5e9203]
      sql/sql_parse.cc:6411(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x5ebf5a]
      sql/sql_parse.cc:1309(dispatch_command(enum_server_command, THD*, char*, unsigned int))[0x5ed96c]
      sql/sql_parse.cc:1005(do_command(THD*))[0x5ef152]
      sql/sql_connect.cc:1379(do_handle_one_connection(THD*))[0x6dd5ff]
      sql/sql_connect.cc:1295(handle_one_connection)[0x6dd725]

      I think I have seen similar failures before. I guess it happens because
      mysys_var->current_mutex changes while THD::awake() is trying to kill a
      thread. IIRC, this is related to incorrect use of ENTER_COND and EXIT_COND
      (eg. missing exit or something like that).

      I also think that in THD::awake, we should take a local copy of
      mysys_var->current_mutex, we really don't want to reload the value when we
      unlock the mutex.

      But we could add a debug assertion that the value does not change, to try and
      catch more of these problems (incorrect usage of ENTER_COND/EXIT_COND).

      Attachments

        Issue Links

          Activity

            People

              knielsen Kristian Nielsen
              knielsen Kristian Nielsen
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.