solid_queue: Database connection error in Solid Queue, but not Rails app

My syslog keeps filling up with errors like:

ActiveRecord::DatabaseConnectionError: There is an issue connecting with your hostname: <<DB SERVER IP>>. (ActiveRecord::DatabaseConnectionError)
Please check your database configuration and ensure there is a valid connection to your database.
...stack trace removed...
PG::ConnectionBad: connection to server at "<<DB SERVER IP>>", port 5432 failed: fe_sendauth: no password supplied (PG::ConnectionBad)

I’m assuming Solid Queue is using the config/database.yml from my Rails app to connect to Postgres:

production:
  <<: *default
  database: purchasing_production
  host: <<DB SERVER IP>>
  port: 5432
  username: postgres
  password: <%= ENV["POSTGRES_PASSWORD"] %>

The Rails app is able to connect fine. I have checked that the POSTGRES_PASSWORD environment variable is set. I’ve also verified there’s only one Solid Queue process running.

Oddly enough, when I send email with the deliver_later method, the emails are properly sent. So it seems that Solid Queue is processing something, but not able to connect to the database? What am I missing here?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 24 (9 by maintainers)

Most upvoted comments

This is related to the environment variable. If I temporarily plug in the actual password in my config/database.yml file, solid queue starts up without issue:

85028 May  6 16:03:00 purchasing systemd[1]: Started solid_queue for Purchasing.
85029 May  6 16:03:05 purchasing solid_queue[12380]: [SolidQueue] Starting Dispatcher(pid=12380, hostname=redacted.com, metadata={:polling_interval=>1, :batch_size=>500})
85030 May  6 16:03:05 purchasing solid_queue[12386]: [SolidQueue] Starting Worker(pid=12386, hostname=redacted.com, metadata={:polling_interval=>0.1, :queues=>"*", :thread_pool
85031 May  6 16:03:19 purchasing systemd[1]: Started Session 10 of User deployer.
85032 May  6 16:03:21 purchasing systemd[1]: session-10.scope: Deactivated successfully.
85033 May  6 16:03:21 purchasing systemd[1]: session-10.scope: Consumed 1.484s CPU time.
85034 May  6 16:07:27 purchasing solid_queue[1201]: [SolidQueue] Claimed 1 jobs

But I can’t figure out why it isn’t finding that ENV["POSTGRES_PASSWORD"]. It is available if I login as the deployer user that is running the solid queue process. And the process itself seems to be running alright:

systemctl --user status solid_queue
● solid_queue.service - solid_queue for Purchasing
     Loaded: loaded (/home/deployer/.config/systemd/user/solid_queue.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-05-06 15:20:08 UTC; 50min ago
   Main PID: 665 (bundle)
      Tasks: 19 (limit: 4666)
     Memory: 282.1M
        CPU: 1min 8.084s
     CGroup: /user.slice/user-1001.slice/user@1001.service/app.slice/solid_queue.service
             ├─ 665 "solid-queue-supervisor(0.2.2): supervising 1195, 1201"
             ├─1195 "solid-queue-dispatcher(0.2.2): waiting"
             └─1201 "solid-queue-worker(0.2.2): waiting for jobs in *"

May 06 15:20:08 purchasing.camfildev.com systemd[627]: Started solid_queue for Purchasing.
May 06 15:20:15 purchasing.camfildev.com solid_queue[1195]: [SolidQueue] Starting Dispatcher(pid=1195, hostname=redacted.com, metadata={:poll>
May 06 15:20:15 purchasing.camfildev.com solid_queue[1201]: [SolidQueue] Starting Worker(pid=1201, hostname=redacted.com, metadata={:polling_>
May 06 16:07:27 purchasing.camfildev.com solid_queue[1201]: [SolidQueue] Claimed 1 jobs

Is it possible that action mailer is using a different queue adapter? Or are you setting solid_queue as the adapter for everything?

I’m not using a different adapter for action mailer, at least not purposely. I’m just calling the deliver_later method “bare”, without any parameters. And searching through my config files, the only thing I’ve set is the overall queue adapter in config/production.rb, per the solid queue instructions.