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

Killed query reports ER_NOT_FORM_FILE for a table with virtual column expressions

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3
    • 10.11, 11.4, 11.8, 12.3
    • Server
    • None
    • Can result in unexpected behaviour

    Description

      Reproduce

      --source include/have_debug_sync.inc
       
      create table t1 (a int, b int as (a + 1) virtual);
      insert into t1 (a) values (1);
      flush tables;
       
      connect con1, localhost, root;
      let $con1_id= `select connection_id()`;
      set debug_sync= 'TABLE_after_field_clone signal opening wait_for go';
      send select * from t1;
       
      connection default;
      set debug_sync= 'now wait_for opening';
      --replace_result $con1_id CON1_ID
      eval kill query $con1_id;
       
      connection con1;
      --error ER_QUERY_INTERRUPTED
      reap;
      show warnings;
       
      disconnect con1;
      connection default;
      set debug_sync= 'reset';
      drop table t1;
      

      Result

      ERROR 70100: Query execution was interrupted
      show warnings;
      Level	Code	Message
      Error	1317	Query execution was interrupted
      Error	1065	Query was empty
      Error	1033	Incorrect information in file: './test/t1.frm'
      

      Expected

      ERROR 70100: Query execution was interrupted
      show warnings;
      Level	Code	Message
      Error	1317	Query execution was interrupted
      Error	1065	Query was empty
      

      The .frm is not corrupted: the query was killed while the table was being opened. ER_NOT_FORM_FILE must not be reported.

      Notes

      Expressions of virtual columns, DEFAULT and CHECK constraints are parsed from the .frm each time a new TABLE instance is created: open_table_from_share() calls parse_vcol_defs(), which calls unpack_vcol_info_from_frm(), which calls parse_sql(). Lex_input_stream::lex_one_token() checks thd->killed on each token, calls send_kill_message() and returns END_OF_INPUT, so the parse fails. unpack_vcol_info_from_frm() does not set *error_reported when parse_sql() fails, so open_table_from_share() sets OPEN_FRM_CORRUPTED and open_table_error() raises ER_NOT_FORM_FILE.

      The main error stays the kill error, ER_NOT_FORM_FILE is an extra condition. In replication it gets into Last_SQL_Error and the error log via aggregate_da_errors() when a parallel slave worker is killed (STOP SLAVE, KILL, shutdown) while opening a table.

      The same code is in 10.6, 10.11, 11.8, 12.3 and main.

      Suspected, not reproduced: if the kill comes between tokens where the already read part is a valid expression (e.g. after `a` in `a` + 1), the grammar accepts END_OF_INPUT and parse_sql() succeeds, because the kill error is not fatal. The TABLE is then opened with a truncated expression and may be returned to the table cache.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              midenok Aleksey Midenkov
              Aleksey Midenkov Aleksey Midenkov
              Oleksandr Byelkin Oleksandr Byelkin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Time Spent - 1d Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - 1d Remaining Estimate - 1h
                  1d

                  Git Integration

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