Skip to content

Commit 64157d6

Browse files
committed
Mysql reconnect option was broken
There were two problems discovered after the release of 72.0 1. during config autoReconnect was firing in common cases and because @connection_parameters was not yet set the adapter was broken. 2. Processing of the reconnect: flag in db config would enable reconnect whether it was set to true or false. The other point is none of our tests ran into this because we do not permute through all the possible config values. Future work should be to at least create a simple app from scratch as part of a CI job so at least do not have failure out of the gate like this.
1 parent 93bf542 commit 64157d6

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/arjdbc/mysql/adapter.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,15 @@ def initialize(...)
7272
@config[:flags] ||= 0
7373

7474
# assign arjdbc extra connection params
75-
conn_params = build_connection_config(@config.compact)
75+
@connection_parameters = @config.compact.deep_dup
76+
build_connection_config(@connection_parameters)
7677

7778
# JDBC mysql appears to use found rows by default: https://dev.mysql.com/doc/connector-j/en/connector-j-connp-props-connection.html
7879
# if @config[:flags].kind_of? Array
7980
# @config[:flags].push "FOUND_ROWS"
8081
# else
8182
# @config[:flags] |= ::Mysql2::Client::FOUND_ROWS
8283
# end
83-
84-
@connection_parameters = conn_params
8584
end
8685

8786
def supports_json?

lib/arjdbc/mysql/adapter_hash_config.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
module ArJdbc
44
module MysqlConfig
55
def build_connection_config(config)
6-
config = config.deep_dup
7-
86
load_jdbc_driver
97

108
# don't set driver if it's explicitly set to false
@@ -61,7 +59,7 @@ def build_properties(config)
6159

6260
properties["connectionCollation"] ||= config[:collation] if config[:collation]
6361

64-
properties["autoReconnect"] ||= reconnect.to_s unless config[:reconnect].nil?
62+
properties["autoReconnect"] ||= reconnect.to_s if config[:reconnect]
6563

6664
properties["noDatetimeStringSync"] = true unless properties.key?("noDatetimeStringSync")
6765

0 commit comments

Comments
 (0)