podify-org/podify

Uninitialized Database: relation "users" does not exist

lorenzschmid opened this issue · 2 comments

Using the docker-compose setup the podify container runs into an issue shortly after having started: It seems as if it does not setup all its databases properly:

PG::UndefinedTable: ERROR:  relation "users" does not exist (Sequel::DatabaseError)

Complete log since first start:

I, [2021-09-16T07:42:35.711129 #8]  INFO -- sentry: ** [Raven] Raven 3.1.2 configured not to capture errors: DSN not set
=> Booting Puma
=> Rails 6.1.4.1 application starting in production 
=> Run `bin/rails server --help` for more startup options
/app/lib/cli/commands/sources/add.rb:18: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
/app/lib/cli/commands/sources/fetch.rb:22: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
/app/lib/cli/commands/sources/request.rb:23: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
D, [2021-09-16T07:42:36.898911 #8] DEBUG -- :   �[1m�[36mSequel::Postgres::Database (0.4ms)�[0m  �[1mSET standard_conforming_strings = ON�[0m
D, [2021-09-16T07:42:36.899468 #8] DEBUG -- :   �[1m�[35mSequel::Postgres::Database (0.2ms)�[0m  SET client_min_messages = 'WARNING'
/app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:156:in `exec': PG::UndefinedTable: ERROR:  relation "users" does not exist (Sequel::DatabaseError)
LINE 1: SELECT * FROM "users" LIMIT 1
                      ^
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:156:in `block in execute_query'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-rails-1.1.1/lib/sequel_rails/sequel/database/active_support_notification.rb:17:in `block in log_connection_yield'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:203:in `block in instrument'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:203:in `instrument'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-rails-1.1.1/lib/sequel_rails/sequel/database/active_support_notification.rb:11:in `log_connection_yield'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:156:in `execute_query'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:144:in `block in execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:120:in `check_disconnect_errors'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:144:in `execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:500:in `_execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:318:in `block (2 levels) in execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:522:in `check_database_errors'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:318:in `block in execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/connection_pool/threaded.rb:88:in `hold'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/database/connecting.rb:269:in `synchronize'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:318:in `execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/dataset/actions.rb:1093:in `execute'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/adapters/postgres.rb:614:in `fetch_rows'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/dataset/actions.rb:152:in `each'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/dataset/actions.rb:86:in `columns!'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/dataset/actions.rb:76:in `columns'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:242:in `columns'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:788:in `block (2 levels) in get_db_schema'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:686:in `block in check_non_connection_error'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/database/transactions.rb:201:in `block in transaction'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/database/connecting.rb:269:in `synchronize'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/database/transactions.rb:195:in `transaction'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:686:in `check_non_connection_error'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:788:in `block in get_db_schema'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:821:in `get_db_schema'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:606:in `set_dataset'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/model/base.rb:869:in `inherited'
    from /app/vendor/bundle/ruby/2.7.0/gems/sequel-5.47.0/lib/sequel/plugins/subclasses.rb:72:in `inherited'
    from /app/app/models/user.rb:1:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
    from /app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
    from /app/lib/users/create_initial.rb:18:in `call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-monads-1.4.0/lib/dry/monads/do.rb:137:in `block in call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-monads-1.4.0/lib/dry/monads/do/mixin.rb:40:in `call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-monads-1.4.0/lib/dry/monads/do.rb:137:in `call'
    from /app/config/system/initial_user.rb:4:in `block (3 levels) in <top (required)>'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/lifecycle.rb:115:in `trigger!'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/lifecycle.rb:80:in `start'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/lifecycle.rb:52:in `block in call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/lifecycle.rb:50:in `each'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/lifecycle.rb:50:in `call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/components/bootable.rb:99:in `start'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:84:in `block (2 levels) in start'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:71:in `block (2 levels) in init'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:110:in `block in call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:153:in `with_component'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:107:in `call'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:69:in `block in init'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:153:in `with_component'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:68:in `init'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:83:in `block in start'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:153:in `with_component'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:80:in `start'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:51:in `block in finalize!'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter/component_registry.rb:16:in `each'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter/component_registry.rb:16:in `each'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/booter.rb:50:in `finalize!'
    from /app/vendor/bundle/ruby/2.7.0/gems/dry-system-0.18.2/lib/dry/system/container.rb:323:in `finalize!'
    from /app/vendor/bundle/ruby/2.7.0/bundler/gems/dry-rails-08eddd1df72a/lib/dry/rails/container.rb:141:in `finalize!'
    from /app/vendor/bundle/ruby/2.7.0/bundler/gems/dry-rails-08eddd1df72a/lib/dry/rails/railtie.rb:67:in `finalize!'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
    from /app/vendor/bundle/ruby/2.7.0/bundler/gems/dry-rails-08eddd1df72a/lib/dry/rails/railtie.rb:16:in `block in <class:Railtie>'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `instance_exec'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `catch'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:199:in `block in halting'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `each'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `invoke_before'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:105:in `run_callbacks'
    from /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/reloader.rb:88:in `prepare!'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
    from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
    from /app/config/environment.rb:5:in `<top (required)>'
    from config.ru:3:in `require_relative'
    from config.ru:3:in `block in <main>'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:312:in `block in start'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:379:in `handle_profiling'
    from /app/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:311:in `start'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:39:in `start'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:144:in `block in perform'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:135:in `tap'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:135:in `perform'
    from /app/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    from /app/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    from /app/vendor/bundle/ruby/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command/base.rb:69:in `perform'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/command.rb:48:in `invoke'
    from /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Oh right. I recently made a change that only the worker container runs migrations, that could be the cause.

If you leave it running for ~30s, just ignore the crashing web container, then restart everything that should make it work for now. I'll work on a proper fix in the coming days.

Thanks for the prompt answer. Actually my bad: My worker did not start properly due to a configuration issue on my end. I fixed it and it runs smoothly now.

I leave it up to you if you consider this issue closed or not.