Skip to content

Commit

Permalink
Added timeout option to SQLite3 configurations to deal more gracefull…
Browse files Browse the repository at this point in the history
…y 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
  • Loading branch information
dhh committed Oct 9, 2006
1 parent 8f93516 commit 943be92
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions 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]
Expand Down
Expand Up @@ -19,6 +19,9 @@ def sqlite3_connection(config) # :nodoc:
:results_as_hash => true,
:type_translation => false
)

db.busy_timeout(config[:timeout]) unless config[:timeout].nil?

ConnectionAdapters::SQLiteAdapter.new(db, logger)
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/connections/native_sqlite3/connection.rb
Expand Up @@ -11,7 +11,7 @@ class SqliteError < StandardError
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;"}
Expand Down
2 changes: 2 additions & 0 deletions railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Added default timeout setting of 5 seconds to SQLite3 database.yml configurations [DHH]

* Added generated attribute options to script/generate model, like the one found in scaffold_resource and resource [DHH]. Examples:

./script/generate model post title:string created_on:date body:text published:boolean
Expand Down
3 changes: 3 additions & 0 deletions railties/configs/databases/sqlite3.yml
Expand Up @@ -3,14 +3,17 @@
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000

0 comments on commit 943be92

Please sign in to comment.