From b653093ac5470069839bbcf68e091d027b5825c7 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 13:26:26 +0900 Subject: [PATCH 01/18] use rails 6.1 --- Gemfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 3f655e3e..9b9177f1 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source "https://rubygems.org" gemspec -gem "rails", "6.0.6.1" +gem "rails", "6.1.7.7" -gem "actionview", "6.0.6.1" -gem "activerecord", "6.0.6.1" -gem "activesupport", "6.0.6.1" +gem "actionview", "6.1.7.7" +gem "activerecord", "6.1.7.7" +gem "activesupport", "6.1.7.7" From 28ce04f420c01c86e1c5b4fe3bee725a0914daa8 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 13:26:42 +0900 Subject: [PATCH 02/18] fix retrieve_connection_pool args for ar6.1 --- .../connection_handler_extension.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext/connection_handler_extension.rb b/lib/active_record/turntable/active_record_ext/connection_handler_extension.rb index 77559d47..f4fe30b4 100644 --- a/lib/active_record/turntable/active_record_ext/connection_handler_extension.rb +++ b/lib/active_record/turntable/active_record_ext/connection_handler_extension.rb @@ -5,10 +5,18 @@ def owner_to_turntable_pool @owner_to_turntable_pool ||= Concurrent::Map.new(initial_capacity: 2) end - # @note Override not to establish_connection destroy existing connection pool proxy object - def retrieve_connection_pool(spec_name) - owner_to_turntable_pool.fetch(spec_name) do - super + if Util.ar_version_equals_or_later?("6.1.0") + def retrieve_connection_pool(spec_name, role: ActiveRecord::Base.current_role, shard: ActiveRecord::Base.current_shard) + owner_to_turntable_pool.fetch(spec_name) do + super + end + end + else + # @note Override not to establish_connection destroy existing connection pool proxy object + def retrieve_connection_pool(spec_name) + owner_to_turntable_pool.fetch(spec_name) do + super + end end end end From 4286cea26e9ce1df1ab74e089e0913d52f6e5a02 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 13:30:44 +0900 Subject: [PATCH 03/18] fix rm spec from ar6.1 --- .../turntable/active_record_ext/database_tasks.rb | 7 ++++++- lib/active_record/turntable/seq_shard.rb | 7 ++++++- lib/active_record/turntable/shard.rb | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext/database_tasks.rb b/lib/active_record/turntable/active_record_ext/database_tasks.rb index 767a9b76..d33794f9 100644 --- a/lib/active_record/turntable/active_record_ext/database_tasks.rb +++ b/lib/active_record/turntable/active_record_ext/database_tasks.rb @@ -45,7 +45,12 @@ def each_current_turntable_cluster_connected(environment) yield(name, configuration) end ActiveRecord::Base.clear_active_connections! - ActiveRecord::Base.establish_connection old_connection_pool.spec.config + config = if old_connection_pool.respond_to?(:db_config) + old_connection_pool.db_config.configuration_hash + else + old_connection_pool.spec.config + end + ActiveRecord::Base.establish_connection config end def each_current_turntable_cluster_configuration(environment) diff --git a/lib/active_record/turntable/seq_shard.rb b/lib/active_record/turntable/seq_shard.rb index c88e3b7b..291bf690 100644 --- a/lib/active_record/turntable/seq_shard.rb +++ b/lib/active_record/turntable/seq_shard.rb @@ -17,7 +17,12 @@ def connection_class_instance klass = Class.new(ActiveRecord::Base) Connections.const_set(name.classify, klass) klass.abstract_class = true - klass.establish_connection ActiveRecord::Base.connection_pool.spec.config[:seq][name].with_indifferent_access + config = if ActiveRecord::Base.connection_pool.respond_to?(:db_config) + ActiveRecord::Base.connection_pool.db_config.configuration_hash + else + ActiveRecord::Base.connection_pool.spec.config + end + klass.establish_connection config[:seq][name].with_indifferent_access end klass end diff --git a/lib/active_record/turntable/shard.rb b/lib/active_record/turntable/shard.rb index 7ae29e22..a120e163 100644 --- a/lib/active_record/turntable/shard.rb +++ b/lib/active_record/turntable/shard.rb @@ -52,7 +52,12 @@ def connection_class_instance klass = Class.new(ActiveRecord::Base) Connections.const_set(name.classify, klass) klass.abstract_class = true - klass.establish_connection ActiveRecord::Base.connection_pool.spec.config[:shards][name].with_indifferent_access + config = if ActiveRecord::Base.connection_pool.respond_to?(:db_config) + ActiveRecord::Base.connection_pool.db_config.configuration_hash + else + ActiveRecord::Base.connection_pool.spec.config + end + klass.establish_connection config[:shards][name].with_indifferent_access end klass end From 727d071486b8f86c835b36c6ae338d1ae97e69ec Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 13:32:49 +0900 Subject: [PATCH 04/18] fix add_to_transaction args for ar6.1 --- .../active_record_ext/transactions.rb | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext/transactions.rb b/lib/active_record/turntable/active_record_ext/transactions.rb index 3ca64cda..37deed79 100644 --- a/lib/active_record/turntable/active_record_ext/transactions.rb +++ b/lib/active_record/turntable/active_record_ext/transactions.rb @@ -5,6 +5,7 @@ module Transactions def with_transaction_returning_status klass = self.class return super unless klass.turntable_enabled? + ensure_finalize = !klass.connection.transaction_open? if Util.ar61_or_later? status = nil if self.new_record? && self.turntable_shard_key.to_s == klass.primary_key && @@ -12,7 +13,10 @@ def with_transaction_returning_status self.id = klass.next_sequence_value end self.class.connection.shards_transaction([self.turntable_shard]) do - if Util.ar60_or_later? + if Util.ar61_or_later? + add_to_transaction(ensure_finalize || has_transactional_callbacks?) + remember_transaction_record_state + elsif Util.ar60_or_later? if has_transactional_callbacks? add_to_transaction else @@ -40,19 +44,26 @@ def with_transaction_returning_status end end - def add_to_transaction - return super unless self.class.turntable_enabled? + if Util.ar_version_equals_or_later?("6.1.0") + def add_to_transaction(ensure_finalize = true) + return super unless self.class.turntable_enabled? + self.turntable_shard.connection.add_transaction_record(self, ensure_finalize) + end + else + def add_to_transaction + return super unless self.class.turntable_enabled? - if Util.ar60_or_later? - self.turntable_shard.connection.add_transaction_record(self) - else - if has_transactional_callbacks? + if Util.ar60_or_later? self.turntable_shard.connection.add_transaction_record(self) else - sync_with_transaction_state - set_transaction_state(self.turntable_shard.connection.transaction_state) + if has_transactional_callbacks? + self.turntable_shard.connection.add_transaction_record(self) + else + sync_with_transaction_state + set_transaction_state(self.turntable_shard.connection.transaction_state) + end + remember_transaction_record_state end - remember_transaction_record_state end end end From 977988b42cf7b09190a8712ff2c280d2f6253fe9 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 16:38:24 +0900 Subject: [PATCH 05/18] fix frozen attribute_names for AR6.1 --- .../turntable/active_record_ext/locking_optimistic.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/active_record/turntable/active_record_ext/locking_optimistic.rb b/lib/active_record/turntable/active_record_ext/locking_optimistic.rb index dfffa449..86f49f3d 100644 --- a/lib/active_record/turntable/active_record_ext/locking_optimistic.rb +++ b/lib/active_record/turntable/active_record_ext/locking_optimistic.rb @@ -11,6 +11,7 @@ def _update_row(attribute_names, attempted_action = "update") begin locking_column = self.class.locking_column previous_lock_value = read_attribute_before_type_cast(locking_column) + attribute_names = attribute_names.dup if attribute_names.frozen? attribute_names << locking_column self[locking_column] += 1 From 823a316b642dcf75616ca07de259f20ef6f9e174 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 16:38:59 +0900 Subject: [PATCH 06/18] merge PR #41082 in rails --- .../active_record_ext/locking_optimistic.rb | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/active_record/turntable/active_record_ext/locking_optimistic.rb b/lib/active_record/turntable/active_record_ext/locking_optimistic.rb index 86f49f3d..765190cb 100644 --- a/lib/active_record/turntable/active_record_ext/locking_optimistic.rb +++ b/lib/active_record/turntable/active_record_ext/locking_optimistic.rb @@ -1,7 +1,50 @@ module ActiveRecord::Turntable module ActiveRecordExt module LockingOptimistic - if Util.ar_version_equals_or_later?("5.1.6") + if Util.ar_version_equals_or_later?("6.1.2") + ::ActiveRecord::Locking::Optimistic.class_eval <<-EOD + private + + def _update_row(attribute_names, attempted_action = "update") + return super unless locking_enabled? + + begin + locking_column = self.class.locking_column + lock_attribute_was = @attributes[locking_column] + lock_value_for_database = _lock_value_for_database(locking_column) + + attribute_names = attribute_names.dup if attribute_names.frozen? + attribute_names << locking_column + + self[locking_column] += 1 + + constraints = { + @primary_key => id_in_database, + locking_column => lock_value_for_database + } + if self.class.sharding_condition_needed? + constraints[self.class.turntable_shard_key] = self[self.class.turntable_shard_key] + end + + affected_rows = self.class._update_record( + attributes_with_values(attribute_names), + constraints + ) + + if affected_rows != 1 + raise ActiveRecord::StaleObjectError.new(self, attempted_action) + end + + affected_rows + + # If something went wrong, revert the locking_column value. + rescue Exception + @attributes[locking_column] = lock_attribute_was + raise + end + end + EOD + elsif Util.ar_version_equals_or_later?("5.1.6") ::ActiveRecord::Locking::Optimistic.class_eval <<-EOD private From 8e592732d25f94bfe076f1ccd815702fc26996d7 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 16:45:34 +0900 Subject: [PATCH 07/18] fix for froozen VALID_OPTIONS --- lib/active_record/turntable/active_record_ext.rb | 1 + .../turntable/active_record_ext/association.rb | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext.rb b/lib/active_record/turntable/active_record_ext.rb index 187efbbe..fe19f5ab 100644 --- a/lib/active_record/turntable/active_record_ext.rb +++ b/lib/active_record/turntable/active_record_ext.rb @@ -32,6 +32,7 @@ module ActiveRecordExt ActiveRecord::ConnectionAdapters::ConnectionHandler.prepend(ConnectionHandlerExtension) ActiveRecord::Associations::Preloader::Association.prepend(AssociationPreloader) ActiveRecord::Associations::Association.prepend(Association) + ActiveRecord::Associations::Builder::Association.singleton_class.prepend(Builder::Association) ActiveRecord::QueryCache.prepend(QueryCache) require "active_record/turntable/active_record_ext/fixtures" require "active_record/turntable/active_record_ext/migration_proxy" diff --git a/lib/active_record/turntable/active_record_ext/association.rb b/lib/active_record/turntable/active_record_ext/association.rb index d781f376..885c9e25 100644 --- a/lib/active_record/turntable/active_record_ext/association.rb +++ b/lib/active_record/turntable/active_record_ext/association.rb @@ -2,13 +2,17 @@ module ActiveRecord::Turntable module ActiveRecordExt + module Builder + module Association + def valid_options(options) + super + [:foreign_shard_key] + end + end + end + module Association include ShardingCondition - def self.prepended(mod) - ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :foreign_shard_key - end - protected # @note Override to pass shard key conditions From bcf18979fa174dcfe710b3c61dfd88660f7f0e2e Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Thu, 16 May 2024 18:09:25 +0900 Subject: [PATCH 08/18] fix configuration on migrate for AR6.1 --- .../turntable/active_record_ext/database_tasks.rb | 8 +++++++- lib/active_record/turntable/migration.rb | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext/database_tasks.rb b/lib/active_record/turntable/active_record_ext/database_tasks.rb index d33794f9..fcb8ec3e 100644 --- a/lib/active_record/turntable/active_record_ext/database_tasks.rb +++ b/lib/active_record/turntable/active_record_ext/database_tasks.rb @@ -1,4 +1,5 @@ require "active_record/tasks/database_tasks" +require "active_record/turntable/util" module ActiveRecord module Tasks @@ -79,7 +80,12 @@ def each_local_turntable_cluster_configuration def current_turntable_cluster_configurations(*environments) configurations = [] environments.each do |environ| - config = ActiveRecord::Base.configurations[environ] + config = if ActiveRecord::Turntable::Util.ar61_or_later? + configs = ActiveRecord::Base.configurations.configs_for(env_name: environ.to_s).map(&:configuration_hash) + configs&.find { |conf| conf.key?("shards") || conf.key?(:shards) }&.stringify_keys + else + ActiveRecord::Base.configurations[environ] + end next unless config %w(shards seq).each do |name| configurations += config[name].to_a if config.has_key?(name) diff --git a/lib/active_record/turntable/migration.rb b/lib/active_record/turntable/migration.rb index 7f9f8dc5..4526a4a1 100644 --- a/lib/active_record/turntable/migration.rb +++ b/lib/active_record/turntable/migration.rb @@ -52,7 +52,13 @@ def target_shard?(shard_name) def migrate(*args) return super(*args) if target_shards.blank? - config = ActiveRecord::Base.configurations[ActiveRecord::Turntable::RackupFramework.env||"development"] + env = ActiveRecord::Turntable::RackupFramework.env || "development" + config = if ActiveRecord::Turntable::Util.ar_version_equals_or_later?("6.1.0") + configs = ActiveRecord::Base.configurations.configs_for(env_name: env.to_s).map(&:configuration_hash) + configs.find { |conf| conf.key?("shards") || conf.key?(:shards) }&.stringify_keys + else + ActiveRecord::Base.configurations[env] + end shard_conf = target_shards.map { |shard| [shard, config["shards"][shard]] }.to_h seqs_conf = target_seqs.map { |seq| [seq, config["seq"][seq]] }.to_h From 1a139975504c8590b8cd022eb018f9010bca79a0 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:39:44 +0900 Subject: [PATCH 09/18] fix require thread_safe --- activerecord-turntable.gemspec | 1 + lib/active_record/turntable/connection_proxy.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/activerecord-turntable.gemspec b/activerecord-turntable.gemspec index 4fc25ae3..5efd0bee 100644 --- a/activerecord-turntable.gemspec +++ b/activerecord-turntable.gemspec @@ -27,6 +27,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "activesupport", ">= 5.0", "< 7.0" spec.add_runtime_dependency "bsearch", "~> 1.5" spec.add_runtime_dependency "sql_tree", "= 0.2.0" + spec.add_runtime_dependency "thread_safe" # optional dependencies spec.add_development_dependency "activerecord-import" diff --git a/lib/active_record/turntable/connection_proxy.rb b/lib/active_record/turntable/connection_proxy.rb index b1e46840..d77360c4 100644 --- a/lib/active_record/turntable/connection_proxy.rb +++ b/lib/active_record/turntable/connection_proxy.rb @@ -1,4 +1,5 @@ require "active_record/turntable/connection_proxy/mixable" +require "thread_safe" module ActiveRecord::Turntable class ConnectionProxy From 3ef87ec9992cbc3b38e446721f3dce12f517b886 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:40:14 +0900 Subject: [PATCH 10/18] define ar60_or_later? --- lib/active_record/turntable/util.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/active_record/turntable/util.rb b/lib/active_record/turntable/util.rb index 3137b6e8..5310b61e 100644 --- a/lib/active_record/turntable/util.rb +++ b/lib/active_record/turntable/util.rb @@ -39,6 +39,10 @@ def ar60_or_later? ar_version_equals_or_later?("6.0") end + def ar61_or_later? + ar_version_equals_or_later?("6.1") + end + module_function :ar_version_equals_or_later?, :ar_version_earlier_than?, :ar_version, @@ -47,6 +51,7 @@ def ar60_or_later? :earlier_than_ar51?, :ar51_or_later?, :ar52_or_later?, - :ar60_or_later? + :ar60_or_later?, + :ar61_or_later? end end From 866735d6823c2e97968c91d0298b033f68896831 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 14:48:11 +0900 Subject: [PATCH 11/18] update rspec-rails gems for AR6.1 --- activerecord-turntable.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord-turntable.gemspec b/activerecord-turntable.gemspec index 5efd0bee..2e896126 100644 --- a/activerecord-turntable.gemspec +++ b/activerecord-turntable.gemspec @@ -50,7 +50,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rspec-collection_matchers" spec.add_development_dependency "rspec-its" spec.add_development_dependency "rspec-parameterized" - spec.add_development_dependency "rspec-rails" + spec.add_development_dependency "rspec-rails", "~> 4.1.0" spec.add_development_dependency "rubocop" spec.add_development_dependency "rubocop-rspec" spec.add_development_dependency "timecop" From 115736d39ed7ffb06066ea2dfc42c2eceaa0ac29 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:47:46 +0900 Subject: [PATCH 12/18] fix fixture for legacy_saved_pool_config from AR6.1 --- .../turntable/active_record_ext/fixtures.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/active_record/turntable/active_record_ext/fixtures.rb b/lib/active_record/turntable/active_record_ext/fixtures.rb index 18986fa7..61214ba8 100644 --- a/lib/active_record/turntable/active_record_ext/fixtures.rb +++ b/lib/active_record/turntable/active_record_ext/fixtures.rb @@ -83,16 +83,11 @@ def setup_fixtures(config = ActiveRecord::Base) @fixture_connections = [] @@already_loaded_fixtures ||= {} @connection_subscriber = nil + @legacy_saved_pool_configs = Hash.new { |hash, key| hash[key] = {} } + @saved_pool_configs = Hash.new { |hash, key| hash[key] = {} } # Load fixtures once and begin transaction. if run_in_transaction? - - # # Support AciveRecrd version 6.0.4 - # # https://github.com/rails/rails/blame/v6.0.4/activerecord/lib/active_record/test_fixtures.rb#L115 - if ActiveRecord::Turntable::Util.ar_version_equals_or_later?("6.0.4") - @saved_pool_configs = Hash.new { |hash, key| hash[key] = {} } - end - if @@already_loaded_fixtures[self.class] @loaded_fixtures = @@already_loaded_fixtures[self.class] else From d359d69079ce95ec444fcf2ed3bc4e084616038c Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:48:16 +0900 Subject: [PATCH 13/18] fix update_attributes method in test for AR6.0 --- .../turntable/active_record_ext/locking_optimistic_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/active_record/turntable/active_record_ext/locking_optimistic_spec.rb b/spec/active_record/turntable/active_record_ext/locking_optimistic_spec.rb index 793de993..791fc766 100644 --- a/spec/active_record/turntable/active_record_ext/locking_optimistic_spec.rb +++ b/spec/active_record/turntable/active_record_ext/locking_optimistic_spec.rb @@ -22,7 +22,11 @@ describe "Json serialized column is saved" do before do - user_profile.update_attributes(data: { foo: "bar" }) + if ActiveRecord::Turntable::Util.ar60_or_later? + user_profile.update(data: { foo: "bar" }) + else + user_profile.update_attributes(data: { foo: "bar" }) + end user_profile.reload end From f4e542baae5aea83f27a42a9790cbbaf48c2bbe4 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:55:36 +0900 Subject: [PATCH 14/18] fix dumper test with charset from AR6.1 --- .../turntable/active_record_ext/schema_dumper_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/active_record/turntable/active_record_ext/schema_dumper_spec.rb b/spec/active_record/turntable/active_record_ext/schema_dumper_spec.rb index 80189f30..b55722ae 100644 --- a/spec/active_record/turntable/active_record_ext/schema_dumper_spec.rb +++ b/spec/active_record/turntable/active_record_ext/schema_dumper_spec.rb @@ -10,7 +10,9 @@ def dump_schema context "#dump" do subject { dump_schema } - if ActiveRecord::Turntable::Util.ar_version_equals_or_later?("5.0.1") + if ActiveRecord::Turntable::Util.ar61_or_later? + it { is_expected.to match(/create_sequence_for "users", force: :cascade, charset: "[^"]+", comment: "[^"]+"$/) } + elsif ActiveRecord::Turntable::Util.ar_version_equals_or_later?("5.0.1") it { is_expected.to match(/create_sequence_for "users", force: :cascade, options: "[^"]+", comment: "[^"]+"$/) } else it { is_expected.to match(/create_sequence_for "users", force: :cascade, options: "[^"]+"/) } From 0cc4d740440813f2055ca872e613e2127d3b4b83 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 13:56:00 +0900 Subject: [PATCH 15/18] update unsupported proxy method in test --- spec/active_record/turntable/pool_proxy_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/active_record/turntable/pool_proxy_spec.rb b/spec/active_record/turntable/pool_proxy_spec.rb index 873f8173..26105bf4 100644 --- a/spec/active_record/turntable/pool_proxy_spec.rb +++ b/spec/active_record/turntable/pool_proxy_spec.rb @@ -4,7 +4,8 @@ context "When initialized" do subject { ActiveRecord::Turntable::PoolProxy.new(nil) } - UNSUPPORTED_PROXY_METHODS = %i[checkout checkin stat lock_thread= remove num_waiting_in_queue].freeze + # TODO: should support AR 6.1 methods (connection_klass discarded? pool_config db_config) + UNSUPPORTED_PROXY_METHODS = %i[checkout checkin stat lock_thread= remove num_waiting_in_queue connection_klass discarded? pool_config db_config].freeze context "Comparing original connection pool" do (ActiveRecord::ConnectionAdapters::ConnectionPool.instance_methods(false) - UNSUPPORTED_PROXY_METHODS).each do |original_method| From ae99e247f3ce65d589309da4777d63b8461e0b2b Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 15:02:11 +0900 Subject: [PATCH 16/18] add ar6.1.z to appraisals and actions --- .github/workflows/test_ruby_2_7.yml | 3 +- .github/workflows/test_ruby_3_0.yml | 3 +- Appraisals | 72 +++++++++++++++++++++++++++++ activerecord-turntable.gemspec | 2 +- gemfiles/rails6_1_0.gemfile | 12 +++++ gemfiles/rails6_1_1.gemfile | 12 +++++ gemfiles/rails6_1_2.gemfile | 12 +++++ gemfiles/rails6_1_3.gemfile | 12 +++++ gemfiles/rails6_1_4.gemfile | 12 +++++ gemfiles/rails6_1_5.gemfile | 12 +++++ gemfiles/rails6_1_6.gemfile | 12 +++++ gemfiles/rails6_1_7.gemfile | 12 +++++ 12 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 gemfiles/rails6_1_0.gemfile create mode 100644 gemfiles/rails6_1_1.gemfile create mode 100644 gemfiles/rails6_1_2.gemfile create mode 100644 gemfiles/rails6_1_3.gemfile create mode 100644 gemfiles/rails6_1_4.gemfile create mode 100644 gemfiles/rails6_1_5.gemfile create mode 100644 gemfiles/rails6_1_6.gemfile create mode 100644 gemfiles/rails6_1_7.gemfile diff --git a/.github/workflows/test_ruby_2_7.yml b/.github/workflows/test_ruby_2_7.yml index 401071d9..abf89276 100644 --- a/.github/workflows/test_ruby_2_7.yml +++ b/.github/workflows/test_ruby_2_7.yml @@ -10,7 +10,8 @@ jobs: arversion: ['5_0_0', '5_0_1', '5_0_2', '5_0_3', '5_0_4', '5_0_5', '5_0_6', '5_0_7', '5_1_0', '5_1_1', '5_1_2', '5_1_3', '5_1_4', '5_1_5', '5_1_6', '5_1_7', '5_2_0', '5_2_1', '5_2_2', '5_2_3', '5_2_4', '5_2_5', '5_2_6', '5_2_7', '5_2_8', - '6_0_0', '6_0_1', '6_0_2', '6_0_3', '6_0_4', '6_0_5', '6_0_6'] + '6_0_0', '6_0_1', '6_0_2', '6_0_3', '6_0_4', '6_0_5', '6_0_6', + '6_1_0', '6_1_1', '6_1_2', '6_1_3', '6_1_4', '6_1_5', '6_1_6', '6_1_7'] runs-on: ubuntu-22.04 env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails${{ matrix.arversion }}.gemfile diff --git a/.github/workflows/test_ruby_3_0.yml b/.github/workflows/test_ruby_3_0.yml index d71fbe97..a763e5cd 100644 --- a/.github/workflows/test_ruby_3_0.yml +++ b/.github/workflows/test_ruby_3_0.yml @@ -7,7 +7,8 @@ jobs: strategy: fail-fast: false matrix: - arversion: ['6_0_6'] + arversion: ['6_0_6', + '6_1_0', '6_1_1', '6_1_2', '6_1_3', '6_1_4', '6_1_5', '6_1_6', '6_1_7'] runs-on: ubuntu-22.04 env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails${{ matrix.arversion }}.gemfile diff --git a/Appraisals b/Appraisals index 30c6e91d..ab769a18 100644 --- a/Appraisals +++ b/Appraisals @@ -60,3 +60,75 @@ appraise "rails6_0_6" do gem "actionview", "~> 6.0.6.1" gem "mysql2", "~> 0.5.2" end + +appraise "rails6_1_0" do + gem "rails", "~> 6.1.0.0" + gem "railties", "~> 6.1.0.0" + gem "activerecord", "~> 6.1.0.0" + gem "activesupport", "~> 6.1.0.0" + gem "actionview", "~> 6.1.0.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_1" do + gem "rails", "~> 6.1.1.0" + gem "railties", "~> 6.1.1.0" + gem "activerecord", "~> 6.1.1.0" + gem "activesupport", "~> 6.1.1.0" + gem "actionview", "~> 6.1.1.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_2" do + gem "rails", "~> 6.1.2.0" + gem "railties", "~> 6.1.2.0" + gem "activerecord", "~> 6.1.2.0" + gem "activesupport", "~> 6.1.2.0" + gem "actionview", "~> 6.1.2.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_3" do + gem "rails", "~> 6.1.3.0" + gem "railties", "~> 6.1.3.0" + gem "activerecord", "~> 6.1.3.0" + gem "activesupport", "~> 6.1.3.0" + gem "actionview", "~> 6.1.3.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_4" do + gem "rails", "~> 6.1.4.0" + gem "railties", "~> 6.1.4.0" + gem "activerecord", "~> 6.1.4.0" + gem "activesupport", "~> 6.1.4.0" + gem "actionview", "~> 6.1.4.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_5" do + gem "rails", "~> 6.1.5.0" + gem "railties", "~> 6.1.5.0" + gem "activerecord", "~> 6.1.5.0" + gem "activesupport", "~> 6.1.5.0" + gem "actionview", "~> 6.1.5.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_6" do + gem "rails", "~> 6.1.6.0" + gem "railties", "~> 6.1.6.0" + gem "activerecord", "~> 6.1.6.0" + gem "activesupport", "~> 6.1.6.0" + gem "actionview", "~> 6.1.6.0" + gem "mysql2", "~> 0.5.2" +end + +appraise "rails6_1_7" do + gem "rails", "~> 6.1.7.0" + gem "railties", "~> 6.1.7.0" + gem "activerecord", "~> 6.1.7.0" + gem "activesupport", "~> 6.1.7.0" + gem "actionview", "~> 6.1.7.0" + gem "mysql2", "~> 0.5.2" +end diff --git a/activerecord-turntable.gemspec b/activerecord-turntable.gemspec index 2e896126..d0ddd1be 100644 --- a/activerecord-turntable.gemspec +++ b/activerecord-turntable.gemspec @@ -61,6 +61,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bcrypt", "~> 3.1.11" spec.add_development_dependency "minitest" spec.add_development_dependency "mocha" - spec.add_development_dependency "sqlite3", "~> 1.3.6" + spec.add_development_dependency "sqlite3", ">= 1.4.2" spec.add_development_dependency "appraisal", "~> 2.5.0" end diff --git a/gemfiles/rails6_1_0.gemfile b/gemfiles/rails6_1_0.gemfile new file mode 100644 index 00000000..a426c1ee --- /dev/null +++ b/gemfiles/rails6_1_0.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.0.0" +gem "actionview", "~> 6.1.0.0" +gem "activerecord", "~> 6.1.0.0" +gem "activesupport", "~> 6.1.0.0" +gem "railties", "~> 6.1.0.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_1.gemfile b/gemfiles/rails6_1_1.gemfile new file mode 100644 index 00000000..4bec8b96 --- /dev/null +++ b/gemfiles/rails6_1_1.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.1.0" +gem "actionview", "~> 6.1.1.0" +gem "activerecord", "~> 6.1.1.0" +gem "activesupport", "~> 6.1.1.0" +gem "railties", "~> 6.1.1.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_2.gemfile b/gemfiles/rails6_1_2.gemfile new file mode 100644 index 00000000..5f11cc32 --- /dev/null +++ b/gemfiles/rails6_1_2.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.2.0" +gem "actionview", "~> 6.1.2.0" +gem "activerecord", "~> 6.1.2.0" +gem "activesupport", "~> 6.1.2.0" +gem "railties", "~> 6.1.2.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_3.gemfile b/gemfiles/rails6_1_3.gemfile new file mode 100644 index 00000000..6be64c69 --- /dev/null +++ b/gemfiles/rails6_1_3.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.3.0" +gem "actionview", "~> 6.1.3.0" +gem "activerecord", "~> 6.1.3.0" +gem "activesupport", "~> 6.1.3.0" +gem "railties", "~> 6.1.3.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_4.gemfile b/gemfiles/rails6_1_4.gemfile new file mode 100644 index 00000000..f831f1e3 --- /dev/null +++ b/gemfiles/rails6_1_4.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.4.0" +gem "actionview", "~> 6.1.4.0" +gem "activerecord", "~> 6.1.4.0" +gem "activesupport", "~> 6.1.4.0" +gem "railties", "~> 6.1.4.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_5.gemfile b/gemfiles/rails6_1_5.gemfile new file mode 100644 index 00000000..bfc00e06 --- /dev/null +++ b/gemfiles/rails6_1_5.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.5.0" +gem "actionview", "~> 6.1.5.0" +gem "activerecord", "~> 6.1.5.0" +gem "activesupport", "~> 6.1.5.0" +gem "railties", "~> 6.1.5.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_6.gemfile b/gemfiles/rails6_1_6.gemfile new file mode 100644 index 00000000..677b829b --- /dev/null +++ b/gemfiles/rails6_1_6.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.6.0" +gem "actionview", "~> 6.1.6.0" +gem "activerecord", "~> 6.1.6.0" +gem "activesupport", "~> 6.1.6.0" +gem "railties", "~> 6.1.6.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" diff --git a/gemfiles/rails6_1_7.gemfile b/gemfiles/rails6_1_7.gemfile new file mode 100644 index 00000000..0fdebe65 --- /dev/null +++ b/gemfiles/rails6_1_7.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", "~> 6.1.7.0" +gem "actionview", "~> 6.1.7.0" +gem "activerecord", "~> 6.1.7.0" +gem "activesupport", "~> 6.1.7.0" +gem "railties", "~> 6.1.7.0" +gem "mysql2", "~> 0.5.2" + +gemspec path: "../" From f6f9c3b67379c946077a3169c7127037e80689b6 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 15:56:20 +0900 Subject: [PATCH 17/18] update unsupported proxy method in test for AR6.1.0 and 6.1.1 --- spec/active_record/turntable/pool_proxy_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/active_record/turntable/pool_proxy_spec.rb b/spec/active_record/turntable/pool_proxy_spec.rb index 26105bf4..d3034f2c 100644 --- a/spec/active_record/turntable/pool_proxy_spec.rb +++ b/spec/active_record/turntable/pool_proxy_spec.rb @@ -5,7 +5,7 @@ subject { ActiveRecord::Turntable::PoolProxy.new(nil) } # TODO: should support AR 6.1 methods (connection_klass discarded? pool_config db_config) - UNSUPPORTED_PROXY_METHODS = %i[checkout checkin stat lock_thread= remove num_waiting_in_queue connection_klass discarded? pool_config db_config].freeze + UNSUPPORTED_PROXY_METHODS = %i[checkout checkin stat lock_thread= remove num_waiting_in_queue owner_name connection_klass discarded? pool_config db_config].freeze context "Comparing original connection pool" do (ActiveRecord::ConnectionAdapters::ConnectionPool.instance_methods(false) - UNSUPPORTED_PROXY_METHODS).each do |original_method| From 505611841afd2ee54e4094b4099ee3fcdd4654a7 Mon Sep 17 00:00:00 2001 From: MATSUBARA Nobutada Date: Fri, 17 May 2024 16:21:42 +0900 Subject: [PATCH 18/18] drop bundler v1 --- .github/workflows/test_ruby_2_7.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_ruby_2_7.yml b/.github/workflows/test_ruby_2_7.yml index abf89276..3f1051b4 100644 --- a/.github/workflows/test_ruby_2_7.yml +++ b/.github/workflows/test_ruby_2_7.yml @@ -7,8 +7,8 @@ jobs: strategy: fail-fast: false matrix: - arversion: ['5_0_0', '5_0_1', '5_0_2', '5_0_3', '5_0_4', '5_0_5', '5_0_6', '5_0_7', - '5_1_0', '5_1_1', '5_1_2', '5_1_3', '5_1_4', '5_1_5', '5_1_6', '5_1_7', + arversion: ['5_0_5', '5_0_6', '5_0_7', + '5_1_3', '5_1_4', '5_1_5', '5_1_6', '5_1_7', '5_2_0', '5_2_1', '5_2_2', '5_2_3', '5_2_4', '5_2_5', '5_2_6', '5_2_7', '5_2_8', '6_0_0', '6_0_1', '6_0_2', '6_0_3', '6_0_4', '6_0_5', '6_0_6', '6_1_0', '6_1_1', '6_1_2', '6_1_3', '6_1_4', '6_1_5', '6_1_6', '6_1_7'] @@ -23,7 +23,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' - bundler: ${{ contains(fromJSON('["5_0_0", "5_0_1", "5_0_2", "5_0_3", "5_0_4", "5_1_0", "5_1_1", "5_1_2"]'), matrix.arversion) && '1.17.3' || 'latest' }} + bundler: latest bundler-cache: true - name: Start mysql run: sudo systemctl start mysql.service