summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-25 01:14:54 -0700
committerStan Hu <stanhu@gmail.com>2015-09-25 01:14:54 -0700
commitfbe5bf762d616c8bbe6e824bd0713e20f0751b74 (patch)
tree3b1d0be3bb115965b193b36eabf6ba52cb47b83b
parent1fef314df26a05bb204263129b12925ccfca0a90 (diff)
downloadgitlab-ce-fbe5bf762d616c8bbe6e824bd0713e20f0751b74.tar.gz
Fix bug where projects would appear to be stuck in the forked import state
A race condition existed between when Rails committed the `import_status` to `started` and when the Sidekiq worker forked a project. If this fork was quick, it's possible that the worker would attempt to move into the `finished` state before the `started` state took effect. As mentioned in https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting#cannot-find-modelname-with-id12345, we should delay the worker to ensure the DB has a chance to update. Closes #2736
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/project.rb4
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 20b6dce1764..256e445d7df 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased)
+ - Fix bug where projects would appear to be stuck in the forked import state (Stan Hu)
- Show CI status on all pages where commits list is rendered
- Automatically enable CI when push .gitlab-ci.yml file to repository
- Move CI charts to project graphs area
diff --git a/app/models/project.rb b/app/models/project.rb
index a7ea1236b86..5deddb2fbc4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -276,8 +276,10 @@ class Project < ActiveRecord::Base
end
def add_import_job
+ # Schedule these jobs after 2 seconds to ensure DB changes to import_status
+ # are saved by the time the workers start
if forked?
- unless RepositoryForkWorker.perform_async(id, forked_from_project.path_with_namespace, self.namespace.path)
+ unless RepositoryForkWorker.perform_in(2.seconds, id, forked_from_project.path_with_namespace, self.namespace.path)
import_fail
end
else