User deletion times out due to resource_label_events nullifying

Summary

User deletion worker has DB timeout statements when user has lots of activities.

Steps to reproduce

  1. Check logs here
  2. See `PG::QueryCanceled: ERROR: canceling statement due to statement timeout CONTEXT: SQL statement "UPDATE ONLY "public"."resource_label_events" SET "user_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "user_id""

Relevant logs and/or screenshots

Check logs here

Output of checks

This bug happens on GitLab.com

Possible fixes

Use app/models/concerns/batch_nullify_dependent_associations.rb for resource_label_events to wipe column in batches.

Edited by Pavel Shutsin