← Back to team overview

maria-developers team mailing list archive

Re: 0dd0bbe54e1: MDEV-14836: Assertion `m_status == DA_ERROR' failed in

 

Hi, Rucha!

On Jul 22, Rucha Deodhar wrote:
> revision-id: 0dd0bbe54e1 (mariadb-10.2.31-307-g0dd0bbe54e1)
> parent(s): 0994af43e58
> author: Rucha Deodhar <rucha.deodhar@xxxxxxxxxxx>
> committer: Rucha Deodhar <rucha.deodhar@xxxxxxxxxxx>
> timestamp: 2020-07-16 22:29:06 +0530
> message:
> 
> MDEV-14836: Assertion `m_status == DA_ERROR' failed in
> Diagnostics_area::sql_errno upon query from I_S with LIMIT ROWS EXAMINED
> 
> Query is aborted because number of examined rows exceeds LIMIT EXAMINED ROWS.
> Even though this is not a real error, open_normal_and_derived_tables()
> returns true. As a result, thd->is_errno() is called and thus the assertion
> failure.
> 
> diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
> index 2d404aff6bc..7644ff4e7a2 100644
> --- a/mysql-test/r/information_schema.result
> +++ b/mysql-test/r/information_schema.result
> @@ -2184,3 +2184,16 @@ SCHEMA_NAME
>  #
>  # End of 10.1 tests
>  #
> +#
> +# Start of 10.2 Test
> +#
> +# MDEV-14836: Assertion `m_status == DA_ERROR' failed in
> +# Diagnostics_area::sql_errno upon query from I_S with LIMIT ROWS EXAMINED
> +#
> +SELECT * FROM INFORMATION_SCHEMA.`COLUMNS` LIMIT ROWS EXAMINED 10;
> +TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	DATETIME_PRECISION	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT	IS_GENERATED	GENERATION_EXPRESSION
> +Warnings:
> +Warning	1931	Query execution was interrupted. The query examined at least 666 rows, which exceeds LIMIT ROWS EXAMINED (10). The query result may be incomplete

I don't understand why there are no rows in the output here?
It has examined quite a lot of rows, I would expect a truncated
result, but not a completely empty one.

Could you check that out, please?

> diff --git a/sql/sql_base.cc b/sql/sql_base.cc
> index 436f753557e..8f1c0ebab29 100644
> --- a/sql/sql_base.cc
> +++ b/sql/sql_base.cc
> @@ -1590,6 +1590,12 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
>    if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed)
>    {
>      thd->send_kill_message();
> +    /*
> +       Query was only aborted, but this is not an actual error.
> +       So return false.
> +    */
> +    if (thd->killed == ABORT_QUERY)
> +      DBUG_RETURN(FALSE);
>      DBUG_RETURN(TRUE);

This looks somewhat risky. open_table() returns TRUE on error and FALSE
on success. You here make it to return FALSE even if the table wasn't
opened. I am not sure the caller will always be able to handle that.

On the other hand, normally all tables are opened first, and then the
server starts reading the data. It's only in I_S the server opens tables
one by one.

So get_all_tables() could be the only possibility for ABORT_QUERY to
happen before open_table(). In that case it is safer to add a check for
thd->killed into get_all_tables(). Could you try that approach instead?

Also, note, don't compare thd->killed with ABORT_QUERY, use
thd->killed_errno() method instead.

>    }
>  
> diff --git a/sql/sql_show.cc b/sql/sql_show.cc
> index 18b7e92bca5..9f834ee118b 100644
> --- a/sql/sql_show.cc
> +++ b/sql/sql_show.cc
> @@ -5622,6 +5622,16 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
>      }
>      DBUG_RETURN(res);
>    }
> +  /*
> +    Query was aborted. This could be because of number of
> +    examined rows exceeded LIMIT ROWS EXAMINED. But don't
> +    issue warning here. It is done later, in handle_select().
> +  */
> +  if(thd->killed == ABORT_QUERY)
> +  {
> +    res= 0;
> +    DBUG_RETURN(res);
> +  }
>  
>    show_table= tables->table;
>    count= 0;
> 
Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx