Fix SQL statement timeout while fetching inactive projects
What does this MR do and why?
- Use
each_batch
instead offind_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 useeach_batch
. - Monitor the elapsed time of
InactiveProjectsDeletionCronWorker
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.
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/363319