-- Session 1 CREATE DATABASE test; use test; CREATE TABLE t1(a INT, primary key (a)) ENGINE=INNODB; CREATE TEMPORARY TABLE t2(a INT auto_increment, b int, primary key (a)) ENGINE=INNODB; CREATE TABLE t3(a INT AUTO_INCREMENT, b INT, primary key (a)) ENGINE=INNODB; insert into t3 (b) values (1); insert into t3 (b) select b from t3 ; . insert into t3 (b) select b from t3 ; BEGIN; INSERT INTO t1 SELECT A from t3; DROP TEMPORARY TABLE t2; ROLLBACK; -- Session 2 insert into t1 values (4587467); rm -rf master/ bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/master --log-error-verbosity=3 bin/mysqld --no-defaults --log-bin --binlog-format=ROW --server-id=1 --basedir=$PWD --datadir=$PWD/master --socket=/tmp/mysql_master.sock --port=3307 --log-error=$PWD/master/log.err 2>&1 & rm -rf slave/ bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/slave --log-error-verbosity=3 bin/mysqld --no-defaults --log-bin --binlog-format=ROW --server-id=2 --basedir=$PWD --datadir=$PWD/slave --socket=/tmp/mysql_slave.sock --port=3308 --log-error=$PWD/slave/log.err 2>&1 & -- setup simple master->slave repl - master [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.22: bin/mysql -uroot -S /tmp/mysql_master.sock --prompt='Master>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.22-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. Master>CREATE USER 'repl'@'localhost' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.01 sec) Master>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost'; Query OK, 0 rows affected (0.00 sec) Master> Master>CREATE USER 'repl'@'127.0.0.1' IDENTIFIED BY 'slavepass'; Query OK, 0 rows affected (0.00 sec) Master>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'127.0.0.1'; Query OK, 0 rows affected (0.00 sec) Master>FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) Master>show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | hod03-bin.000001 | 1220 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) Master> - slave [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.22: bin/mysql -uroot -S /tmp/mysql_slave.sock --prompt='Slave>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.22-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. Slave>CHANGE MASTER TO -> MASTER_HOST='localhost', -> MASTER_PORT=3307, -> MASTER_USER='repl', -> MASTER_PASSWORD='slavepass', -> MASTER_LOG_FILE='hod03-bin.000001', -> MASTER_LOG_POS=1220; Query OK, 0 rows affected, 2 warnings (0.01 sec) Slave>start slave; Query OK, 0 rows affected (0.01 sec) Slave>show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: localhost Master_User: repl Master_Port: 3307 Connect_Retry: 60 Master_Log_File: hod03-bin.000001 Read_Master_Log_Pos: 1220 Relay_Log_File: hod03-relay-bin.000002 Relay_Log_Pos: 320 Relay_Master_Log_File: hod03-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1220 Relay_Log_Space: 527 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: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: dbd90a9e-5e49-11e8-937d-0010e05f3e06 Master_Info_File: /export/umesh/server/binaries/GABuilds/mysql-5.7.22/slave/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) - master -- Session 1 Master>CREATE DATABASE test; Query OK, 1 row affected (0.00 sec) Master>use test; Database changed Master>CREATE TABLE t1(a INT, primary key (a)) ENGINE=INNODB; Query OK, 0 rows affected (0.01 sec) Master>CREATE TEMPORARY TABLE t2(a INT auto_increment, b int, primary key (a)) ENGINE=INNODB; Query OK, 0 rows affected (0.00 sec) Master>CREATE TABLE t3(a INT AUTO_INCREMENT, b INT, primary key (a)) ENGINE=INNODB; Query OK, 0 rows affected (0.00 sec) Master>insert into t3 (b) values (1); Query OK, 1 row affected (0.01 sec) Master>insert into t3 (b) select b from t3 ; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 8 rows affected (0.00 sec) Records: 8 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 16 rows affected (0.00 sec) Records: 16 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 32 rows affected (0.00 sec) Records: 32 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 64 rows affected (0.00 sec) Records: 64 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 128 rows affected (0.00 sec) Records: 128 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 256 rows affected (0.00 sec) Records: 256 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 512 rows affected (0.00 sec) Records: 512 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 1024 rows affected (0.01 sec) Records: 1024 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 2048 rows affected (0.02 sec) Records: 2048 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 4096 rows affected (0.03 sec) Records: 4096 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 8192 rows affected (0.07 sec) Records: 8192 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 16384 rows affected (0.14 sec) Records: 16384 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 32768 rows affected (0.25 sec) Records: 32768 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 65536 rows affected (0.51 sec) Records: 65536 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 131072 rows affected (1.06 sec) Records: 131072 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 262144 rows affected (2.17 sec) Records: 262144 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 524288 rows affected (4.10 sec) Records: 524288 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 1048576 rows affected (9.31 sec) Records: 1048576 Duplicates: 0 Warnings: 0 Master>insert into t3 (b) select b from t3 ; Query OK, 2097152 rows affected (18.83 sec) Records: 2097152 Duplicates: 0 Warnings: 0 Master>BEGIN; Query OK, 0 rows affected (0.00 sec) Master>INSERT INTO t1 SELECT A from t3; Query OK, 4194304 rows affected (35.77 sec) Records: 4194304 Duplicates: 0 Warnings: 0 Master>DROP TEMPORARY TABLE t2; Query OK, 0 rows affected (0.00 sec) Master>ROLLBACK; -- Don't wait for it to complete, run insert in another session Query OK, 0 rows affected, 1 warning (36.59 sec) Master> -- Session 2 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.22: bin/mysql -uroot -S /tmp/mysql_master.sock --prompt='Master2>' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.22-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. Master2>use test Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed Master2>insert into t1 values (4587467); Query OK, 1 row affected (0.00 sec) Master2> -- Slave Slave>show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: localhost Master_User: repl Master_Port: 3307 Connect_Retry: 60 Master_Log_File: hod03-bin.000001 Read_Master_Log_Pos: 58979643 Relay_Log_File: hod03-relay-bin.000002 Relay_Log_Pos: 37917091 Relay_Master_Log_File: hod03-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: Could not execute Write_rows event on table test.t1; Duplicate entry '4587467' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log hod03-bin.000001, end_log_pos 58979433 Skip_Counter: 0 Exec_Master_Log_Pos: 37917991 Relay_Log_Space: 58978950 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: 105 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1062 Last_SQL_Error: Could not execute Write_rows event on table test.t1; Duplicate entry '4587467' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log hod03-bin.000001, end_log_pos 58979433 Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: dbd90a9e-5e49-11e8-937d-0010e05f3e06 Master_Info_File: /export/umesh/server/binaries/GABuilds/mysql-5.7.22/slave/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Reading event from the relay log Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 180523 07:35:38 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec)