Nullify GPG signatures before destroying the key
When a GPG key is deleted, the related signatures have their gpg_key_id
column nullified. However, when the number of signatures is large, then a timeout may happen. The signatures are processed in batches before GPG key delete is attempted in order to avoid timeouts.
We have similar behavior for projects: https://gitlab.com/gitlab-org/gitlab/blob/064813598c0a0126090f1895f5f6b7b8ce2bec89/app/services/projects/destroy_service.rb#L132
Related issue: https://gitlab.com/gitlab-com/dev-sub-department/section-dev-request-for-help/-/issues/135+
Edited by Igor Drozdov