mirror of https://github.com/rails/rails
Allow SQLite3 `busy_handler` to be configured with simple max number of `retries`
Retrying busy connections without delay is a preferred practice for performance-sensitive applications. Add support for a `database.yml` `retries` integer, which is used in a simple `busy_handler` function to retry busy connections without exponential backoff up to the max number of `retries` .
This commit is contained in:
parent
d39ea2b2cd
commit
236a144b50
|
@ -1,3 +1,9 @@
|
|||
* Allow SQLite3 `busy_handler` to be configured with simple max number of `retries`
|
||||
|
||||
Retrying busy connections without delay is a preferred practice for performance-sensitive applications. Add support for a `database.yml` `retries` integer, which is used in a simple `busy_handler` function to retry busy connections without exponential backoff up to the max number of `retries`.
|
||||
|
||||
*Stephen Margheim*
|
||||
|
||||
* The SQLite3 adapter now supports `supports_insert_returning?`
|
||||
|
||||
Implementing the full `supports_insert_returning?` contract means the SQLite3 adapter supports auto-populated columns (#48241) as well as custom primary keys.
|
||||
|
|
|
@ -712,7 +712,16 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def configure_connection
|
||||
@raw_connection.busy_timeout(self.class.type_cast_config_to_integer(@config[:timeout])) if @config[:timeout]
|
||||
if @config[:timeout] && @config[:retries]
|
||||
raise ArgumentError, "Cannot specify both timeout and retries arguments"
|
||||
elsif @config[:timeout]
|
||||
@raw_connection.busy_timeout(self.class.type_cast_config_to_integer(@config[:timeout]))
|
||||
elsif @config[:retries]
|
||||
retries = self.class.type_cast_config_to_integer(@config[:retries])
|
||||
raw_connection.busy_handler do |count|
|
||||
count <= retries
|
||||
end
|
||||
end
|
||||
|
||||
raw_execute("PRAGMA foreign_keys = ON", "SCHEMA")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue