Skip to content

Commit 800069b

Browse files
committed
Use the new SQLite3::Database#busy_handler_timeout= method for a non-GVL-blocking, fair retry interval busy handler implementation
1 parent ea0f0a2 commit 800069b

File tree

11 files changed

+17
-18
lines changed

11 files changed

+17
-18
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ platforms :ruby, :windows do
155155
gem "racc", ">=1.4.6", require: false
156156

157157
# Active Record.
158-
gem "sqlite3", ">= 1.6.6"
158+
gem "sqlite3", ">= 2.0"
159159

160160
group :db do
161161
gem "pg", "~> 1.3"

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ DEPENDENCIES
682682
sidekiq
683683
sneakers
684684
sprockets-rails (>= 2.0.0)
685-
sqlite3 (>= 1.6.6)
685+
sqlite3 (>= 2.0)
686686
stackprof
687687
stimulus-rails
688688
sucker_punch

activerecord/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* Replace `SQLite3::Database#busy_timeout` with `#busy_handler_timeout=`
2+
3+
Provides a non-GVL-blocking, fair retry interval busy handler implementation
4+
5+
*Stephen Margheim*
6+
17
* Add `ActiveRecord::Relation#readonly?`.
28

39
Reflects if the relation has been marked as readonly.

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -759,15 +759,8 @@ def reconnect
759759
end
760760

761761
def configure_connection
762-
if @config[:timeout] && @config[:retries]
763-
raise ArgumentError, "Cannot specify both timeout and retries arguments"
764-
elsif @config[:timeout]
765-
@raw_connection.busy_timeout(self.class.type_cast_config_to_integer(@config[:timeout]))
766-
elsif @config[:retries]
767-
retries = self.class.type_cast_config_to_integer(@config[:retries])
768-
raw_connection.busy_handler do |count|
769-
count <= retries
770-
end
762+
if @config[:timeout]
763+
@raw_connection.busy_handler_timeout = self.class.type_cast_config_to_integer(@config[:timeout]))
771764
end
772765

773766
super

guides/bug_report_templates/action_mailbox.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# If you want to test against edge Rails replace the previous line with this:
1010
# gem "rails", github: "rails/rails", branch: "main"
1111

12-
gem "sqlite3", "~> 1.4"
12+
gem "sqlite3", ">= 2.0"
1313
end
1414

1515
require "active_record/railtie"

guides/bug_report_templates/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# If you want to test against edge Rails replace the previous line with this:
1010
# gem "rails", github: "rails/rails", branch: "main"
1111

12-
gem "sqlite3", "~> 1.4"
12+
gem "sqlite3", ">= 2.0"
1313
end
1414

1515
require "active_record"

guides/bug_report_templates/active_record_migrations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# If you want to test against edge Rails replace the previous line with this:
1010
# gem "rails", github: "rails/rails", branch: "main"
1111

12-
gem "sqlite3", "~> 1.4"
12+
gem "sqlite3", ">= 2.0"
1313
end
1414

1515
require "active_record"

guides/bug_report_templates/active_storage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# If you want to test against edge Rails replace the previous line with this:
1010
# gem "rails", github: "rails/rails", branch: "main"
1111

12-
gem "sqlite3", "~> 1.4"
12+
gem "sqlite3", ">= 2.0"
1313
end
1414

1515
require "active_record/railtie"

railties/lib/rails/generators/database.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def port
223223
end
224224

225225
def gem
226-
["sqlite3", [">= 1.4"]]
226+
["sqlite3", [">= 2.0"]]
227227
end
228228

229229
def base_package

railties/test/generators/app_generator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def test_gemfile_has_no_whitespace_errors
472472
def test_config_database_is_added_by_default
473473
run_generator
474474
assert_file "config/database.yml", /sqlite3/
475-
assert_gem "sqlite3", '">= 1.4"'
475+
assert_gem "sqlite3", '">= 2.0"'
476476
end
477477

478478
def test_config_mysql_database

0 commit comments

Comments
 (0)