We are hitting deadlocks on this query
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_acl_contact_cache WHERE contact_id IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)');
Since it is a delete clause with a subquery it locks the whole table rather than the relevant rows.
Logically this should be (possibly) done when the contact is trashed rather than at random access times. I say possibly because there is an implicit assumption the acled user cannot see deleted contacts in this action.
I took a look at the create clause and I feel like it is already aggressively clearing caches from there so adding a specific, non-locking delete clause to the deletecontact function should be enough to warrant removing this query.