Skip to content

Fix SQL statement timeout while fetching inactive projects

What does this MR do and why?

  • Use each_batch instead of find_each to traverse the table using primary index and prevent statement timeouts. This was tested on staging as well as production using rails console and it was observed that the statement timeouts does not happen if we use each_batch.
  • Monitor the elapsed time ofInactiveProjectsDeletionCronWorker and exit before 5 minutes to avoid breaching the maximum allowed execution latency for low urgency workers.
  • Update InactiveProjectsDeletionCronWorker to run at every 10th minute instead of running as we are exiting the worker after every 4 minutes now.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. The query timeout will not be reproducible in the development environment, however, we can verify the behaviour of the inactive projects deletion feature by following the same steps as mentioned in the initial MR.

MR acceptance checklist

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

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/363319

Merge request reports