Stored procedure triggered on insert causes deadlock in transaction
Is there a better way to keep the constraint I'm trying to get (uniqueness on b and the YEAR of date d)?


Create virtual generated column which calculates value You'd like to be unique, and create unique secondary index over it. 

For more information read MySQL 5.7 Reference Manual / Secondary Indexes and Generated Columns