zoukankan      html  css  js  c++  java
  • Another reason why SQL_SLAVE_SKIP_COUNTER is bad in MySQL

    It is everywhere in the world of MySQL that if your replication is broken because an event caused a duplicate key or a row was not found and it cannot be updated or deleted, then you can use ‘STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; ‘ and be done with it. In some cases this is fine and you can repair the offending row or statements later on. But what if the statement is part of a multi-statement transaction? Well, then it becomes more interesting, because skipping the offending statement will cause the whole transaction to be skipped. This is well documented in the manual by the way. So here’s a quick example.

    3 rows on the master:

    2 on the slave:

    Execute a transaction on the master to break replication:

    Broken slave:

    An attempt to fix replication only caused bigger inconsistencies on slave:

    This happens because the replication honors transaction boundaries, and is definitely something you should consider the next time you try to use this workaround on a broken slave. Of course, there is pt-table-checksum and pt-table-sync to rescue you when inconsistencies occur, however, prevention is always better than cure. Make sure to put safeguards in place to prevent your slaves from drifting.

    Lastly, the example above is for ROW-based replication as my colleague pointed out, but can similarly happen with STATEMENT for example with a duplicate key error.  You can optionally fix the error above by temporarily setting slave_exec_mode to IDEMPOTENT so errors because of missing rows are skipped, but then again, it does not apply in all cases like an UPDATE statement that cannot be applied because the row on the slave is missing.

    Here is a demonstration of the problem with STATEMENT-based replication:

    https://www.percona.com/blog/2013/07/23/another-reason-why-sql_slave_skip_counter-is-bad-in-mysql/

  • 相关阅读:
    G450 Ubuntu14 无线网卡解决
    USB设备不能用。提示Windows 无法启动这个硬件设备。 (代码 19)
    帮你选处理器:CPU T9500-p9500-T9400-T9300-p8700对比分析!
    全球各大运营商黑莓ROM官网下载链接汇总
    查看80端口被占用的方法(IIS、apmserv、system)
    Windows 2003 服务器安全设置-批处理 (附参考链接)
    解决Windows时间同步失败问题!系统时间同步设置!
    WinHTTP Web Proxy Auto-Discovery Service
    关于“未使用GUID分区表”无法安装的解决方案
    DataGridView使用技巧六:冻结列或行
  • 原文地址:https://www.cnblogs.com/DataArt/p/10174494.html
Copyright © 2011-2022 走看看