Skip to content

Improve performance of querying alert assignees - attempt 2

Sarah Yasonik requested to merge sy-alert-assignee-n-1-again into master

What does this MR do?

!33656 (merged) was reverted due to some unexpected conflicts (namely removal of support for FilterableArray in graphql connections). This MR reimplements that fix, with a slight adjustment to approach.

Context

Querying AlertManagementAlerts with the assignee field through the GraphQL API would result in a N+1 query.

This fixes the query by using LooksAhead to preload the assignee association before querying the DB.

This is currently behind a feature flag (:alert_assignee) which simply returns an empty collection if not enabled. I'm leaving the flag in place for now. This also requires the :graphql_lookahead_support feature flag to be enabled to see the performance improvement.

Related issue: #219571 (closed)

Blocks: #219571 (closed)

Screenshots

Graphql verification logs output
Screen_Shot_2020-06-09_at_7.59.39_PM Screen_Shot_2020-06-09_at_7.59.22_PM
UI verification logs output
Screen_Shot_2020-06-09_at_8.01.46_PM Screen_Shot_2020-06-09_at_8.10.03_PM

Out of scope: this solution only handles a single connection, as that is the important use case for our scenario. If this becomes a scenario we want to handle down the road, we can do that later.

So a query like this one would have a separate query for each alert:

{
  project(fullPath: "root/autodevops") {
		id
    fullPath
    alert5: alertManagementAlert(iid: "5") {
      iid
      status
      assignees {
        nodes {
          username
        }
      }
    }
    alert2: alertManagementAlert(iid: "2") {
      iid
      status
      assignees {
        nodes {
          username
        }
      }
    }
  }
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Rémy Coutable

Merge request reports