diff options
author | Nick Thomas <nick@gitlab.com> | 2019-02-20 18:35:57 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-03-27 19:51:33 +0300 |
commit | 0e831b0b692f2988d3c84fc01a463b08afec05ad (patch) | |
tree | 3fdcb423db62141b2db2d2cc3f39986fb929c8af /app/workers/schedule_migrate_external_diffs_worker.rb | |
parent | 98824f3e97e24a5d6cb0688167bc8411a74739fc (diff) |
Allow external diffs to be used conditionally
Since external diffs are likely to be a bit slower than in-database
ones, add a mode that makes diffs external after they've been obsoleted
by events. This should strike a balance between performance and disk
space.
A background cron drives the majority of migrations, since diffs become
outdated through user actions.
Diffstat (limited to 'app/workers/schedule_migrate_external_diffs_worker.rb')
-rw-r--r-- | app/workers/schedule_migrate_external_diffs_worker.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/workers/schedule_migrate_external_diffs_worker.rb b/app/workers/schedule_migrate_external_diffs_worker.rb new file mode 100644 index 00000000000..70910f7ca04 --- /dev/null +++ b/app/workers/schedule_migrate_external_diffs_worker.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: false + +class ScheduleMigrateExternalDiffsWorker + include ApplicationWorker + include CronjobQueue + include Gitlab::ExclusiveLeaseHelpers + + def perform + in_lock(self.class.name.underscore, ttl: 2.hours, retries: 0) do + MergeRequests::MigrateExternalDiffsService.enqueue! + end + rescue Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError + end +end |