1

Title really says it all. Here is the LAST_ERROR:

Last_Error: Error 'Cannot add or update a child row: a foreign key constraint fails
(`cd1n401`.`cdi_catalog_product_entity_int`, CONSTRAINT `FK_CDI_CAT_PRD_ENTT_INT_ENTT_ID_CDI_CAT_PRD_ENTT_ENTT_ID`
FOREIGN KEY (`entity_id`) REFERENCES `cdi_catalog_product_entity` (`entity_id`)' on query.
Default database: 'cd1n401'.
Query: 'INSERT INTO `cdi_catalog_product_entity_int` (`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`)
VALUES ('4', '178', '0', '3', NULL), ('4', '180', '0', '3', NULL), ('4', '181', '0', '3', NULL), ('4', '182', '0', '3', NULL)
ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)'

Has anyone setup a master slave before for magneto?

David Makogon
  • 2,768
  • 1
  • 20
  • 29

1 Answers1

0

Usually replication errors like that are caused by data inconsistencies between the master and the slave - the constraint was obviously satisfied on the master, since the query was successful, but it's not on the slave.

At that point, your entire (slave) database becomes suspect. You can track down the particular inconsistency and fix it manually, but how do you know that's the only one? The safe thing to do is start up a new slave, and once replication has caught up, kill the old one.

However, that's only fixing the symptom; you need to consider how the slave got out of sync with the master in the first place. By far the most common issue is running modification (that is, non-SELECT) commands on the slave. Unfortunately, you can't disable this completely, as MySQL's replication process needs write privileges, but you can audit who has privileges. Every human who has query access to the slave needs to know that they shouldn't run UPDATEs (and, ideally, limit their permissions so they can't). Every piece of code that talks to the slave similarly needs to only ever do SELECTs.

Another possible cause is that the process you used to create the slave's initial data set (e.g. bringing it up from a backup of the master) is flawed, and it started with an inconsistency before replication even ever started.

Xiong Chiamiov
  • 2,954
  • 2
  • 27
  • 30