Skip to content

Commit

Permalink
Attempting to quash SQLite3::BusyException
Browse files Browse the repository at this point in the history
On occasion, our specs encounter a `SQLite3::BusyException` exception.
This commit, based on some Google-fu (actually DuckDuckGo-ing but
that's not yet in our vernacular), I found a few references that
involve increasing the `RAILS_MAX_THREADS` environment variable and/or
increasing the database timeout.

In CircleCI, for SHA 600753e and rspec
seed 3048, we encountered the problem. I don't assume that we can
duplicate this behavior with that configuration.

References

* https://stackoverflow.com/questions/7154664/ruby-sqlite3busyexception-database-is-locked
  • Loading branch information
jeremyf authored and Tom Johnson committed Feb 2, 2020
1 parent f9b75f2 commit 00316d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
environment:
RAILS_VERSION: << parameters.rails_version >>
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
RAILS_MAX_THREADS: 50
steps:
- samvera/cached_checkout
- samvera/bundle_for_gem:
Expand Down
2 changes: 1 addition & 1 deletion .regen
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
6
9 changes: 9 additions & 0 deletions tasks/hyrax_dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ if Gem.loaded_specs.key? 'engine_cart'
puts 'Creating default collection type...'
EngineCart.within_test_app do
raise "EngineCart failed on with: #{$?}" unless system "bundle exec rake hyrax:default_collection_types:create"

# Replace the default sqlite timeout to 15000 (which should triple the timeout). Based on some
# googling, this may help address the "ActiveRecord::StatementInvalid:SQLite3::BusyException:"
# exception that is occassionally breaking the build.
database_yml_content = File.read("config/database.yml")
new_database_yml_content = database_yml_content.gsub(/timeout: +(\d+)/, 'timeout: 15000')
File.open("config/database.yml", "w+") do |f|
f.puts new_database_yml_content
end
end
end
end
Expand Down

0 comments on commit 00316d0

Please sign in to comment.