diff --git a/HowtoMySQL/Replication.md b/HowtoMySQL/Replication.md index fdb17803..b4de0252 100644 --- a/HowtoMySQL/Replication.md +++ b/HowtoMySQL/Replication.md @@ -620,3 +620,104 @@ En cas de `Can't make changes on the master because no unique index exists`. On ~~~ # pt-table-sync --execute --no-check-slave localhost slave ~~~ + +## Lire les erreurs de réplication, pour une réplication par Channel, ou Group réplication. + +Dans le cas d'une réplication par channel, ou Group Réplication, la sortie de `SHOW SLAVE STATUS\G' indique sur quels Channel il y a une erreur, mais sans forcément indiqué de manière explicite l'erreur en question. + +Exemple : + +~~~ +mysql> SHOW SLAVE STATUS\G + +..... + + Exec_Master_Log_Pos: 18089090 + Relay_Log_Space: 1104382466 + 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: 1064 + Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at master log mysql-bin.000807, end_log_pos 18089265. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any. + Replicate_Ignore_Server_Ids: + Master_Server_Id: 62 + Master_UUID: + Master_Info_File: mysql.slave_master_info + SQL_Delay: 0 + SQL_Remaining_Delay: NULL + Slave_SQL_Running_State: + Master_Retry_Count: 86400 + Master_Bind: + Last_IO_Error_Timestamp: + Last_SQL_Error_Timestamp: 200703 10:56:11 + Master_SSL_Crl: + Master_SSL_Crlpath: + Retrieved_Gtid_Set: + Executed_Gtid_Set: + Auto_Position: 0 + Replicate_Rewrite_DB: + Channel_Name: su6-sql2 + Master_TLS_Version: + Master_public_key_path: + Get_master_public_key: 0 + Network_Namespace: + +~~~ + +On vois que la réplication sur le Channel nommée su6-sql2 est en erreur, mais on ne sait pas sur quelle requête. + +Le message d'erreur suggère de regarder les logs d'erreurs dans la table performance_schema.replication_applier_status_by_worker. + +On peu le faire comme ceci, en indiquant le Channel en erreur, et le numéro du Worker, comme indiqué dans le message d'erreur précédent: + +Exemple : + +~~~ +mysql> SELECT * FROM performance_schema.replication_applier_status_by_worker WHERE WORKER_ID=1 AND CHANNEL_NAME='su6-sql2'\G; + +*************************** 1. row *************************** + CHANNEL_NAME: su6-sql2 + WORKER_ID: 1 + THREAD_ID: NULL + SERVICE_STATE: OFF + LAST_ERROR_NUMBER: 1064 + LAST_ERROR_MESSAGE: Worker 1 failed executing transaction 'ANONYMOUS' at master log mysql-bin.000807, end_log_pos 18089265; Error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1' at line 1' on query. Default database: 'DB_content_cfbe'. Query: 'delete from toppops_cfbe_null_20200702_104153_V220 where rank=1' + LAST_ERROR_TIMESTAMP: 2020-07-03 10:56:11.801803 + LAST_APPLIED_TRANSACTION: + LAST_APPLIED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000 + LAST_APPLIED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000 + LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP: 0000-00-00 00:00:00.000000 + LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP: 0000-00-00 00:00:00.000000 + APPLYING_TRANSACTION: + APPLYING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000 + APPLYING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00.000000 + APPLYING_TRANSACTION_START_APPLY_TIMESTAMP: 0000-00-00 00:00:00.000000 + LAST_APPLIED_TRANSACTION_RETRIES_COUNT: 0 + LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER: 0 + LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE: +LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000 + APPLYING_TRANSACTION_RETRIES_COUNT: 0 + APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER: 0 + APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE: + APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000 +1 row in set (0.01 sec) + +ERROR: +No query specified +~~~ + +Comme ça on peux voir l'erreur explicite : + +~~~ +Error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1' at line 1' on query. Default database: 'DB_content_cfbe'. Query: 'delete from toppops_cfbe_null_20200702_104153_V220 where rank=1' +~~~ \ No newline at end of file