[ARVADOS] updated: 34d7bf56de6e43ff7f787e112ee88ffbc3056880
git at public.curoverse.com
git at public.curoverse.com
Wed Dec 3 15:40:26 EST 2014
Summary of changes:
.../api/app/controllers/database_controller.rb | 40 ++++++++++++----------
1 file changed, 21 insertions(+), 19 deletions(-)
discards f40cef415e71c144c4c3b70dc7456e97561920d3 (commit)
via 34d7bf56de6e43ff7f787e112ee88ffbc3056880 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (f40cef415e71c144c4c3b70dc7456e97561920d3)
\
N -- N -- N (34d7bf56de6e43ff7f787e112ee88ffbc3056880)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 34d7bf56de6e43ff7f787e112ee88ffbc3056880
Author: Tom Clegg <tom at curoverse.com>
Date: Wed Dec 3 15:40:18 2014 -0500
4533: Lock all tables before deleting contents.
diff --git a/services/api/app/controllers/database_controller.rb b/services/api/app/controllers/database_controller.rb
index a2e15ed..4c3f4d9 100644
--- a/services/api/app/controllers/database_controller.rb
+++ b/services/api/app/controllers/database_controller.rb
@@ -29,25 +29,33 @@ class DatabaseController < ApplicationController
fixturesets = Dir.glob(Rails.root.join('test', 'fixtures', '*.yml')).
collect { |yml| yml.match(/([^\/]*)\.yml$/)[1] }
- # Delete existing fixtures (and everything else) from fixture
- # tables
- fixturesets.each do |x|
- x.classify.constantize.unscoped.delete_all
+ ActiveRecord::Base.transaction do
+ # Avoid deadlock by locking all tables before doing anything
+ # drastic.
+ table_names = '"' + fixturesets.sort.join('","') + '"'
+ ActiveRecord::Base.connection.execute \
+ "LOCK TABLE #{table_names} IN SHARE ROW EXCLUSIVE MODE"
+
+ # Delete existing fixtures (and everything else) from fixture
+ # tables
+ fixturesets.each do |x|
+ x.classify.constantize.unscoped.delete_all
+ end
+
+ # create_fixtures() is a no-op for cached fixture sets, so
+ # uncache them all.
+ ActiveRecord::Fixtures.reset_cache
+ ActiveRecord::Fixtures.
+ create_fixtures(Rails.root.join('test', 'fixtures'), fixturesets)
+
+ # Dump cache of permissions etc.
+ Rails.cache.clear
+ ActiveRecord::Base.connection.clear_query_cache
+
+ # Reload database seeds
+ DatabaseSeeds.install
end
- # create_fixtures() is a no-op for cached fixture sets, so uncache
- # them all.
- ActiveRecord::Fixtures.reset_cache
- ActiveRecord::Fixtures.
- create_fixtures(Rails.root.join('test', 'fixtures'), fixturesets)
-
- # Dump cache of permissions etc.
- Rails.cache.clear
- ActiveRecord::Base.connection.clear_query_cache
-
- # Reload database seeds
- DatabaseSeeds.install
-
# Done.
render json: {success: true}
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list