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

Update to 3.15.4 breaks cleanup_preserved_jobs #937

Closed
Timmitry opened this issue Apr 24, 2023 · 3 comments · Fixed by #938
Closed

Update to 3.15.4 breaks cleanup_preserved_jobs #937

Timmitry opened this issue Apr 24, 2023 · 3 comments · Fixed by #938

Comments

@Timmitry
Copy link
Contributor

Hey @bensheldon 👋

After upgrading the gem in our application from 3.15.0 to 3.15.4, we see an error. I think I already found this PR to be the culprit, together with this line:

deleted_discrete_executions = GoodJob::DiscreteExecution.where(active_job_id: active_job_ids).delete_all

Which does not check whether the new good_job_executions-Table already exists.

The error we see is:

ActiveRecord::StatementInvalid

PG::UndefinedTable: ERROR:  relation "good_job_executions" does not exist
LINE 9:  WHERE a.attrelid = '"good_job_executions"'::regclass

And here's the full stacktrace:

from activerecord (7.0.4.3) lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `exec'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in `block (2 levels) in query'
  from activesupport (7.0.4.3) lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
  from activesupport (7.0.4.3) lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/postgresql/database_statements.rb:18:in `block in query'
  from activesupport (7.0.4.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
  from activesupport (7.0.4.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
  from activesupport (7.0.4.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
  from activesupport (7.0.4.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/abstract_adapter.rb:765:in `block in log'
  from activesupport (7.0.4.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/abstract_adapter.rb:756:in `log'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/postgresql/database_statements.rb:17:in `query'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/postgresql_adapter.rb:916:in `column_definitions'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:117:in `block in columns'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:116:in `fetch'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:116:in `columns'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:125:in `block in columns_hash'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:124:in `fetch'
  from activerecord (7.0.4.3) lib/active_record/connection_adapters/schema_cache.rb:124:in `columns_hash'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:580:in `load_schema!'
  from activerecord (7.0.4.3) lib/active_record/attributes.rb:264:in `load_schema!'
  from activerecord (7.0.4.3) lib/active_record/encryption/encryptable_record.rb:122:in `load_schema!'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:566:in `block in load_schema'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:563:in `synchronize'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:563:in `load_schema'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:429:in `attribute_types'
  from activerecord (7.0.4.3) lib/active_record/model_schema.rb:455:in `type_for_attribute'
  from activerecord (7.0.4.3) lib/active_record/type_caster/map.rb:16:in `type_for_attribute'
  from activerecord (7.0.4.3) lib/arel/table.rb:107:in `type_for_attribute'
  from activerecord (7.0.4.3) lib/active_record/table_metadata.rb:18:in `type'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:59:in `build'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:54:in `[]'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:126:in `block in expand_from_hash'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:79:in `each'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:79:in `flat_map'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:79:in `expand_from_hash'
  from activerecord (7.0.4.3) lib/active_record/relation/predicate_builder.rb:25:in `build_from_hash'
  from activerecord (7.0.4.3) lib/active_record/relation/query_methods.rb:1315:in `build_where_clause'
  from activerecord (7.0.4.3) lib/active_record/relation/query_methods.rb:756:in `where!'
  from activerecord (7.0.4.3) lib/active_record/relation/query_methods.rb:751:in `where'
  from activerecord (7.0.4.3) lib/active_record/querying.rb:22:in `where'
  from good_job (3.15.4) lib/good_job.rb:181:in `block (2 levels) in cleanup_preserved_jobs'
  from good_job (3.15.4) lib/good_job.rb:177:in `loop'
  from good_job (3.15.4) lib/good_job.rb:177:in `block in cleanup_preserved_jobs'
  from appsignal (3.4.1) lib/appsignal/hooks/active_support_notifications.rb:19:in `block in instrument'
  from activesupport (7.0.4.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from appsignal (3.4.1) lib/appsignal/hooks/active_support_notifications.rb:18:in `instrument'
  from good_job (3.15.4) lib/good_job.rb:170:in `cleanup_preserved_jobs'
  from good_job (3.15.4) lib/good_job/job_performer.rb:71:in `cleanup'
  from good_job (3.15.4) lib/good_job/scheduler.rb:259:in `block (2 levels) in cleanup'
  from activesupport (7.0.4.3) lib/active_support/execution_wrapper.rb:92:in `wrap'
  from good_job (3.15.4) lib/good_job/scheduler.rb:258:in `block in cleanup'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/ivar.rb:170:in `safe_execute'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/future.rb:55:in `block in execute'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
  from concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
@bensheldon
Copy link
Owner

bensheldon commented Apr 24, 2023

@Timmitry whoops! thank you for opening this issue. I'll fix that right now.

@bensheldon
Copy link
Owner

@Timmitry I just released a fix for this in https://github.com/bensheldon/good_job/releases/tag/v3.15.5

Thank you again!

@Timmitry
Copy link
Contributor Author

Thank you for the quick fix! In the meantime, we ran the update command to generate the migration for the new table, and everything works again 💙 Thanks for your amazing work on this Gem!

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