While the automation worked correctly for STATEMENT based replica sets, the primary master replication broke on ROW, because it complained with:
Slave_SQL_Running: No Last_Error: Could not execute Update_rows_v1 event on table heartbeat.heartbeat; Can't find record in 'heartbeat', Error_code: 1
Sep 18 21:27:14 db1220 mysqld[5222]: 2024-09-18 21:27:14 658112927 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='', master_port='3306', master_log_file='', master_log_pos='4'. New state master_host='db2196.codfw.wmnet', master_port='3306', master_log_file='db2196-bin.003331', master_log_pos='299799413'. Sep 18 21:27:15 db1220 mysqld[5222]: 2024-09-18 21:27:15 658112939 [Note] Slave I/O thread: Start asynchronous replication to master 'repl2024@db2196.codfw.wmnet:3306' in log 'db2196-bin.003331' at position 299799413 Sep 18 21:27:15 db1220 mysqld[5222]: 2024-09-18 21:27:15 658112939 [Note] Slave I/O thread: connected to master 'repl2024@db2196.codfw.wmnet:3306',replication started in log 'db2196-bin.003331' at position 299799413 Sep 18 21:27:17 db1220 mysqld[5222]: 2024-09-18 21:27:17 658112940 [ERROR] Slave SQL: Could not execute Update_rows_v1 event on table heartbeat.heartbeat; Can't find record in 'heartbeat', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log db2196-bin.003331, end_log_pos 299800037, Gtid 180360966-180360966-41321649, Internal MariaDB error code: 1032 Sep 18 21:27:17 db1220 mysqld[5222]: 2024-09-18 21:27:17 658112940 [Warning] Slave: Can't find record in 'heartbeat' Error_code: 1032 Sep 18 21:27:17 db1220 mysqld[5222]: 2024-09-18 21:27:17 658112940 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'db2196-bin.003331' position 299799413 Sep 18 21:27:17 db1220 mysqld[5222]: 2024-09-18 21:27:17 658112940 [Note] Slave SQL thread exiting, replication stopped in log 'db2196-bin.003331' at position 299799413, master: db2196.codfw.wmnet:3306
This is due to, once the secondary master starts pt-heartbeat-wikimedia, it generates an SQL REPLACE on the secondary, which gets written as a row_update into the ROW format binlog. The row, missing in the primary master, fails to be inserted, as it wants to update an existing row, not insert it. This doesn't affect STATEMENT masters as the REPLACE is kept, and it inserts or updates depending on the replica set automatically.
There are several options to overcome this, from switching to statement, to deleting the table fully to preinserting the row, but why did it used to work before? Was the row not used to be cleaned? Was there a special procedure before?