Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/gpg_keys/destroy_service.rb')
-rw-r--r--app/services/gpg_keys/destroy_service.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/services/gpg_keys/destroy_service.rb b/app/services/gpg_keys/destroy_service.rb
index 2e82509897e..c8ee90db9f6 100644
--- a/app/services/gpg_keys/destroy_service.rb
+++ b/app/services/gpg_keys/destroy_service.rb
@@ -2,9 +2,24 @@
module GpgKeys
class DestroyService < Keys::BaseService
+ BATCH_SIZE = 1000
+
def execute(key)
+ nullify_signatures(key)
key.destroy
end
+
+ private
+
+ # 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
+ def nullify_signatures(key)
+ key.gpg_signatures.each_batch(of: BATCH_SIZE) do |batch|
+ batch.update_all(gpg_key_id: nil)
+ end
+ end
end
end