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

Query doesn't return on one node until restart mariadb

    XMLWordPrintable

Details

    Description

      I noticed yesterday that a query was not returning and assumed I had done something wrong but noticed that the same query returned fine on the other database nodes. I restarted the bad node and thought no more about it. Today two nodes have that issue (I have 3) I restarted one of them and it returns the query fine. 0.7s, the one I didn't restart it still working on that query 1000 seconds later. This time, whilst I have it in that state I did an explain and the result is indeed different on the bad node but matches on the good node. I didn't notice the issue before v16.

      Good nodes:
      '{
      "query_block": {
      "select_id": 1,
      "filesort": {
      "sort_key": "p.replen_id, p.consumer_id",
      "temporary_table": {
      "nested_loop": [
      {
      "table":

      { "table_name": "p", "access_type": "ALL", "rows": 31225, "filtered": 100 }

      },
      {
      "table":

      { "table_name": "p", "access_type": "ref", "possible_keys": [ "PRIMARY", "idx_current", "fk_product_master_lifecycle" ], "key": "PRIMARY", "key_length": "42", "used_key_parts": ["product_code"], "ref": ["func"], "rows": 1, "filtered": 100, "attached_condition": "convert(p.product_code using utf8mb4) = p.product_code and p.lifecycle_id is not null" }

      },
      {
      "table":

      { "table_name": "pg", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["id"], "ref": ["sales_report.p.product_group_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(p.product_group_id is not null))" }

      },
      {
      "table":

      { "table_name": "cg", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["id"], "ref": ["sales_report.pg.commodity_group_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(pg.commodity_group_id is not null))" }

      },
      {
      "table":

      { "table_name": "l", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["id"], "ref": ["range_management.p.lifecycle_id"], "rows": 1, "filtered": 100 }

      },
      {
      "table":

      { "table_name": "pm", "access_type": "eq_ref", "possible_keys": ["PRIMARY", "idx_current"], "key": "PRIMARY", "key_length": "45", "used_key_parts": ["product_code", "valid_from"], "ref": ["func", "range_management.p.valid_from"], "rows": 1, "filtered": 100, "attached_condition": "convert(p.product_code using utf8mb4) = pm.product_code" }

      },
      {
      "table":

      { "table_name": "l", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["id"], "ref": ["range_management.pm.lifecycle_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(pm.lifecycle_id is not null))" }

      },
      {
      "table":

      { "table_name": "pt", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["id"], "ref": ["sales_report.cg.product_type_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(cg.product_type_id is not null))" }

      },
      {
      "table": {
      "table_name": "<derived2>",
      "access_type": "ref",
      "possible_keys": ["key1"],
      "key": "key1",
      "key_length": "45",
      "used_key_parts": ["product_code", "valid_from"],
      "ref": [
      "range_management.pm.product_code",
      "range_management.p.valid_from"
      ],
      "rows": 10,
      "filtered": 100,
      "materialized": {
      "query_block": {
      "select_id": 2,
      "nested_loop": [
      {
      "read_sorted_file": {
      "filesort": {
      "sort_key": "pm.product_code, pm.valid_from, pm.valid_to",
      "table":

      { "table_name": "pm", "access_type": "index", "possible_keys": ["PRIMARY", "idx_current"], "key": "idx_current", "key_length": "45", "used_key_parts": ["product_code", "valid_to"], "rows": 21370, "filtered": 100, "attached_condition": "<cache>(curdate()) between pm.valid_from and pm.valid_to", "using_index": true }

      }
      }
      },
      {
      "table":

      { "table_name": "pma", "access_type": "ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "45", "used_key_parts": ["product_code", "valid_from"], "ref": [ "range_management.pm.product_code", "range_management.pm.valid_from" ], "rows": 1, "filtered": 100 }

      },
      {
      "table":

      { "table_name": "a", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["attr_id"], "ref": ["range_management.pma.attr_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(pma.attr_id is not null))" }

      }
      ]
      }
      }
      }
      }
      ]
      }
      }
      }
      }'

      Bad node:

      {
      "query_block": {
      "select_id": 1,
      "filesort": {
      "sort_key": "range_management.p.replen_id, range_management.p.consumer_id",
      "temporary_table": {
      "nested_loop": [
      {
      "table":

      { "table_name": "pm", "access_type": "index", "possible_keys": ["PRIMARY", "idx_current"], "key": "fk_product_master_lifecycle", "key_length": "5", "used_key_parts": ["lifecycle_id"], "rows": 21924, "filtered": 100, "using_index": true }

      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "<derived2>", "access_type": "ALL", "rows": 21924, "filtered": 0 }

      ,
      "buffer_type": "flat",
      "buffer_size": "1113Kb",
      "join_type": "BNL",
      "attached_condition": "a.product_code = range_management.pm.product_code and a.valid_from = range_management.pm.valid_from",
      "materialized": {
      "query_block": {
      "select_id": 2,
      "nested_loop": [
      {
      "read_sorted_file": {
      "filesort": {
      "sort_key": "range_management.pm.product_code, range_management.pm.valid_from, range_management.pm.valid_to",
      "table":

      { "table_name": "pm", "access_type": "index", "possible_keys": ["PRIMARY", "idx_current"], "key": "idx_current", "key_length": "45", "used_key_parts": ["product_code", "valid_to"], "rows": 21924, "filtered": 100, "attached_condition": "<cache>(curdate()) between range_management.pm.valid_from and range_management.pm.valid_to", "using_index": true }

      }
      }
      },
      {
      "table":

      { "table_name": "pma", "access_type": "ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "45", "used_key_parts": ["product_code", "valid_from"], "ref": [ "range_management.pm.product_code", "range_management.pm.valid_from" ], "rows": 1, "filtered": 100 }

      },
      {
      "table":

      { "table_name": "a", "access_type": "eq_ref", "possible_keys": ["PRIMARY"], "key": "PRIMARY", "key_length": "4", "used_key_parts": ["attr_id"], "ref": ["range_management.pma.attr_id"], "rows": 1, "filtered": 100, "attached_condition": "trigcond(trigcond(range_management.pma.attr_id is not null))" }

      }
      ]
      }
      }
      }
      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "l", "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 11, "filtered": 100 }

      ,
      "buffer_type": "incremental",
      "buffer_size": "853",
      "join_type": "BNL"
      }
      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "l", "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 11, "filtered": 100 }

      ,
      "buffer_type": "incremental",
      "buffer_size": "2Kb",
      "join_type": "BNL",
      "attached_condition": "trigcond(range_management.l.`id` = range_management.pm.lifecycle_id)"
      }
      },
      {
      "table":

      { "table_name": "p", "access_type": "ref", "possible_keys": [ "PRIMARY", "idx_current", "fk_product_master_lifecycle" ], "key": "fk_product_master_lifecycle", "key_length": "5", "used_key_parts": ["lifecycle_id"], "ref": ["range_management.l.id"], "rows": 2739, "filtered": 100, "index_condition": "range_management.p.valid_from = range_management.pm.valid_from" }

      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "p", "access_type": "ALL", "rows": 29078, "filtered": 100 }

      ,
      "buffer_type": "flat",
      "buffer_size": "5Kb",
      "join_type": "BNL",
      "attached_condition": "convert(p.product_code using utf8mb4) = range_management.pm.product_code and convert(p.product_code using utf8mb4) = range_management.p.product_code"
      }
      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "pg", "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 276, "filtered": 100 }

      ,
      "buffer_type": "incremental",
      "buffer_size": "1Kb",
      "join_type": "BNL",
      "attached_condition": "trigcond(pg.`id` = p.product_group_id)"
      }
      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "cg", "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 72, "filtered": 100 }

      ,
      "buffer_type": "incremental",
      "buffer_size": "1Kb",
      "join_type": "BNL",
      "attached_condition": "trigcond(cg.`id` = pg.commodity_group_id)"
      }
      },
      {
      "block-nl-join": {
      "table":

      { "table_name": "pt", "access_type": "ALL", "possible_keys": ["PRIMARY"], "rows": 5, "filtered": 100 }

      ,
      "buffer_type": "incremental",
      "buffer_size": "866",
      "join_type": "BNL",
      "attached_condition": "trigcond(pt.`id` = cg.product_type_id)"
      }
      }
      ]
      }
      }
      }
      }

      Query:
      SELECT p.product_code,
      p.description description,
      p.product_type_long_name,
      p.product_type,
      p.consumer_id,
      p.replen_id,
      p.approved,
      p.lifecycle AS status,
      pm.lifecycle_id,
      l.colour AS status_colour,
      p.valid_from,
      p.sell_item,
      CONCAT(commodity_group_name,' - ',product_group_name) AS product_group,
      a.attrs
      FROM range_management.v_product_attrs a
      JOIN range_management.product_master_view p
      ON p.product_code = a.product_code
      AND p.valid_from = a.valid_from
      JOIN range_management.product_master pm
      ON pm.product_code = a.product_code
      AND pm.valid_from = a.valid_from
      LEFT JOIN range_management.lifecycle l
      ON l.id = pm.lifecycle_id
      ORDER BY p.replen_id, p.consumer_id

      Attachments

        Activity

          People

            Unassigned Unassigned
            DrJaymz James Cross
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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