| Bug #39622 | Primary key to repeat the error occurred in MySQL slave when update record. | ||
|---|---|---|---|
| Submitted: | 24 Sep 2008 8:43 | Modified: | 9 May 2009 13:15 |
| Reporter: | liu yunfei | Email Updates: | |
| Status: | No Feedback | Impact on me: | |
| Category: | MySQL Cluster: Replication | Severity: | S2 (Serious) |
| Version: | mysql-5.1.23 ndb-6.2.15 | OS: | Linux |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
[24 Sep 2008 8:49]
liu yunfei
Cluster config file
Attachment: ndbconfig.ini (application/octet-stream, text), 1.05 KiB.
[24 Sep 2008 8:51]
liu yunfei
Master SQL node config
Attachment: my.cnf (application/octet-stream, text), 145 bytes.
[24 Sep 2008 8:52]
liu yunfei
Data node config
Attachment: my.cnf (application/octet-stream, text), 48 bytes.
[24 Sep 2008 8:53]
liu yunfei
Slave MySQL config
Attachment: my.cnf (application/octet-stream, text), 565 bytes.
[24 Sep 2008 10:14]
Bernd Ocklin
Tested with - 6.2.15 - ndb_apply_status table on slave as MyISAM w/o PK - no replication filtering Verifed dup key error.
[24 Sep 2008 10:31]
Bernd Ocklin
Update is actually turned into an insert on master already and only affects cluster tables. update www set name='aaa' where id =1; reads in the binlog on master: BINLOG ' oRHaSBMBAAAALQAAAMQCAAAAAC0AAAAAAAAABHRlc3QAA3d3dwACAw8CgAAC oRHaSBMBAAAAPgAAAAIDAAAAABAAAAAAAAAABW15c3FsABBuZGJfYXBwbHlfc3RhdHVzAAUDCA8I CAL/AAA= oRHaSBcBAAAAOwAAAD0DAAAAABAAAAAAAAAABR/gAQAAAAUAAADAAgAAAAAAAAAAAAAAAAAAAAAA AAA= ### INSERT INTO mysql.ndb_apply_status ### SET ### @1=1 ### @2=3023656976389 ### @3='' ### @4=0 ### @5=0 oRHaSBcBAAAAJgAAAGMDAAAQAC0AAAAAAAEAAgP8AQAAAANhYWE= '/*!*/; ### INSERT INTO test.www ### SET ### @1=1 ### @2='aaa'
[24 Sep 2008 13:44]
wang xiaolin
Dear Bernhard Ocklin :
>- 6.2.15
>- ndb_apply_status table on slave as MyISAM w/o PK
>- no replication filtering
I did as you said , but I still get the dup key error !!
Could you finger out what's wrong with my config file or any other ?
%%%%%%%%%%%%
%% step 1
%%%%%%%%%%%%
slave mysql config file :
[root@mfx222 data]# cat /etc/my.cnf |grep -Ev "#|^$"
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 32M
max_allowed_packet = 1M
table_cache =128
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
max_connections=256
default-character-set=cp932
skip-name-resolve
server-id = 222
master-host = 10.4.6.227
master-user = root
master-password = 123456
skip-slave-start
%%%%%%%%%%%%
%% step 2
%%%%%%%%%%%%
change ndb_apply_status to MyISAM without PK on the SLAVE mysql .
mysql> show create table ndb_apply_status \G;
*************************** 1. row ***************************
Table: ndb_apply_status
Create Table: CREATE TABLE `ndb_apply_status` (
`server_id` int(10) unsigned NOT NULL,
`epoch` bigint(20) unsigned NOT NULL,
`log_name` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
`start_pos` bigint(20) unsigned NOT NULL,
`end_pos` bigint(20) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
%%%%%%%%%%%%
%% step 3
%%%%%%%%%%%%
Master Cluster's MySQL Server (SQL Node) my.cnf :(10.4.6.227)
[root@mfx226 data]# cat /etc/my.cnf |grep -Ev "#|^$"
[MYSQLD]
ndbcluster
ndb-connectstring=10.4.6.224
default-storage-engine=ndbcluster
max_connections=1024
default-character-set=cp932
server-id = 27
log-bin=mfx227-bin
binlog_format="ROW"
%%%%%%%%%%%%
%% step 4
%%%%%%%%%%%%
Do the Following SQL at Master :
mysql> create table www (id int(10),name varchar(64), PRIMARY KEY (id))
engine=ndb DEFAULT CHARSET=cp932 ;
Query OK, 0 rows affected (0.78 sec)
mysql>
mysql> insert into www (id,name) values (1,'ttt');
Query OK, 1 row affected (0.01 sec)
mysql> update www set name='aaa' where id=1 ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> commit ;
Query OK, 0 rows affected (0.00 sec)
%%%%%%%%%%%%
%% step 5
%%%%%%%%%%%%
This is the slave infomation :
mysql> select * From www ;
+----+------+
| id | name |
+----+------+
| 1 | ttt |
+----+------+
1 row in set (0.00 sec)
mysql> show slave status \G ;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.4.6.227
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mfx227-bin.000001
Read_Master_Log_Pos: 935
Relay_Log_File: mfx222-relay-bin.000003
Relay_Log_Pos: 747
Relay_Master_Log_File: mfx227-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1062
Last_Error: Duplicate entry '1' for key 'PRIMARY'
Skip_Counter: 0
Exec_Master_Log_Pos: 601
Relay_Log_Space: 1237
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1062
Last_SQL_Error: Duplicate entry '1' for key 'PRIMARY'
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> show create table www ;
+-------+------------------------------------------------------------------
| Table | Create Table
+-------+------------------------------------------------------------------
| www | CREATE TABLE `www` (
`id` int(10) NOT NULL DEFAULT '0',
`name` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp932 |
+-------+------------------------------------------------------------------
1 row in set (0.00 sec)
[24 Sep 2008 14:14]
Bernd Ocklin
Hi, nothing is wrong with what you do. I simply reproduced and verified with a simpler test set-up then yours that there is really a bug.
[24 Sep 2008 15:04]
wang xiaolin
hi ,I am sorry . I thought the dup key error would be fixed accroding to your steps . But In fact, the error still exist . So it is indeed a BUG of this version ,right? I was wondering if there is any other way to use the function of Cluster--->MyISAM in this GA version ?
[24 Sep 2008 15:57]
wang xiaolin
added this option to Master SQL Node : ndb-log-update-as-write=0 ,then it work all OK now . BUT this option is safe enough for my product system ? is there any other problem ? Thanks a lot .
[24 Sep 2008 18:23]
Bernd Ocklin
Sure you can use ndb-log-update-as-write option. Its safe for production if you don't use conflict detection on another slave cluster.
[9 Apr 2009 13:15]
Jonathan Miller
Hi, need feed back on if bug or not per Martin. 04/09/09 Bug meeting.
[9 May 2009 23: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".

Description: Hi All: I want to use MySQL Cluster to MySQL Replication (slave is not Slave) in our system ,But we have meet some strange problem when we execute update data. ================================================== Master: Cluster ( 2SQLNode+2DataNode+1MgmNode) Slave : MySQL Server .( MyISAM Table) My Actions Slave RESULT Create table OK Insert Data OK Update Data NOT OK !! ================================================== The DDL is : create table www (id int(10),name varchar(64), PRIMARY KEY (id)) engine=ndb DEFAULT CHARSET=cp932 ; " ================================================== The Follow is my test step,Please check .. Best Regards Linux version information: Linux mfx222 2.6.9-67.EL #1 Fri Nov 16 12:34:13 EST 2007 i686 i686 i386 GNU/Linux --------------------------------------------------------------------------- Cluster config information : ndb_mgm> show Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @10.4.6.220 (mysql-5.1.23 ndb-6.2.15, Nodegroup: 0, Master) id=3 @10.4.6.221 (mysql-5.1.23 ndb-6.2.15, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=1 @10.4.6.224 (mysql-5.1.23 ndb-6.2.15) [mysqld(API)] 5 node(s) id=4 @10.4.6.226 (mysql-5.1.23 ndb-6.2.15) id=5 @10.4.6.227 (mysql-5.1.23 ndb-6.2.15) id=6 (not connected, accepting connect from 10.4.6.228) id=7 (not connected, accepting connect from 10.4.6.229) id=8 (not connected, accepting connect from any host) ----------------------------------------------------------------------------- Cluster config file: [root@mfx224 ~]# cat /etc/ndbconfig.ini [NDBD DEFAULT] NoOfReplicas=1 MaxNoOfConcurrentOperations= 100000 MaxNoOfLocalOperations = 110000 MaxNoOfConcurrentTransactions=1024 DataMemory= 1280M IndexMemory= 256M DataDir=/usr/local/mysql/cluster TimeBetweenWatchDogCheck= 30000 MaxNoOfConcurrentScans=256 MaxNoOfLocalScans=256 BatchSizePerLocalScan=64 MaxNoOfOrderedIndexes= 1024 NoOfFragmentLogFiles=16 MaxNoOfAttributes=80000 MaxNoOfTables=1500 MaxNoOfUniqueHashIndexes=3500 MaxNoOfTriggers=1000 TransactionDeadlockDetectionTimeout=20000 TransactionInactiveTimeout=16000 BackupDataDir=/usr/local/mysql/BACKUP LockPagesInMainMemory=0 [ndb_mgmd default] DataDir=/usr/local/mysql/cluster [TCP default] SendBufferMemory=2M [NDB_MGMD] Hostname= 10.4.6.224 logDestination=FILE:filename=cluster.log,maxsize=100000,maxfiles=6 [NDBD] HostName= 10.4.6.220 [NDBD] HostName= 10.4.6.221 [MYSQLD] HostName= 10.4.6.226 [MYSQLD] HostName= 10.4.6.227 [MYSQLD] HostName= 10.4.6.228 [MYSQLD] HostName= 10.4.6.229 [MYSQLD] ----------------------------------------------------------------------------- Master SQL node config is : [root@mfx227 data]# cat /etc/my.cnf [MYSQLD] ndbcluster ndb-connectstring=10.4.6.224 default-storage-engine=ndbcluster server-id = 27 log-bin=mfx227-bin binlog_format="ROW" ----------------------------------------------------------------------------- data node config is : [root@mfx220 ~]# cat /etc/my.cnf [MYSQL_CLUSTER] ndb-connectstring=10.4.6.224 ----------------------------------------------------------------------------- Slave MySQL : IP:10.4.6.222 mysql> select version(); +-------------------+ | version() | +-------------------+ | 5.1.23-ndb-6.2.15 | +-------------------+ 1 row in set (0.00 sec) ----------------------------------------------------------------------------- Slave MYSQL config file is : [root@mfx222 data]# cat /etc/my.cnf [client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking key_buffer = 16M max_allowed_packet = 1M table_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M server-id = 222 relay-log=oracle110-relay-bin default-storage-engine=innodb replicate-ignore-table=mysql.ndb_apply_status master-host=10.4.6.227 master-port=3306 master-user=root master-password=123456 How to repeat: 1. start Cluster to MySQL replication. On Cluster master: mysql> reset master; Query OK, 0 rows affected (0.03 sec) mysql> show master status; +-------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+----------+--------------+------------------+ | mfx227-bin.000001 | 106 | | | +-------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) On MySQL slave: mysql> stop slave; Query OK, 0 rows affected (0.00 sec) mysql> reset slave; Query OK, 0 rows affected (0.00 sec) mysql> start slave; Query OK, 0 rows affected (0.00 sec) mysql> show slave status \G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.4.6.227 Master_User: root Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mfx227-bin.000001 Read_Master_Log_Pos: 106 Relay_Log_File: oracle110-relay-bin.000003 Relay_Log_Pos: 252 Relay_Master_Log_File: mfx227-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: mysql.ndb_apply_status Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 106 Relay_Log_Space: 411 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: 1 row in set (0.00 sec) ERROR: No query specified 2. create table and insert record in Cluster master. On Cluster msater : mysql> create table www (id int(10),name varchar(64), PRIMARY KEY (id)) engine=ndb DEFAULT CHARSET=cp932 ; Query OK, 0 rows affected (0.47 sec) mysql> insert into www (id,name) values (1,'ttt'); Query OK, 1 row affected (0.01 sec) mysql> select * from www; +------+------+ | id | name | +------+------+ | 1 | ttt | +------+------+ 1 row in set (0.00 sec) On MySQL slave: mysql> show create table www\G; *************************** 1. row *************************** Table: www Create Table: CREATE TABLE `www` ( `id` int(10) DEFAULT NULL, `name` varchar(64) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=cp932 1 row in set (0.00 sec) ERROR: No query specified mysql> select * from www; +----+------+ | id | name | +----+------+ | 1 | ttt | +----+------+ 1 row in set (0.00 sec) 3. update record in Cluster master. On Cluster master: mysql> update www set name='aaa' where id =1; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from www; +----+------+ | id | name | +----+------+ | 1 | aaa | +----+------+ 1 row in set (0.00 sec) On MySQL slave: mysql> select * from www; +----+------+ | id | name | +----+------+ | 1 | ttt | +----+------+ 1 row in set (0.00 sec) mysql> show slave status \G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.4.6.227 Master_User: root Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mfx227-bin.000001 Read_Master_Log_Pos: 938 Relay_Log_File: oracle110-relay-bin.000003 Relay_Log_Pos: 749 Relay_Master_Log_File: mfx227-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: mysql.ndb_apply_status Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1062 Last_Error: Duplicate entry '1' for key 'PRIMARY' Skip_Counter: 0 Exec_Master_Log_Pos: 603 Relay_Log_Space: 1243 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1062 Last_SQL_Error: Duplicate entry '1' for key 'PRIMARY' 1 row in set (0.00 sec) ERROR: No query specified