bensheldon / good_job

Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.
https://goodjob-demo.herokuapp.com/
MIT License
2.67k stars 199 forks source link

ERROR: relation "good_jobs" does not exist at character 454 #308

Closed petebytes closed 2 years ago

petebytes commented 3 years ago

Seeing this error repeat. running good_job v 1.11.2

postgres_1 | 2021-07-25 20:39:26.577 UTC [131] ERROR: relation "good_jobs" does not exist at character 454 postgres_1 | 2021-07-25 20:39:26.577 UTC [131] STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod), postgres_1 | pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod, postgres_1 | c.collname, col_description(a.attrelid, a.attnum) AS comment postgres_1 | FROM pg_attribute a postgres_1 | LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum postgres_1 | LEFT JOIN pg_type t ON a.atttypid = t.oid postgres_1 | LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation postgres_1 | WHERE a.attrelid = '"good_jobs"'::regclass postgres_1 | AND a.attnum > 0 AND NOT a.attisdropped postgres_1 | ORDER BY a.attnum

image

good_job:update shows migration files are identical

Migrations are all UP

bash-5.1# bin/rails g good_job:update skip db/migrate/20210725203837_create_good_jobs.rb identical db/migrate/20210701172249_add_active_job_id_concurrency_key_cron_key_to_good_jobs.rb identical db/migrate/20210701172250_add_active_job_id_index_and_concurrency_key_index_to_good_jobs.rb

bensheldon commented 3 years ago

@petebytes that's strange. Are you seeing this in the development environment or in production? And also, is this a new install or did you recently update GoodJob?

I think that query is coming out of ActiveRecord. I found this SO post that looks like it's a similar class of problem: https://stackoverflow.com/questions/19097558/pg-undefinedtable-error-relation-users-does-not-exist

petebytes commented 3 years ago

Development - I deleted the Postgres volume and rebuilt. Seems to be gone :)

petebytes commented 2 years ago

Exact same problem happening again in development. Running good_job 3.0.0 Postgres version 11.6 Not sure how to troubleshoot.

2022-07-02 15:43:18.905 UTC [5739] ERROR: relation "good_job_processes" does not exist at character 454 2022-07-02 15:43:18.905 UTC [5739] STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod, c.collname, col_description(a.attrelid, a.attnum) AS comment FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum LEFT JOIN pg_type t ON a.atttypid = t.oid LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation WHERE a.attrelid = '"good_job_processes"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum

petebytes commented 2 years ago

The solution was listed on the post you linked to @bensheldon I ran docker compose exec app bin/rails db:prepare RAILS_ENV=test and the issue is gone :)

PS Loving using cron with good_job!

bensheldon commented 2 years ago

Glad you continue to find a fix. I'm a little curious why your database keeps getting out of sorts.

Also, you might save a few keystrokes with:

rails db:test:prepare