Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1036 from dmann/DDS-916-db_data_migration_timeout…
Browse files Browse the repository at this point in the history
…_bug

DDS-916 db data migration timeout bug
  • Loading branch information
dmann committed Jul 19, 2017
2 parents da14e7f + b497ef2 commit 9153d8f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
25 changes: 15 additions & 10 deletions lib/tasks/db_data_migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,22 @@ def migrate_nil_consistency_status
storage_provider = StorageProvider.first
updated_projects = 0
updated_uploads = 0
Project.where(is_consistent: nil).each do |p|
unless p.is_deleted
if storage_provider.get_container_meta(p.id)
p.update_columns(is_consistent: true)
else
p.update_columns(is_consistent: false)
end
updated_projects += 1
projects = Project.where(is_consistent: nil).where.not(is_deleted: true)
puts "#{projects.count} projects with nil consistency_status."
projects.each do |p|
if storage_provider.get_container_meta(p.id)
p.update_columns(is_consistent: true)
else
p.update_columns(is_consistent: false)
end
print '.'
updated_projects += 1
end
puts "#{updated_projects} projects updated."

Upload.where(is_consistent: nil).each do |u|
uploads = Upload.where(is_consistent: nil)
puts "#{uploads.count} uploads with nil consistency_status."
uploads.each do |u|
begin
if storage_provider.get_object_metadata(u.project.id, u.id)
u.update_columns(is_consistent: true)
Expand All @@ -99,8 +103,9 @@ def migrate_nil_consistency_status
u.update_columns(is_consistent: false)
end
updated_uploads += 1
print '.'
end
$stderr.print "#{updated_projects} projects and #{updated_uploads} uploads updated consistency"
puts "#{updated_uploads} uploads updated."
end

namespace :db do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions spec/lib/tasks/db_data_migrate_rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
expect(storage_provider.get_container_meta(record.id)).not_to be_nil
}
it_behaves_like 'a consistency migration', :init_project_storage

context 'with deleted project' do
before(:each) { FactoryGirl.create(:project, :deleted, is_consistent: nil) }
it { expect {invoke_task}.not_to change{Project.where(is_consistent: nil).count} }
end
end

context 'for upload' do
Expand Down

0 comments on commit 9153d8f

Please sign in to comment.