Commit ec30d98a authored by Andreas Brandl's avatar Andreas Brandl

Swap conditions to reduce frequency of database query

The `Gitlab::Mirror.reschedule_immediately?` performs a rather heavy
query and it was detected that this is the major contributor to total
query time on GitLab.com (50% of total time is spent in this query!).

Context: https://gitlab.com/gitlab-org/gitlab-ce/issues/60524
parent b31b74e1
......@@ -35,7 +35,7 @@ class RepositoryUpdateMirrorWorker
fail_mirror(project, ex.message)
raise UpdateError, "#{ex.class}: #{ex.message}"
ensure
if !lease.exists? && Gitlab::Mirror.reschedule_immediately? && lease.try_obtain
if !lease.exists? && lease.try_obtain && Gitlab::Mirror.reschedule_immediately?
UpdateAllMirrorsWorker.perform_async
end
end
......
---
title: Swap conditions to reduce frequency of database query
merge_request: 11217
author:
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment