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

--bidirectional help. Choosing the correct right-column with greatest date.

mwild8mwild8 EntrantInactive User Role Beginner
Running the following command:

pt-table-sync --print --bidirectional --databases db1 --tables test --conflict-column update_in --conflict-comparison greatest h=h1 h=h2


Left:

+----+
+
+
+
| id | date_in | update_in | pet_name
+----+
+
+
+
| 1 | 2013-09-13 13:41:52 | NULL | kitty
| 3 | 2013-09-13 13:41:52 | NULL | dog
| 5 | 2013-09-13 13:41:52 | NULL | tiger
+----+
+
+
+


Right:

+----+
+
+
+
| id | date_in | update_in | pet_name
+----+
+
+
+
| 1 | 2013-09-13 13:41:52 | NULL | kitty
| 3 | 2013-09-13 13:41:52 | 2013-09-15 00:00:00 | dog_changed
| 5 | 2013-09-13 13:41:52 | NULL | tiger
+----+
+
+
+

I do not get any results. The goal is to bring row 3 over from the right server because the update_in field is the greatest.

Running:

pt-table-sync --print --sync-to-master h=h1,D=db1,t=test

Gives me the correct REPLACE INTO

REPLACE INTO `db1`.`test`(`id`, `date_in`, `update_in`, `pet_name`) VALUES ('3', '2013-09-13 13:41:52', '2013-09-15 00:00:00', 'dog_changed')


What is the best approach to explicitly choosing the greatest specified date record using bidirectional?

Thank you,

-Matt

Comments

  • mwild8mwild8 Entrant Inactive User Role Beginner
    I got it so it returns a result, but its the opposite from the newest 0_o

    pt-table-sync --print --bidirectional --databases db1--tables test--columns update_in --conflict-column update_in --conflict-comparison newest h=h1 h=h2

    /*h1*/ UPDATE `db1`.`test` SET `date_in`='2013-09-13 13:41:52', `update_in`='2013-09-01 00:00:00', `pet_name`='dog' WHERE `id`='3' LIMIT 1;

    It is attempting to use the "oldest" when I specify the newest. What exactly am I missing?
  • mwild8mwild8 Entrant Inactive User Role Beginner
    I have solved this issue. It was a mistake on my part.
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.