Bug #40472 ndb_restore can't restore selection of database
Submitted: 1 Nov 2008 23:40 Modified: 6 Nov 2008 14:15
Reporter: Geert Vanderkelen Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1.29-ndb-6.3.19 OS:Any
Assigned to: Jon Stephens CPU Architecture:Any
Tags: Backup, ndb, restore

[1 Nov 2008 23:40] Geert Vanderkelen
Description:
Currently, we have documented in the MySQL 5.1 manual:
 http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-restore.html

ndb_restore other_options db_name_1 [db_name_2[, db_name_3][, ...] | tbl_name_1[, tbl_name_2][, ...]]

Which implements following:
1) All tables from one or more databases
2) One or more tables from a single database

However, (1) does not work. If you specify db1,db2 on the command line, ndb_restore takes a database named `db1,db2`.
And (2) is also falsely documented in the syntax. Only thing that works currently:

ndb_restore other_options [db_name_1 [ tbl_name_1 [tbl_name_2] [...]]]

How to repeat:
Take any backup, and restore some databases. In the output here under, we see that nothing gets restored or no errors were outputted saying tables were already there. It actually went to include `test,test2`.

shell> ndb_restore -b 5 -n 3 -m -r /opt/mysql/cluster/BACKUP/BACKUP-5/ test,test2
..
Restoring only from database test,test2
Opening file '/opt/mysql/cluster/BACKUP/BACKUP-5/BACKUP-5.3.ctl'
Backup version in files: ndb-6.3.11 ndb version: mysql-5.1.29 ndb-6.3.19
Connected to ndb!!
Opening file '/opt/mysql/cluster/BACKUP/BACKUP-5/BACKUP-5-0.3.Data'
_____________________________________________________
Processing data in table: test2/def/t3(9) fragment 0
..
Opening file '/opt/mysql/cluster/BACKUP/BACKUP-5/BACKUP-5.3.log'
Restored 0 tuples and 0 log entries

NDBT_ProgramExit: 0 - OK

Suggested fix:
Goes wrong here (storage/ndb/tools/restore/restore_main.cpp:

    if ((*pargv)[i] == NULL)
      break;
    g_databases.push_back((*pargv)[i++]);
    if ()
    while ((*pargv)[i] != NULL)
    {
      g_tables.push_back((*pargv)[i++]);
    }
    break;

Only 1 argument is read after the path, and not checked for commas later on.

Fix would be that when the first option after the path has commas, to see that as a list of databases. We ignore then any other option on the command line. If we restore multiple database, you can't specify tables really.

Now, I found this while implementing feature/bug #40429 . That one will fix this stuff I hope.

We should just make sure that we document the behavior/syntax of ndb_restore correctly.
[1 Nov 2008 23:42] Geert Vanderkelen
W4: can run ndb_restore multiple times for each database; bit clumsy but works.
[7 Nov 2008 18:36] Jon Stephens
Hi,

Please don't assign Server bugs to me as they do not show up in the Docs Team work queues. (And I don't work on the server.)

If this is a Docs bug, please change the category to Docs and the lead to Stefan.

If this is not a Docs bug, please assign it to someone else.

The third option is to leave it the way it is, in which case it is quite likely to be ignored.

Thanks!
[13 Mar 2014 13:28] Omer Barnir
This bug is not scheduled to be fixed at this time.