LP #1004567: pt-heartbeat --update --replace causes duplicate key error
Description
Environment
Smart Checklist
Activity

lpjirasync January 24, 2018 at 3:39 PM
**Comment from Launchpad by: Daniel Nichter on: 20-07-2012 22:14:26
WontFix 1.0, just the fix but not the test in 2.0 (because the 2.1 test suite is different than 2.0), fix and test in 2.1.

lpjirasync January 24, 2018 at 3:39 PM
**Comment from Launchpad by: Baron Schwartz on: 29-06-2012 19:26:33
See also bug 885938.

lpjirasync January 24, 2018 at 3:39 PM
**Comment from Launchpad by: Baron Schwartz on: 29-06-2012 19:26:05
I believe the problem may be caused by this bit of code:
3586 my $row = $dbh->selectall_arrayref($sql);
3587 if ( scalar @$row == 0 ) {
3588 PTDEBUG && _d('No heartbeat row in table');
3589 if ( $o->get('insert-heartbeat-row') ) {
3590 my $sql = "INSERT INTO $db_tbl ($pk_col, ts) "
3591 . "VALUES ('$pk_val', NOW())";
3592 PTDEBUG && _d($sql);
3593 $dbh->do($sql);
3594 }
This doesn't respect the REPLACE options.

lpjirasync January 24, 2018 at 3:39 PM
**Comment from Launchpad by: Mark W on: 31-05-2012 16:31:57
I updated pt-heartbeat to 2.1.1 but i have not failed over to test.
I also stop the cron job that runs every 10 minutes that cleans up the table.
I have no planned maintenance at this time but something always comes up.
I will report back in on my next failover which probably happen sometime in next 30 days.

lpjirasync January 24, 2018 at 3:39 PM
**Comment from Launchpad by: Baron Schwartz on: 31-05-2012 16:11:21
Have you tried with the newest version of Percona Toolkit, or are you still looking at the old version?
Details
Assignee
UnassignedUnassignedReporter
lpjirasynclpjirasync(Deactivated)Priority
High
Details
Details
Assignee
Reporter

Priority
Smart Checklist
Open Smart Checklist
Smart Checklist
Open Smart Checklist
Smart Checklist

**Reported in Launchpad by Mark W last update 10-08-2012 18:15:18
I am using pt-heartbeat with MySQL that is configured in a HA setup.
LoadBalancer(VIP)
M1(RW)<--->M2(RW)
----+
S1(R) S2(R)
I am using pt-heartbeat version 1.0.1
I send out a heartbeat every two minutes to the active writer via cron
to the load balancer Virtual IP Address.
*/2 * * * * /usr/bin/pt-heartbeat -D test --update --replace --create-
table -h LBVIP -P LBPORT --run-time 1
When I do a failover I get duplicate key errors on the secondary
master M2. On failback i get duplicate key error on Master M1.
Last_Error: Error 'Duplicate entry '8806' for key 'PRIMARY'' on query.
Default database: 'test'. Query: 'INSERT INTO `test`.`heartbeat`
(server_id, ts) VALUES ('8806', NOW())'
I am using the --update --replace options but i believe based on my
replication errors that it is doing an insert not a replace.
Am i hitting a bug with pt-heartbeat or do i have to change my method
of sending heartbeat?