Delete then insert occasionally fails with duplicate key
问题 We have a table that looks like this: appointment_id | team_id ----------------|--------- 1001 | 1 1005 | 4 1009 | 7 In this table appointment_id is the primary index and team_id is just a regular index. The code for creating the table: CREATE TABLE `appointment_primary_teams` ( `appointment_id` int(11) NOT NULL, `team_id` int(11) NOT NULL, PRIMARY KEY (`appointment_id`), KEY `team_id` (`team_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; However, occasionally the below code fails: // Even