deadlock in mariadb: with non-index & fk table
The lack of a PK is a serious problem.  But there are other problems with the many:many table.  See here for 7 tips on an efficient mapping table.  In particular, you do need a composite PRIMARY KEY in order to prevent inserting duplicates.  At that point, INSERT IGNORE (or other techniques) can be efficiently used.