Bug #54279 failing compatibility checks in ndb_restore attribute promotion
Submitted: 7 Jun 2010 9:05 Modified: 18 Jun 2010 9:03
Reporter: Hartmut Holzgraefe Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.1 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: mysql-cluster-7.1.4

[7 Jun 2010 9:05] Hartmut Holzgraefe
Description:
Promotion compatibility checking works by:

 1) check if column definitions are equal
 2) if not equal find appropriate comparison function for the type pair
 3) then apply comparison function

Problem is that prior to the addition of native default values for certain column types like TIMESTAMP the "check if definitions are equal" check would always succeed so that no compatibility comparison function is defined for this type at all.

But now the equality check would fail on a "TIMESTAMP without default" vs. "TIMESTAMP with default" pair, and as there is no compatibility check function defined for that type either the compatibility test fails even though the columns are actually restore compatible

How to repeat:
- create table with TIMESTAMP field in pre-7.1.4 version
- take "mysqldump --no-data" schema dump
- take cluster backup

- create fresh 7.1.4 instance
- restore schema from mysqldump, TIMESTAMP column now has an implicit native default
- try to restore data from cluster backup with --skip-table-check --promote-attributes

Suggested fix:
add compatibility test entries for TIMESTAMP type in

  const PromotionRules BackupRestore::m_allowed_promotion_attrs[]

maybe needed for other types now, too?
[7 Jun 2010 9:14] Hartmut Holzgraefe
This actually seems to affect any fixed size type with a default value when going from pre-7.1.4 to 7.1.4 (or beyond), e.g. also fails with the following test table:

CREATE TABLE t1
(
  id int primary key,
  n int default 3
) engine=ndb;
[7 Jun 2010 9:19] Hartmut Holzgraefe
probably better solution than adding lots of new type/type comparison functions:

have a new equal_enough() function instead of equal() that ignores certain column attributes like DEFAULT or DYNAMIC ...
[7 Jun 2010 9:43] Hartmut Holzgraefe
See also bug #54242
[18 Jun 2010 9:03] Frazer Clement
Duplicate of bug#54242.

The fix for #54242 relaxes the equality checks to ignore differences in column's default values.  This occurs before / independently of type promotion logic.