Not the answer you need?
Register and ask your own question!

pt-table-sync --sync-to-mater option confused.

icesycicesyc EntrantInactive User Role Beginner
in the document I saw the example

pt-table-sync --execute --replicate test.checksum \ --sync-to-master slave1

and in the follow description, the documentation said

Be careful though: although this option specifies and syncs a single slave, if there are other slaves on the same master, they will receive via replication the changes intended for the slave that you’re trying to sync.

so I want to know, whether add the option or not, all the slave will be sync ?
does sync only one slave can be done with the --sync-to-master option?

Comments

  • psongpsong Contributor Inactive User Role Beginner
    When use --sync-to-master slave1, only the differences between slave1 and the master are the fix target. However, the tool does the sync by making changes on the master and so all slaves would receive the same queries.

    If the replication topology is master1, slave1, slave2, and table test.t1 has one id column with data as below:

    master1: 3 records, 1, 2, 3
    slave1: 1 record, 1
    slave2: 1 record, 2

    1) If you do
    pt-table-sync --execute --replicate test.checksum --sync-to-master slave1

    It would only attempt to sync slave1 to master1. The end result would be:

    master1: 1, 2, 3
    slave1: 1, 2, 3
    slave2: 2, 3

    Even if you didn't specify slave2 to be synced, it still receives the change sql and be affected.

    2) if you do
    pt-table-sync --execute --replicate test.checksum master1

    Then it would fix all slaves and the end result would be:
    master1: 1, 2, 3
    slave1: 1, 2, 3
    slave2: 1, 2, 3

    You can see the sql executed on the master by replacing --execute with --print.

    Hope this helps to clarify.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.