Bug #23040 Auto-discover behavior is wrong in diskless mode
Submitted: 6 Oct 2006 4:16 Modified: 17 Nov 2006 12:45
Reporter: John David Duncan Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:5.0, 5.1 OS:
Assigned to: CPU Architecture:Any

[6 Oct 2006 4:16] John David Duncan
Description:
If a .frm file and a .ndb file exist for a table, but the cluster does not know about the table, then the .frm and .ndb files are deleted.   This code is around line 5983 of ha_ndbcluster.cc:

    DBUG_PRINT("info", ("%s existed on disk", name));     
    // The .ndb file exists on disk, but it's not in list of tables in ndb
    // Verify that handler agrees table is gone.
    if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0)    
    {
      DBUG_PRINT("info", ("NDB says %s does not exists", file_name));     
      it.remove();
      // Put in list of tables to remove from disk
      delete_list.push_back(thd->strdup(file_name));
    }
  }

I would argue that this behavior is correct if diskless=0 but it is *incorrect* if diskless=1.  When diskless=1, the behavior should be the same as if a .FRM file was found for a MEMORY table.  The table should be silently created in the cluster.

How to repeat:
Start a cluster with diskless=1.
Create a table.
Insert data.
Shut down the cluster.
Restart the cluster.
SELECT * from my_table

Suggested fix:
Provide a way for the API node to know that the cluster is diskless.
Or, provide a general way in the management API to query configuration variables and use this inside mysql.
Or, provide an "ndb_diskless" configuration variable for mysql.
Or, provide an "ndb_create_lost_tables" variable for mysql.

And alter the behavior in ha_ndbcluster.cc
[6 Oct 2006 5:13] Jonas Oreland
How would you distinguish from the case where some other 
mysqld actually dropped the table ?

(and e.g one mysqld was down)

I think you want the "no logging" feature instead.
This is almost the same as diskless
But one can per table decide if it should logged or not.
A not logged table will be empty after cluster restart.

This feature has been in ndb since y2k, but has not been exposed to SQL.

/Jonas
[18 Nov 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".