简体   繁体   English

没有找到主要的连接池

[英]no connection pool with primary found

I am using Rails and am experiencing a connection pool error very randomly and it does not target any single endpoint specifically.我正在使用 Rails 并且非常随机地遇到连接池错误,并且它没有专门针对任何单个端点。 I can hit endpoints about 70% of the time without getting this error.我可以在大约 70% 的时间内到达端点而不会出现此错误。 The database is PostgreSQL running on Google Cloud.数据库是在 Google Cloud 上运行的 PostgreSQL。 Here's the main stuff of the error I'm getting:这是我遇到的错误的主要内容:

#<ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished>
/usr/local/bundle/gems/activerecord-5.1.5/lib/active_record/connection_handling.rb:112:in `connection_pool'

ActiveRecord::ConnectionNotEstablished (No connection pool with 'primary' found.):

Gemfile:宝石档案:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


gem 'rails', '~> 5.1.5'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.7'
gem 'bcrypt', '~> 3.1.7'
gem 'jwt', '~> 1.5'
gem 'simple_command', '~> 0.0.9'
gem 'swagger-blocks', '~> 2.0.2'
gem 'active_model_serializers', '~> 0.10.2'
gem 'kaminari'
gem 'google-cloud-storage', '~> 1.10.0'
gem 'mini_magick', '~> 4.8.0'
gem 'carrierwave', '~> 1.2.0'
gem 'fog-google', '~> 1.3.0'
gem 'geocoder', '~> 1.4.7'
gem 'paper_trail', '~> 9.2.0'
gem 'paper_trail-association_tracking'
gem 'full-name-splitter', '~> 0.1.2'
gem 'pg_search'
gem 'mailgun-ruby', '~>1.1.6'


 gem 'rack-cors'

group :development, :test, :staging, :dev do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 3.7'
  gem 'factory_bot_rails'
  gem 'dotenv-rails'
  gem 'pry-rails'
  gem 'stackprof'
  gem 'flamegraph'
  gem 'rack-mini-profiler'
  gem 'bullet'
  gem 'seed_dump'
end

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

 gem
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    gem 'devise', '~> 4.4.3'
    gem 'activeadmin', github: 'activeadmin'
    gem 'inherited_resources', git: 'https://github.com/activeadmin/inherited_resources'

Database.yml:数据库.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: rails_development

dev:
  <<: *default
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_HOST'] %>
test:
  <<: *default
  database: rails_test

production:
  <<: *default
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_HOST'] %>

staging:
  <<: *default
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_HOST'] %>

We're using:我们正在使用:

Ruby 2.5.0 Rails 5.1.5红宝石 2.5.0 导轨 5.1.5

With Postgresql on Googles CloudSQL在 Google CloudSQL 上使用 Postgresql

First:第一的:

$ gem uninstall sqlite

then in gemfile change it for:然后在 gemfile 中将其更改为:

gem 'sqlite3', '~> 1.3.6' 

and:和:

$ bundle install 

$ rake db:migrate

and restart server.并重启服务器。 Should works :)应该有效:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有找到“主要”的连接池 - No connection pool with 'primary' found 没有为 RSpec 找到具有“主”的连接池 - No connection pool with 'primary' found for RSpec 未找到 ID 为主要的连接池 - No connection pool with id primary found ActiveRecord::ConnectionNotEstablished(未找到“主”连接池。) - ActiveRecord::ConnectionNotEstablished (No connection pool with 'primary' found.) 呈现结果时,ActiveRecord::ConnectionNotEstablished(未找到具有“主要”的连接池。) - ActiveRecord::ConnectionNotEstablished (No connection pool with 'primary' found.) when rendering results ActiveRecord::ConnectionNotEstablished:在登台时找不到“阅读”角色的“主要”连接池 - ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found for the 'reading' role on staging 出现“找不到‘ActiveRecord::Base’的连接池”的间歇性错误 - Getting intermittent error of "No connection pool for 'ActiveRecord::Base' found" 引发ConnectionNotFounded,“未找到带有&#39;#{spec_name}&#39;的连接池。”除非池LOCALHOST3000不起作用 - raise ConnectionNotEstablished, “No connection pool with '#{spec_name}' found.” unless pool LOCALHOST3000 not working {model name} 没有连接池 - No connection pool for {model name} 轨道连接池5 - Connection Pool for rails 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM