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

Deadlock in CREATE TABLE ... AS SELECT .. if result set is empty in Galera

    XMLWordPrintable

Details

    Description

      If I execute a CREATE TABLE ... AS SELECT ... on a Galera Cluster node, and the result set of the query is empty, then the query will deadlock.

      Let's say that we have the following table on a Galera Cluster node:

      CREATE TABLE test_tab (
      	id integer primary key,
      	data varchar(25)
      );
       
      INSERT INTO test_tab VALUES (4, 'name 33'),
      	(7, 'name 33'),
      	(13, 'name 33'),
      	(16, 'name 33'),
      	(19, 'name 33');
      

      The following query works just fine:

      MariaDB [db1]> SELECT * FROM test_tab WHERE id=4;
      +----+---------+
      | id | data    |
      +----+---------+
      |  4 | name 33 |
      +----+---------+
      1 row in set (0.00 sec)
       
      MariaDB [db1]> CREATE TABLE test_clone1 AS SELECT * FROM test_tab WHERE id=4;
      Query OK, 1 row affected (0.01 sec)
      Records: 1  Duplicates: 0  Warnings: 0
      

      But this query deadlocks:

      MariaDB [db1]> SELECT * FROM test_tab WHERE id=2;
      Empty set (0.00 sec)
       
      MariaDB [db1]> CREATE TABLE test_clone2 AS SELECT * FROM test_tab WHERE id=2;
      ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
      

      Galera version:

      MariaDB [db1]> show global status like 'wsrep_provider_version';
      +------------------------+----------------+
      | Variable_name          | Value          |
      +------------------------+----------------+
      | wsrep_provider_version | 25.3.15(r3578) |
      +------------------------+----------------+
      1 row in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              nirbhay_c Nirbhay Choubey (Inactive)
              GeoffMontee Geoff Montee (Inactive)
              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.