Skip to content

PropagateServiceTemplate for services with data tables

Arturo Herrero requested to merge 214834-propagate-service-tempate into master

What does this MR do?

Updating a service template performs an asynchronous creation of project services using PropagateServiceTemplate.

This propagation works fine except for those services that also have a separate table to store some fields data like issue_tracker_data, jira_tracker_data and open_project_tracker_data at the moment, see: https://gitlab.com/gitlab-org/gitlab/-/blob/v12.10.0-rc20200415152739-ee/app/models/project_services/data_fields.rb#L45-47

This commit extends the propagation to also cover the services with separate tables.

It also uses exec_query instead of execute which depending on the database connector can be more memory efficient. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-execute


database This propagation can create a potentially large number of records (update one service template, could create a service for each project of the GitLab instance).

We are doing:

  • Find project IDs
  • For each 100 (within a transaction):
    • INSERT INTO services ...
    • INSERT INTO *_tracker_data ... (Only if data_fields_present?)
    • UPDATE projects SET has_external_issue_tracker (Only if active_external_issue_tracker?)
    • UPDATE projects SET has_external_wiki (Only if active_external_wiki?)

Closes #214834 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports