Bug #49586 mysql.ndb_replication should be restored first when restoring from backup
Submitted: 10 Dec 2009 13:27 Modified: 22 Feb 2010 19:27
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Replication Severity:S3 (Non-critical)
Version:mysql-5.1-ndb-7.0 OS:Any
Assigned to: Martin Skold CPU Architecture:Any
Tags: Backup, conflict resolution, mysql-5.1.39-ndb-7.0.9, replication, restore
Triage: Triaged: D4 (Minor) / R6 (Needs Assessment) / E6 (Needs Assessment)

[10 Dec 2009 13:27] Geert Vanderkelen
Description:
For conflict resolution to work for a table, you need to first insert
an entry in the mysql.ndb_replication for this table before you create it.

However, when you backup the MySQL schema, and restore the schema, the
entries in mysql.ndb_replication will be restored after the CREATE TABLE
statements. This happens whether you are restoring a backup using output
of mysqldump, or restoring a cluster backup using ndb_restore.

This is considered a bug since it isn't possible to actually restore a
backup, however, it is possible to workaround it.

See:
 http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-replication-conflict-resolution.html

How to repeat:
(restore a backup, conflict resolution will not work)

Suggested fix:
Introduce a new option to mysqldump which will force dumping the entries
of mysql.ndb_replication so its entreis are inserted right after its creation
and before all other tables are created.

Maybe we could take this further:

 mysqldump -d --include-table-data=mysql.ndb_replication.
 
 This would dump all DDL of tables and no data, except for the given
 table, in this case mysql.ndb_replication.
 Similar to --ignore-table.

The same should work for ndb_restore. Maybe ndb_restore should first
restore ndb_replication, like forcing the order? Or the backup should
dump it first?

Workaround: Make first the backup of mysql.ndb_replication
------------
 mysqldump -uroot mysql ndb_replication > mysql_ndb_replication.sql
 mysqldump -uroot --no-data --all-databases \
      --ignore-table=mysql.ndb_replication > mysql_DDL_all.sql

Or you can simply dump first the mysql database, and then the other
databases.
Point is, first restore mysql.ndb_replication table completely, and then
the other tables.
[5 Jan 2010 10:05] Jonas Oreland
this should be fixed for both mysqldump and ndb_restore,
but for affected customer, mysqldump is prio 1
[22 Feb 2010 19:27] Jonas Oreland
customer accepted work-around,
we'll close this