MariaDB: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails
Obviously this doesn't happen on all foreign keys so we suspect there was some corruption affecting that foreign key.

The solution was to drop and recreate the foreign key.