Open GoogleCodeExporter opened 9 years ago
How to reproduce:
1. Insert the following data onto the master:
create database base;
CREATE TABLE user1 (id int(11) NOT NULL, name varchar(255) NOT NULL);
INSERT INTO base.user1 (id, name) VALUES (1, 'test1');
INSERT INTO base.user1 (id, name) VALUES (2, 'test2');
INSERT INTO base.user1 (id, name) VALUES (3, 'test3');
INSERT INTO base.user1 (id, name) VALUES (4, 'test4');
CREATE TABLE user2 (id int(11) NOT NULL, name varchar(255) NOT NULL);
INSERT INTO base.user2 (id, name) VALUES (1, 'test1');
INSERT INTO base.user2 (id, name) VALUES (2, 'test2');
INSERT INTO base.user2 (id, name) VALUES (3, 'test3');
INSERT INTO base.user2 (id, name) VALUES (4, 'test4');
2. Create a master-slave replication and copy the data to the slave with
xtrabackup.
3. Create a mysqldump on the slave and swap the order of the data in table
user2:
INSERT INTO `user2` VALUES (1,'test1'),(2,'test2'),(3,'test3'),(4,'test4');
->
INSERT INTO `user2` VALUES (1,'test1'),(2,'test2'),(4,'test4'),(3,'test3');
4. Add the second slave to the replication and import the modified dump.
5. On master:
./trepctl check base.user1 - OK
./trepctl check base.user2 - works on the first slave (xtrabackup), fails on
second slave (mysqldump)
The master / slave1 (xtrabackup):
mysql> select * from user1;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
| 2 | test2 |
| 3 | test3 |
| 4 | test4 |
+----+-------+
4 rows in set (0.00 sec)
mysql> select * from user2;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
| 2 | test2 |
| 3 | test3 |
| 4 | test4 |
+----+-------+
4 rows in set (0.00 sec)
Slave2 (mysqldump):
mysql> select * from user1;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
| 2 | test2 |
| 3 | test3 |
| 4 | test4 |
+----+-------+
4 rows in set (0.00 sec)
mysql> select * from user2;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
| 2 | test2 |
| 4 | test4 |
| 3 | test3 |
+----+-------+
4 rows in set (0.00 sec)
Either way, the following SELECTs give the same result:
mysql> select * from user2 where id=1;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
+----+-------+
1 row in set (0.00 sec)
mysql> select * from user2 where id=2;
+----+-------+
| id | name |
+----+-------+
| 2 | test2 |
+----+-------+
1 row in set (0.00 sec)
mysql> select * from user2 where id=3;
+----+-------+
| id | name |
+----+-------+
| 3 | test3 |
+----+-------+
1 row in set (0.00 sec)
mysql> select * from user2 where id=4;
+----+-------+
| id | name |
+----+-------+
| 4 | test4 |
+----+-------+
1 row in set (0.00 sec)
Original comment by tomas.mo...@gmail.com
on 23 Jan 2014 at 12:45
Hi Tomas,
try adding a primary key to the id column in user1 and user2 tables on both
sides and repeat the test - it should work. If there's no PK, there's no
consistent way of ordering rows between different DBMS instances, hence
consistency check failure.
Cheers,
Linas
Original comment by linas.vi...@continuent.com
on 27 Jan 2014 at 12:16
Hello,
after modifying the table creation to be more specific:
CREATE TABLE base.user1 (id int(11) NOT NULL, name varchar(255) NOT NULL,
PRIMARY KEY (id)) ENGINE=MyISAM
CREATE TABLE base.user2 (id int(11) NOT NULL, name varchar(255) NOT NULL,
PRIMARY KEY (id)) ENGINE=MyISAM
the same error appears:
Consistency check failed on table 'base.user2' id: 2, offset: -1, limit: -1,
method: 'md5' failed
As pointed out in the first comment, the production table on which this
happened already had a primary key on `id`.
- mysqldump on master/slave (xtrabackup):
--
-- Table structure for table `user1`
--
DROP TABLE IF EXISTS `user1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user1` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user1`
--
LOCK TABLES `user1` WRITE;
/*!40000 ALTER TABLE `user1` DISABLE KEYS */;
INSERT INTO `user1` VALUES (1,'test1'),(2,'test2'),(3,'test3'),(4,'test4');
/*!40000 ALTER TABLE `user1` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user2`
--
DROP TABLE IF EXISTS `user2`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user2` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user2`
--
LOCK TABLES `user2` WRITE;
/*!40000 ALTER TABLE `user2` DISABLE KEYS */;
INSERT INTO `user2` VALUES (1,'test1'),(2,'test2'),(3,'test3'),(4,'test4');
/*!40000 ALTER TABLE `user2` ENABLE KEYS */;
UNLOCK TABLES;
- mysqldump on slave with differently ordered data:
--
-- Table structure for table `user1`
--
DROP TABLE IF EXISTS `user1`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user1` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user1`
--
LOCK TABLES `user1` WRITE;
/*!40000 ALTER TABLE `user1` DISABLE KEYS */;
INSERT INTO `user1` VALUES (1,'test1'),(2,'test2'),(3,'test3'),(4,'test4');
/*!40000 ALTER TABLE `user1` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `user2`
--
DROP TABLE IF EXISTS `user2`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user2` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `user2`
--
LOCK TABLES `user2` WRITE;
/*!40000 ALTER TABLE `user2` DISABLE KEYS */;
INSERT INTO `user2` VALUES (1,'test1'),(2,'test2'),(4,'test4'),(3,'test3');
/*!40000 ALTER TABLE `user2` ENABLE KEYS */;
UNLOCK TABLES;
Original comment by tomas.mo...@gmail.com
on 31 Jan 2014 at 7:52
Original issue reported on code.google.com by
tomas.mo...@gmail.com
on 23 Jan 2014 at 11:57