diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-09 02:02:27 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-09 02:02:27 +0000 |
commit | 943be923f0d9a8d7248e5eb04595306cb31bf0da (patch) | |
tree | b2cee179434fb91fefe410f6bc8b8ba5097c57e9 /activerecord | |
parent | 8f93516168f8c4d89ca1cfafcb01ee4f9b1fc491 (diff) | |
download | rails-943be923f0d9a8d7248e5eb04595306cb31bf0da.tar.gz rails-943be923f0d9a8d7248e5eb04595306cb31bf0da.tar.bz2 rails-943be923f0d9a8d7248e5eb04595306cb31bf0da.zip |
Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception (closes #6126) [wreese@gmail.com] Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 3 | ||||
-rw-r--r-- | activerecord/test/connections/native_sqlite3/connection.rb | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 6ebfc9e8a4..a16e2bef02 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added timeout option to SQLite3 configurations to deal more gracefully with SQLite3::BusyException, now the connection can instead retry for x seconds to see if the db clears up before throwing that exception #6126 [wreese@gmail.com] + * Added update_attributes! which uses save! to raise an exception if a validation error prevents saving #6192 [jonathan] * Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [BobSilva] diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 308a21191d..db9aa2e717 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -19,6 +19,9 @@ module ActiveRecord :results_as_hash => true, :type_translation => false ) + + db.busy_timeout(config[:timeout]) unless config[:timeout].nil? + ConnectionAdapters::SQLiteAdapter.new(db, logger) end diff --git a/activerecord/test/connections/native_sqlite3/connection.rb b/activerecord/test/connections/native_sqlite3/connection.rb index 008ea686d6..6dbb2b98c1 100644 --- a/activerecord/test/connections/native_sqlite3/connection.rb +++ b/activerecord/test/connections/native_sqlite3/connection.rb @@ -11,7 +11,7 @@ sqlite_test_db = "#{BASE_DIR}/fixture_database.sqlite3" sqlite_test_db2 = "#{BASE_DIR}/fixture_database_2.sqlite3" def make_connection(clazz, db_file, db_definitions_file) - ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => db_file } } + ActiveRecord::Base.configurations = { clazz.name => { :adapter => 'sqlite3', :database => db_file, :timeout => 5000 } } unless File.exist?(db_file) puts "SQLite3 database not found at #{db_file}. Rebuilding it." sqlite_command = %Q{sqlite3 #{db_file} "create table a (a integer); drop table a;"} |