-
Lakshmi Narayanan Sreethar authored
When a MySQL Server connects to NDB, it does not know whether it has connected to that cluster before or not. Due to this, it also will not know if its DD entries are just a little bit out of sync or completely invalid. This commit introduces a schema version identifier known as schema UUID to solve this issue. The schema UUID will be a unique identifier stored in the ndb_schema table in NDB and in the se_private_data field of the ndb_schema table object in DD. Whenever a MySQL Server connects with a cluster, it can now compare the schema UUID stored in its DD against the one stored in the ndb_schema in NDB and detect if it is connecting for the first time or not. If it is connecting for the first time, it will wipe clean its DD entries. Changes: ha_ndbcluster_binlog.cc: - Updated the method remove_deleted_ndb_tables_from_dd() in Ndb_binlog_setup class to optionally wipe clean the DD when an initial start/restart is detected. - Added method detect_initial_restart() to compare the UUIDs stored in DD and NDB, and, detect if this is an initial start/restart or not. - Updated the Ndb_binlog_setup class' setup method to detect and handle initial system restarts. ndb_schema_dist_table.h - Added a method get_schema_uuid() to retrieve the schema UUID from the ndb_schema table in NDB. - Overloaded the pre_upgrade() method to save the schema UUID in a new static member - old_ndb_schema_uuid. - Overloaded the post_install() method to either generate a new schema UUID or use the old_ndb_schema_uuid and update them in the ndb_schema table after a create/upgrade. - Added a method update_schema_uuid_in_NDB() that updates the UUID of the ndb_schema table in NDB. ndb_util_table.h - Added a new method pre_upgrade(), that can be overloaded by the derived classes to save any additional metadata that has to be restored after upgrade. - Added a new method post_install(), which can be overloaded by the derived classes to update the metadata of the tables further after the table has been created in NDB. - Added a new method unpack_blob_not_null() to read out the values from a blob handle into a buffer. - Added get_thd() and get_ndb() methods to be used by the derived class methods to access the THD and Ndb objects stored in the object. - Updated the return type of pack_varbinary method and its wrapper in Ndb_schema_result_table to void. - Made the pack_varbinary, unpack_varbinary into protected methods. ndb_dd_client.h - Added methods get_schema_uuid() and update_schema_uuid() to read and write the schema UUID values from the ndb_schema table in DD. ndb_dd_table.h - Added methods ndb_dd_table_get_schema_uuid() and ndb_dd_table_set_schema_uuid() to read and update schema_uuid from and into the ndb_schema table object's se_private_data. ndb_dd.h - Added wrapper methods to read and write the schema UUID from and to DD. ndb_thd_ndb.h - Added a getter get_thd() for the THD object in the Thd_ndb class. Updated ndb.ndb_restart and ndb_ddl.schema_dist_upgrade testcases. Change-Id: Ia82ed94e645615230c02027f606888a550cbcf48
Lakshmi Narayanan Sreethar authoredWhen a MySQL Server connects to NDB, it does not know whether it has connected to that cluster before or not. Due to this, it also will not know if its DD entries are just a little bit out of sync or completely invalid. This commit introduces a schema version identifier known as schema UUID to solve this issue. The schema UUID will be a unique identifier stored in the ndb_schema table in NDB and in the se_private_data field of the ndb_schema table object in DD. Whenever a MySQL Server connects with a cluster, it can now compare the schema UUID stored in its DD against the one stored in the ndb_schema in NDB and detect if it is connecting for the first time or not. If it is connecting for the first time, it will wipe clean its DD entries. Changes: ha_ndbcluster_binlog.cc: - Updated the method remove_deleted_ndb_tables_from_dd() in Ndb_binlog_setup class to optionally wipe clean the DD when an initial start/restart is detected. - Added method detect_initial_restart() to compare the UUIDs stored in DD and NDB, and, detect if this is an initial start/restart or not. - Updated the Ndb_binlog_setup class' setup method to detect and handle initial system restarts. ndb_schema_dist_table.h - Added a method get_schema_uuid() to retrieve the schema UUID from the ndb_schema table in NDB. - Overloaded the pre_upgrade() method to save the schema UUID in a new static member - old_ndb_schema_uuid. - Overloaded the post_install() method to either generate a new schema UUID or use the old_ndb_schema_uuid and update them in the ndb_schema table after a create/upgrade. - Added a method update_schema_uuid_in_NDB() that updates the UUID of the ndb_schema table in NDB. ndb_util_table.h - Added a new method pre_upgrade(), that can be overloaded by the derived classes to save any additional metadata that has to be restored after upgrade. - Added a new method post_install(), which can be overloaded by the derived classes to update the metadata of the tables further after the table has been created in NDB. - Added a new method unpack_blob_not_null() to read out the values from a blob handle into a buffer. - Added get_thd() and get_ndb() methods to be used by the derived class methods to access the THD and Ndb objects stored in the object. - Updated the return type of pack_varbinary method and its wrapper in Ndb_schema_result_table to void. - Made the pack_varbinary, unpack_varbinary into protected methods. ndb_dd_client.h - Added methods get_schema_uuid() and update_schema_uuid() to read and write the schema UUID values from the ndb_schema table in DD. ndb_dd_table.h - Added methods ndb_dd_table_get_schema_uuid() and ndb_dd_table_set_schema_uuid() to read and update schema_uuid from and into the ndb_schema table object's se_private_data. ndb_dd.h - Added wrapper methods to read and write the schema UUID from and to DD. ndb_thd_ndb.h - Added a getter get_thd() for the THD object in the Thd_ndb class. Updated ndb.ndb_restart and ndb_ddl.schema_dist_upgrade testcases. Change-Id: Ia82ed94e645615230c02027f606888a550cbcf48
Loading