-
Notifications
You must be signed in to change notification settings - Fork 130
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
Loading schema in production? #365
Comments
Hey @cjamison, thanks for writing this up! This is all very strange.
No... it should work just fine.
So, if this did nothing to the |
Hey @rosa , I'm having the exact same problem. I've just added solid_queue to an existing application, and I've followed the setup instructions:
Running FYI this is the full output of the rake task:
|
Hey @stefanoc, could you copy your |
@rosa here it is:
Yes, |
I have the same issue. I have just installed solid_queue, updated db config and I am not able to start solid server
|
I am having an identical problem. When I install solid queue, it creates the schema file. I then modify my default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
primary: &primary_development
<<: *default
url: "hidden"
queue:
<<: *primary_development
database: steplist_development_queue
migrations_paths: db/queue_migrate
test:
<<: *default
url: "hidden"
production:
primary: &primary_production
<<: *default
url: <%= ENV['DATABASE_URL'] %>
connect_timeout: 2
checkout_timeout: 5
variables:
statement_timeout: 5000 # ms
queue:
<<: *primary_production
database: steplist_production_queue
migrations_paths: db/queue_migrate If I run # Job backend
config.active_job.queue_adapter = :solid_queue
config.solid_queue.connects_to = { database: { writing: :queue } } Running |
Some further info... When my development databases were already running and seeded, However, when I Created database 'steplist-dev'
Created database 'steplist-test'
2024-10-28T19:41:06.190Z pid=70490 tid=1hmi INFO: Sidekiq 7.3.2 connecting to Redis with options {:size=>10, :pool_name=>"internal", :url=>nil}
Creating static users
No default list found for Drew Breunig
bin/rails aborted!
SolidQueue::Job::EnqueueError: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "solid_queue_jobs" does not exist (SolidQueue::Job::EnqueueError)
LINE 10: WHERE a.attrelid = '"solid_queue_jobs"'::regclass
^
/Users/dbreunig/Development/StepList/db/seeds/00_static_user.rb:4:in `<top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:81:in `block in <top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `each'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `<top (required)>'
Caused by:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "solid_queue_jobs" does not exist (ActiveRecord::StatementInvalid)
LINE 10: WHERE a.attrelid = '"solid_queue_jobs"'::regclass
^
/Users/dbreunig/Development/StepList/db/seeds/00_static_user.rb:4:in `<top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:81:in `block in <top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `each'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `<top (required)>'
Caused by:
PG::UndefinedTable: ERROR: relation "solid_queue_jobs" does not exist (PG::UndefinedTable)
LINE 10: WHERE a.attrelid = '"solid_queue_jobs"'::regclass
^
/Users/dbreunig/Development/StepList/db/seeds/00_static_user.rb:4:in `<top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:81:in `block in <top (required)>'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `each'
/Users/dbreunig/Development/StepList/db/seeds.rb:80:in `<top (required)>'
Tasks: TOP => db:prepare
(See full trace by running task with --trace) Running Created database 'steplist-dev'
Database 'steplist-dev' already exists
Created database 'steplist-test' But now I'm curious why development:
primary: &primary_development
<<: *default
url: "postgres://dbreunig:dbreunig@localhost:5434/steplist-dev"
queue:
<<: *primary_development
url: "postgres://dbreunig:dbreunig@localhost:5434/steplist-development-queue" # <- this is new
database: steplist_development_queue
migrations_paths: db/queue_migrate Suddenly it all works. I would suggest adding something in the docs about setting up the separate DB so this is more clear for those migrating. |
Huh, I just tested a brand new app using Rails 8.0.0.beta1 and everything worked perfectly from the start, just following the instructions and configuring Solid Queue in development, using SQLite 🤔 I get the same error with I realise that before Solid Queue started using multiple DBs, not many people were using multiple DBs with Rails, and as such, we're running into a few rough edges around this Rails feature... (eg. rails/rails#52829) 🤔 |
I think the issue here isn't new apps, but those looking to migrate. Including instructions for running it in dev, essential for migrations, would be helpful. I heard of a few migrations before the separate database methodology was introduced, but none since. |
@dbreunig, not sure I follow 🤔 Do you mean apps that were using Solid Queue before version 0.8? In that case, you have instructions about how to proceed here, as you won't be able to use the new schema file, you'd need to run the incremental migrations until your Solid Queue DB looks like the one in the schema file now. If you mean existing apps that weren't using Solid Queue before, then there's no difference between that and a new app. |
I hope there is a better way to do this that I am not seeing.
According to the read me:
I am testing this out in staging first. So I ran the following on the server:
This did nothing to the queue database. Maybe because the queue database already existed? Our deployment process sets up the databases ahead of time. So running this command resulted in zero tables in the queue DB. Plus, db:prepare is not listed as a command for multiple databases. However, db:setup is. So, I ran:
This might have worked. However, it tried connecting to the postgres database. Presumably to drop and recreate the database. However, connecting as postgres is not allowed on our staging and production systems.
So, I tried db:schema:load:queue (I actually tried this first):
This resulted in this error:
It looks like it is doing something with regard to a test DB that does not exist? There is actually an open PR about this: rails/rails#50672.
Then I started a console in the Staging environment on the server and ran these commands to load the schema in the queue database:
This successfully loaded the queue database.
Is there a better way to do this? I don't remember having to load a schema in Staging or Production before. It seems like an anti-pattern? I started using Solid Queue with version 0.3 and the migrations sure seemed easier. Would it be easier to place the contents of the queue_schema.rb in a single migration file?
The text was updated successfully, but these errors were encountered: