Bug #33411 Didn't write exception table if reqired columns in different order
Submitted: 20 Dec 2007 16:24 Modified: 3 Apr 2008 11:26
Reporter: li zhou Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Replication Severity:S2 (Serious)
Version:mysql-5.1-telco-6.3 OS:Any
Assigned to: CPU Architecture:Any
Tags: 5.1.22-ndb-6.3.7

[20 Dec 2007 16:24] li zhou
Description:
In testing “Same timestamp wins” conflict resolution, if the required columns in different order when creating exception table, records will not insert into exception table if conflict occurred.
 

How to repeat:
I test this error using MTR, and do the following modification:

./mysql-test/suite/rpl_ndb/t/rpl_ndb_conflict_old.test, 

create table `test`.`t1$EX`
  (
   a int not null,
   d varchar(9) not null,
   server_id int unsigned,
   master_server_id int unsigned,
   master_epoch bigint unsigned,
   count int unsigned,
   primary key(server_id, master_server_id, master_epoch, count)) engine ndb;

Then do ./mysql-test-run.pl --do-test=rpl_ndb_conflict_old
from the result, you can see nothing exist in t1$EX table.

Suggested fix:
1:  If original_table_pk_columns must following the four required column(server_id, master_server_id, master_epoch, count), we need to give warning when we put pk_columns before required_columns.

2: In fact there are another problem. from manual(http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-replication-conflict-resolution.html), we know that "Additional columns may optionally be defined following these columns(required columns), but not before any of them; ". But we didn't check this order. We can create a exception table as following:

CREATE TABLE test.t1$EX  (
    server_id INT UNSIGNED,
    master_server_id INT UNSIGNED,
    master_epoch BIGINT UNSIGNED,
    mycol1 INT UNSIGNED ,
    mycol2 INT UNSIGNED ,
    mycol3 INT UNSIGNED ,
    count INT UNSIGNED,      -----count should before mycol*
    a INT UNSIGNED NOT NULL,
    b CHAR(25) NOT NULL,
    PRIMARY KEY(server_id, master_server_id, master_epoch, count)
)   ENGINE=NDB;
CREATE TABLE test.t1  (
    a INT UNSIGNED NOT NULL,
    b CHAR(25) NOT NULL,
    mycol INT UNSIGNED ,
    mycol1 INT UNSIGNED ,
    mycol2 INT UNSIGNED ,
    mycol3 INT UNSIGNED ,
    PRIMARY KEY (a, b)
)   ENGINE=NDB;

So we need warning when we create this kind of table.

I think the columns order should be explicitly descript and check.
[3 Apr 2008 11:26] Sveta Smirnova
Thank you for the report.

Verified as described.