Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation does not work when using DB read-replica #2265

Closed
dssjoblom opened this issue Mar 17, 2022 · 3 comments · Fixed by #2266
Closed

Installation does not work when using DB read-replica #2265

dssjoblom opened this issue Mar 17, 2022 · 3 comments · Fixed by #2266

Comments

@dssjoblom
Copy link

dssjoblom commented Mar 17, 2022

Description

When installing (rake alchemy:install) with a DB replica setup, e.g. something along the lines of

development:
  primary:
    database: primary
    username: <%= ENV["DB_USERNAME"] %>
    password: <%= ENV["DB_PASSWORD"] %>
    host: localhost
    port: 5432
  replica:
    database: replica
    username: <%= ENV["DB_REPLICA_USERNAME"] %>
    password: <%= ENV["DB_REPLICA_PASSWORD"] %>
    host: localhost
    port: 5432

in database.yml, the installer fails with an exception.

Expected behavior

The installation should work normally. Specifically, it should not try to do anything with the replica.

Actual behavior

Installation fails with an exception:

PG::InsufficientPrivilege: ERROR:  permission denied to create database
Couldn't create 'replica' database. Please check your configuration.
rake aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  permission denied to create database
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `exec'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block (2 levels) in execute'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `block in execute'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activesupport-6.1.4.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:45:in `execute'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/connection_adapters/postgresql/schema_statements.rb:46:in `create_database'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/postgresql_database_tasks.rb:26:in `create'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:133:in `create'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:193:in `block in create_current'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:506:in `block (2 levels) in each_current_configuration'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:503:in `each'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:503:in `block in each_current_configuration'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:502:in `each'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:502:in `each_current_configuration'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/tasks/database_tasks.rb:193:in `create_current'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/activerecord-6.1.4.7/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <main>'
/home/daniel/.rvm/gems/ruby-2.7.5/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/home/daniel/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
/home/daniel/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'

System configuration

  • Alchemy Version: 6.0.0.pre.rc6
  • Rails Version: 6.1.4.7
@tvdeyen
Copy link
Member

tvdeyen commented Mar 17, 2022

You are missing the privilege to create the database. We could add an option to skip creation of database during install.

tvdeyen added a commit to tvdeyen/alchemy_cms that referenced this issue Mar 17, 2022
@tvdeyen
Copy link
Member

tvdeyen commented Mar 17, 2022

@dssjoblom I added an option to the installer. Can you try with

# Gemfile
gem "alchemy_cms", github: "tvdeyen/alchemy_cms", branch: "installer/skip-db-migrate"

@dssjoblom
Copy link
Author

@tvdeyen thanks for the response. However, I realized that the problem was actually in the database config, as it failed to set replica: true on the replica instance. After fixing this, the installation works even without the --skip-db-create flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants