Keywords: mysql replication Troubleshooting
[1] manual processing gtid_next (SQL thread error)
For example: primary key violation, table, database does not exist, the data does not exist in the other row mode.
[1.1] Fault simulation: Create a user repeats
[1.1 . 1 ] in first create a user from the database, create a user on the go to the main library
- from 202:
the Create the User 'the Test' @ '%' IDENTIFIED by '123456';
. All privileges ON * * Grant to 'Test' @ '%';
the flush privileges;
- Main 202:
Create User 'Test' @ '%' IDENTIFIED by '123456';
Grant ON * * All privileges to 'Test' @ '%';.
The flush privileges;
use Test;
Create Table Test3 (int ID);
INTO Test3 values INSERT (. 1);
the commit;
[1.1.2] verification synchronization
synchronism is found
202 in execution from the library:
show slave status \ G - View status
found mistake:
GTID shown here, refers to the need to perform this GTID transaction failed, that is to say, the real problem is that GTID above that transaction.
[1.1.3] verify the error message
What to see performed on the main library based on the file name and location on the map information;
Sure enough, it is to create a user error.
From this figure, according to the position information and the GTID, you should be able to apply for the above said marked red.
View more detailed information; runs on from the library
select * from performance_schema.replication_applier_status_by_worker\G
Read_Master_Log_Pos: 2174
Exec_Master_Log_Pos: 1112
Remember, this error number, that is our error, or it may be to the corresponding error message appears at other times;
[1.1.4] is resolved, skip, shielding the conflict Affairs
From the library: specified directly, executing the next transaction, the transaction is the error message displayed ( because GTID shown here, is that the implementation of this points to an error, the affairs of this GTID where no execution )
(1) Since the GTID must be continuous, normally produced in the same GTID a server is not present vacancies.
We can not simply skip out a transaction can only replace a practical method by injecting Affairs empty things.
(2) Method Injection empty things:
stop slave;
set @@session.gtid_next='de853101-b165-11e9-900a-000c291f4171:8';
begin;commit;
set @@ session.gtid_next = 'automatic'; - not change back, many error
start slave;
If set @@ session.gtid_next = 'automatic'; this time, given below.
So not mean re-done, and then the operation can wait.
mysql> set @@session.gtid_next='de853101-b165-11e9-900a-000c291f4171:18';
ERROR 1766 (HY000): The system variable gtid_next cannot be set when there is an ongoing transaction.
[1.1.5] verification
show slave status \ G - view the process status and error information is OK
use test; show tables; - to see whether the data is synchronized over, OK, ah
[1.1.6] If a transaction is the last main library error, how to do?