This seems related to #13800. We have a fairly large Matomo site, and PrivacyManager's deleteLogData task takes almost 4 hours to execute. This in itself is not really an issue, but at least the following query can take over 6 minutes to complete while keeping the database locked:
DELETE LOW_PRIORITY QUICK IGNORE piwik_log_action FROM piwik_log_action LEFT JOIN piwik_tmp_log_actions_to_keep tmp ON tmp.idaction = piwik_log_action.idaction WHERE tmp.idaction IS NULL
All the while tracking and Matomo UI remain inaccessible. I've been unable to catch the tmp table in time to see how large it was when this happens.