Skip to content

Move updating statistics logic outside of the transaction

What does this MR do and why?

Updating the vulnerability statistics within a transaction causes the concurrent queries to take a long time if they are trying to update the same vulnerability statistics record. To mitigate this issue, we could move updating the statistics query to be the last SQL query within the transaction but since the statistics information is not a mission-critical one, I've decided to move it out from the transaction to reduce the overhead of updating it for concurrent queries.

The previous sequence of queries was like this;

  1. Begin the transaction
  2. Update the vulnerability
  3. Update the statistics
  4. Create a note
  5. Commit the transaction

With this MR the sequence will be;

  1. Begin the transaction
  2. Update the vulnerability
  3. Create a note
  4. Commit the transaction
  5. Update the statistics

Related to gitlab-com/gl-infra/production#6609 (closed)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mehmet Emin INAC

Merge request reports

Loading