Bug #75797 Remove MCP_BUG16021021
Submitted: 5 Feb 2015 15:04 Modified: 15 May 2015 14:11
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.4.4 OS:Any
Assigned to: CPU Architecture:Any

[5 Feb 2015 15:04] Magnus Blåudd
Description:

This MCP was hacked in 18 Feb 2013 but the problem never fixed in MySQL Server. Can we revive the bug and include in MySQL Server? Assumption is that since MCP is in code it's been approved and thus can be pushed also to mysql-trunk. Probably not.

There are according to the bug at least 6 different ways to rename a table, all cases need to be considered.

The fix in sql_table.cc changes the behaviour of "ALTER TABLE algorithm=copy, RENAME" to not use copying alter. Does not feel like that would be an acceptable solution for the vanilla MySQL Server, not doing a copying ALTER when user so requested is weird.

Feels like problem need to be fixed in ha_ndbcluster so that it properly detects the RENAME and also propagates it to participant servers. Magnus supposedly has patch in 7.2-ddl/ called magic_detect_rename. That patch rewrites ha_ndbcluster::rename_table() quite a lot to account for all the different cases.

How to repeat:
Current MCP patch:

> diff --git a/sql/sql_table.cc b/sql/sql_table.cc
> index 1b802a4..fa9b43f 100644
> --- a/sql/sql_table.cc
> +++ b/sql/sql_table.cc
> @@ -8236,8 +8284,16 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
>    THD_STAGE_INFO(thd, stage_setup);
>    if (!(alter_info->flags & ~(Alter_info::ALTER_RENAME |
>                                Alter_info::ALTER_KEYS_ONOFF)) &&
> +#ifndef MCP_BUG16021021
> +      (alter_info->requested_algorithm !=
> +       Alter_info::ALTER_TABLE_ALGORITHM_COPY ||
> +       // Allow for all exclusive rename to avoid copying
> +      (alter_info->flags & Alter_info::ALTER_RENAME &&
> +       !(alter_info->flags & ~Alter_info::ALTER_RENAME))) &&
> +#else
>        alter_info->requested_algorithm !=
>        Alter_info::ALTER_TABLE_ALGORITHM_COPY &&
> +#endif
>        !table->s->tmp_table) // no need to touch frm
>    {
>      // This requires X-lock, no other lock levels supported.

Suggested fix:
Refactor ha_ndbcluster::rename() to properly detect the different cases of rename.
Add tests.
Remove the MCP.
Fix in 5.7 based MySQL Cluster.
[15 May 2015 14:11] Jon Stephens
Documented fix as follows in the NDB 7.5.0 changelog:

    In previous versions of MySQL Cluster, other DDL operations
    could not be part of ALTER ONLINE TABLE ... RENAME ... . (This
    was disallowed by the fix for BUG#16021021.) MySQL Cluster NDB
    7.5 makes the following changes:

          The ONLINE and OFFLINE keywords are now deprecated; the
          NDB storage engine now accepts ALGORITHM = DEFAULT,
          ALGORITHM = COPY, and ALGORITHM = INPLACE to specify
          whether the operation is copying or in-place, just as in
          the standard MySQL Server.

          NDB now allows concurrent DDL operations as part of ALTER
          TABLE ... ALGORITHM=INPLACE RENAME.

Closed.

Note that this also fixes BUG#76543.