Skip to content
Snippets Groups Projects
Commit d9ab64f5 authored by Stan Hu's avatar Stan Hu
Browse files

Merge branch '362949-fix-handling-of-null-store' into 'master'

Fix handling for `GitlabSchemasValidateConnection` for early start

See merge request gitlab-org/gitlab!88162
parents f8a8707f a2a5af3a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -203,8 +203,13 @@ def self.db_config_names
# This does not look at literal connection names, but rather compares
# models that are holders for a given db_config_name
def self.gitlab_schemas_for_connection(connection)
db_name = self.db_config_name(connection)
primary_model = self.database_base_models.fetch(db_name.to_sym)
db_config = self.db_config_for_connection(connection)
# connection might not be yet adopted (returning NullPool, and no connection_klass)
# in such cases it is fine to ignore such connections
return unless db_config
primary_model = self.database_base_models.fetch(db_config.name.to_sym)
 
self.schemas_to_base_models.select do |_, child_models|
child_models.any? do |child_model|
Loading
Loading
Loading
Loading
@@ -222,10 +222,6 @@
end
 
describe '.gitlab_schemas_for_connection' do
it 'does raise exception for invalid connection' do
expect { described_class.gitlab_schemas_for_connection(:invalid) }.to raise_error /key not found: "unknown"/
end
it 'does return a valid schema depending on a base model used', :request_store do
# FF due to lib/gitlab/database/load_balancing/configuration.rb:92
stub_feature_flags(force_no_sharing_primary_model: true)
Loading
Loading
@@ -282,6 +278,15 @@
end
end
end
it 'does return empty for non-adopted connections' do
new_connection = ActiveRecord::Base.postgresql_connection(
ActiveRecord::Base.connection_db_config.configuration_hash)
expect(described_class.gitlab_schemas_for_connection(new_connection)).to be_nil
ensure
new_connection&.disconnect!
end
end
 
describe '#true_value' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment