← Back to team overview

maria-developers team mailing list archive

Re: 308c28e8a60: MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.

 

Hi, Alexey!

On Mar 21, Alexey Botchkov wrote:
> revision-id: 308c28e8a60 (mariadb-10.5.2-393-g308c28e8a60)
> parent(s): 786bc312b85
> author: Alexey Botchkov <holyfoot@xxxxxxxxxxx>
> committer: Alexey Botchkov <holyfoot@xxxxxxxxxxx>
> timestamp: 2021-02-09 00:59:55 +0400
> message:
> 
> MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
> 
> Kind of 'naive' solution that surprisingly worked so trying to
> understand why.
> 
> diff --git a/mysql-test/main/flush-innodb.result b/mysql-test/main/flush-innodb.result
> index 21e5bda7785..2c886e4f9fc 100644
> --- a/mysql-test/main/flush-innodb.result
> +++ b/mysql-test/main/flush-innodb.result
> @@ -60,7 +60,7 @@ DROP TABLE export;
>  CREATE VIEW v1 AS SELECT 1;
>  CREATE TEMPORARY TABLE t1 (a INT);
>  FLUSH TABLES v1 FOR EXPORT;
> -ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
> +UNLOCK TABLES;

good, but it only tests that there's no error.
may be you need to add tests to verify that tables are actually
locked?

>  FLUSH TABLES t1 FOR EXPORT;
>  ERROR 42S02: Table 'test.t1' doesn't exist
>  FLUSH TABLES non_existent FOR EXPORT;
> diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
> index 8f87d633d19..c146b7693c1 100644
> --- a/sql/sql_reload.cc
> +++ b/sql/sql_reload.cc
> @@ -543,6 +543,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
>  
>    if (thd->lex->type & REFRESH_READ_LOCK)
>    {
> +#ifdef MDEV15887
>      /*
>        Acquire SNW locks on tables to be flushed. Don't acquire global
>        IX and database-scope IX locks on the tables as this will make
> @@ -559,6 +560,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
>      for (auto table_list= all_tables; table_list;
>           table_list= table_list->next_global)
>        table_list->mdl_request.ticket= NULL;
> +#endif /*MDEV15887*/

what's that?
btw, the number is MDEV15888

>    }
>  
>    thd->variables.option_bits|= OPTION_TABLE_LOCK;

Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx


Follow ups