Jobs stopped running after upgrade from 1.21.3 to 1.22.0

Problem:
After upgrade from 1.21.3 to 1.22.0 I cannot run any Jobs in Foreman. I’ve tried Ansible as well as Command types.
Any job ends with failed state and following errors are in production.log:

2019-08-14T09:33:29 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `state_updated_at=' for #<ForemanTasks::Task::DynflowTask:0x00007f4a380bc708>
Did you mean?  started_at=
2019-08-14T09:33:30 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `update_from_dynflow' for nil:NilClass
2019-08-14T09:33:30 [E|bac|] Couldn't find ForemanTasks::Task::DynflowTask with [WHERE "foreman_tasks_tasks"."type" IN ('ForemanTasks::Task::DynflowTask') AND "foreman_tasks_tasks"."external_id" = $1] (ActiveRecord::RecordNotFound)

Expected outcome:
Job will run and execute.

Foreman and Proxy versions:

foreman-1.22.0-1.el7.noarch
foreman-cli-1.22.0-1.el7.noarch
foreman-debug-1.22.0-1.el7.noarch
foreman-installer-1.22.0-1.el7.noarch
foreman-postgresql-1.22.0-1.el7.noarch
foreman-proxy-1.22.0-1.el7.noarch
foreman-selinux-1.22.0-1.el7.noarch
foreman-vmware-1.22.0-1.el7.noarch
tfm-ror52-rubygem-actioncable-5.2.1-1.el7.noarch
tfm-ror52-rubygem-actionmailer-5.2.1-1.el7.noarch
tfm-ror52-rubygem-actionpack-5.2.1-1.el7.noarch
tfm-ror52-rubygem-actionview-5.2.1-1.el7.noarch
tfm-ror52-rubygem-activejob-5.2.1-1.el7.noarch
tfm-ror52-rubygem-activemodel-5.2.1-1.el7.noarch
tfm-ror52-rubygem-activerecord-5.2.1-1.el7.noarch
tfm-ror52-rubygem-activestorage-5.2.1-1.el7.noarch
tfm-ror52-rubygem-activesupport-5.2.1-1.el7.noarch
tfm-ror52-rubygem-arel-9.0.0-1.el7.noarch
tfm-ror52-rubygem-builder-3.2.3-1.el7.noarch
tfm-ror52-rubygem-coffee-rails-4.2.2-1.el7.noarch
tfm-ror52-rubygem-coffee-script-2.4.1-1.el7.noarch
tfm-ror52-rubygem-coffee-script-source-1.12.2-1.el7.noarch
tfm-ror52-rubygem-concurrent-ruby-1.1.4-1.el7.noarch
tfm-ror52-rubygem-crass-1.0.4-1.el7.noarch
tfm-ror52-rubygem-erubi-1.7.1-1.el7.noarch
tfm-ror52-rubygem-execjs-2.7.0-1.el7.noarch
tfm-ror52-rubygem-globalid-0.4.1-3.el7.noarch
tfm-ror52-rubygem-i18n-1.4.0-1.el7.noarch
tfm-ror52-rubygem-loofah-2.2.2-2.el7.noarch
tfm-ror52-rubygem-mail-2.7.0-1.el7.noarch
tfm-ror52-rubygem-marcel-0.3.2-1.el7.noarch
tfm-ror52-rubygem-method_source-0.9.0-1.el7.noarch
tfm-ror52-rubygem-mimemagic-0.3.2-1.el7.noarch
tfm-ror52-rubygem-mime-types-3.2.2-1.el7.noarch
tfm-ror52-rubygem-mime-types-data-3.2018.0812-1.el7.noarch
tfm-ror52-rubygem-mini_mime-1.0.0-1.el7.noarch
tfm-ror52-rubygem-mini_portile2-2.3.0-1.el7.noarch
tfm-ror52-rubygem-multi_json-1.13.1-1.el7.noarch
tfm-ror52-rubygem-mustermann-1.0.2-1.el7.noarch
tfm-ror52-rubygem-nio4r-2.3.1-1.el7.x86_64
tfm-ror52-rubygem-nokogiri-1.8.4-2.el7.x86_64
tfm-ror52-rubygem-rack-2.0.6-1.el7.noarch
tfm-ror52-rubygem-rack-protection-2.0.3-1.el7.noarch
tfm-ror52-rubygem-rack-test-1.1.0-1.el7.noarch
tfm-ror52-rubygem-rails-5.2.1-1.el7.noarch
tfm-ror52-rubygem-rails-dom-testing-2.0.3-3.el7.noarch
tfm-ror52-rubygem-rails-html-sanitizer-1.0.4-2.el7.noarch
tfm-ror52-rubygem-railties-5.2.1-1.el7.noarch
tfm-ror52-rubygem-sinatra-2.0.3-1.el7.noarch
tfm-ror52-rubygem-sprockets-3.7.2-3.el7.noarch
tfm-ror52-rubygem-sprockets-rails-3.2.1-1.el7.noarch
tfm-ror52-rubygem-sqlite3-1.3.13-1.el7.x86_64
tfm-ror52-rubygem-thor-0.20.0-3.el7.noarch
tfm-ror52-rubygem-thread_safe-0.3.6-1.el7.noarch
tfm-ror52-rubygem-tilt-2.0.8-1.el7.noarch
tfm-ror52-rubygem-turbolinks-2.5.4-1.el7.noarch
tfm-ror52-rubygem-tzinfo-1.2.5-1.el7.noarch
tfm-ror52-rubygem-websocket-driver-0.7.0-1.el7.x86_64
tfm-ror52-rubygem-websocket-extensions-0.1.3-1.el7.noarch
tfm-ror52-runtime-1.0-4.el7.x86_64
tfm-rubygem-activerecord-session_store-1.1.1-2.el7.noarch
tfm-rubygem-addressable-2.6.0-1.el7.noarch
tfm-rubygem-algebrick-0.7.3-6.el7.noarch
tfm-rubygem-ancestry-3.0.0-3.el7.noarch
tfm-rubygem-apipie-bindings-0.2.3-1.el7.noarch
tfm-rubygem-apipie-params-0.0.5-3.el7.noarch
tfm-rubygem-apipie-rails-0.5.14-1.el7.noarch
tfm-rubygem-audited-4.7.1-2.el7.noarch
tfm-rubygem-awesome_print-1.8.0-3.el7.noarch
tfm-rubygem-bundler_ext-0.4.1-3.el7.noarch
tfm-rubygem-clamp-1.1.2-4.el7.noarch
tfm-rubygem-concurrent-ruby-edge-0.4.1-1.fm1_22.el7.noarch
tfm-rubygem-css_parser-1.4.7-3.el7.noarch
tfm-rubygem-daemons-1.2.3-5.el7.noarch
tfm-rubygem-deacon-1.0.0-3.el7.noarch
tfm-rubygem-deep_cloneable-2.3.2-2.el7.noarch
tfm-rubygem-deface-1.3.2-1.el7.noarch
tfm-rubygem-diffy-3.0.1-5.el7.noarch
tfm-rubygem-domain_name-0.5.20160310-3.el7.noarch
tfm-rubygem-dynflow-1.2.3-1.fm1_22.el7.noarch
tfm-rubygem-excon-0.58.0-3.el7.noarch
tfm-rubygem-facter-2.4.0-6.el7.x86_64
tfm-rubygem-fast_gettext-1.4.1-3.el7.noarch
tfm-rubygem-fog-core-2.1.0-1.el7.noarch
tfm-rubygem-fog-vsphere-3.0.0-2.el7.noarch
tfm-rubygem-foreman_ansible-3.0.2-1.fm1_22.el7.noarch
tfm-rubygem-foreman_ansible_core-3.0.0-1.fm1_22.el7.noarch
tfm-rubygem-foreman_bootdisk-15.0.0-1.fm1_22.el7.noarch
tfm-rubygem-foreman_remote_execution-1.8.2-1.fm1_22.el7.noarch
tfm-rubygem-foreman_remote_execution_core-1.2.0-1.el7.noarch
tfm-rubygem-foreman-tasks-0.15.7-1.fm1_22.el7.noarch
tfm-rubygem-foreman-tasks-core-0.3.2-1.fm1_22.el7.noarch
tfm-rubygem-foreman_templates-6.0.3-2.fm1_22.el7.noarch
tfm-rubygem-formatador-0.2.1-11.el7.noarch
tfm-rubygem-friendly_id-5.2.4-2.el7.noarch
tfm-rubygem-get_process_mem-0.2.1-3.el7.noarch
tfm-rubygem-gettext_i18n_rails-1.8.0-1.el7.noarch
tfm-rubygem-git-1.5.0-1.el7.noarch
tfm-rubygem-graphql-1.8.14-1.el7.noarch
tfm-rubygem-graphql-batch-0.3.10-1.el7.noarch
tfm-rubygem-hammer_cli-0.17.1-1.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.17.2-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.13-1.fm1_22.el7.noarch
tfm-rubygem-hammer_cli_foreman_templates-0.1.2-1.fm1_22.el7.noarch
tfm-rubygem-hashie-3.6.0-1.el7.noarch
tfm-rubygem-highline-1.7.8-4.el7.noarch
tfm-rubygem-http-cookie-1.0.2-3.el7.noarch
tfm-rubygem-ipaddress-0.8.0-11.el7.noarch
tfm-rubygem-jwt-2.1.0-1.el7.noarch
tfm-rubygem-ldap_fluff-0.4.7-3.el7.noarch
tfm-rubygem-little-plugger-1.1.3-23.el7.noarch
tfm-rubygem-locale-2.0.9-13.el7.noarch
tfm-rubygem-logging-2.2.2-3.el7.noarch
tfm-rubygem-net-ldap-0.15.0-3.el7.noarch
tfm-rubygem-net-ping-2.0.1-3.el7.noarch
tfm-rubygem-netrc-0.11.0-3.el7.noarch
tfm-rubygem-net-scp-1.2.1-3.el7.noarch
tfm-rubygem-net-ssh-4.2.0-1.el7.noarch
tfm-rubygem-oauth-0.5.4-3.el7.noarch
tfm-rubygem-optimist-3.0.0-1.el7.noarch
tfm-rubygem-parse-cron-0.1.4-4.fm1_22.el7.noarch
tfm-rubygem-passenger-4.0.18-10.12.el7.x86_64
tfm-rubygem-passenger-native-4.0.18-10.12.el7.x86_64
tfm-rubygem-passenger-native-libs-4.0.18-10.12.el7.x86_64
tfm-rubygem-pg-0.21.0-3.el7.x86_64
tfm-rubygem-polyglot-0.3.5-2.el7.noarch
tfm-rubygem-powerbar-2.0.1-1.el7.noarch
tfm-rubygem-promise.rb-0.7.4-1.el7.noarch
tfm-rubygem-public_suffix-3.0.3-1.el7.noarch
tfm-rubygem-rabl-0.13.1-2.el7.noarch
tfm-rubygem-rack-cors-1.0.2-1.el7.noarch
tfm-rubygem-rack-jsonp-1.3.1-7.el7.noarch
tfm-rubygem-rails-i18n-5.1.1-2.el7.noarch
tfm-rubygem-rainbow-2.2.1-3.el7.noarch
tfm-rubygem-rbvmomi-2.0.1-1.el7.noarch
tfm-rubygem-record_tag_helper-1.0.0-2.el7.noarch
tfm-rubygem-responders-2.4.0-2.el7.noarch
tfm-rubygem-rest-client-2.0.1-3.el7.noarch
tfm-rubygem-roadie-3.4.0-1.el7.noarch
tfm-rubygem-roadie-rails-2.0.0-1.el7.noarch
tfm-rubygem-ruby2ruby-2.4.2-1.el7.noarch
tfm-rubygem-ruby_parser-3.10.1-2.el7.noarch
tfm-rubygem-safemode-1.3.5-2.el7.noarch
tfm-rubygem-scoped_search-4.1.7-1.el7.noarch
tfm-rubygem-secure_headers-6.0.0-1.el7.noarch
tfm-rubygem-sequel-5.7.1-2.el7.noarch
tfm-rubygem-sexp_processor-4.10.0-5.el7.noarch
tfm-rubygem-smart_proxy_dynflow_core-0.2.2-1.fm1_22.el7.noarch
tfm-rubygem-sshkey-1.9.0-3.el7.noarch
tfm-rubygem-statsd-instrument-2.1.4-2.el7.noarch
tfm-rubygem-trollop-2.1.2-3.el7.noarch
tfm-rubygem-unf-0.1.3-7.el7.noarch
tfm-rubygem-unf_ext-0.0.6-8.el7.x86_64
tfm-rubygem-unicode-0.4.4.1-5.el7.x86_64
tfm-rubygem-unicode-display_width-1.0.5-3.el7.noarch
tfm-rubygem-validates_lengths_from_database-0.5.0-5.el7.noarch
tfm-rubygem-webpack-rails-0.9.8-3.el7.noarch
tfm-rubygem-will_paginate-3.1.7-1.el7.noarch
tfm-rubygem-x-editable-rails-1.5.5-3.el7.noarch
tfm-runtime-5.0-6.el7.x86_64

Foreman and Proxy plugin versions:
See above.

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)

2019-08-14T09:33:29 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `state_updated_at=' for #<ForemanTasks::Task::DynflowTask:0x00007f4a380bc708>
Did you mean?  started_at=
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/attribute_methods.rb:430:in `method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/models/foreman_tasks/task.rb:293:in `update_state_updated_at'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:426:in `block in make_lambda'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:605:in `catch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:605:in `block in default_terminator'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:199:in `block in halting'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:513:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:513:in `invoke_before'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:131:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:816:in `_run_save_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/callbacks.rb:342:in `create_or_update'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/persistence.rb:308:in `save!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:52:in `save!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:315:in `block in save!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `block in transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
...
2019-08-14T09:33:30 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `update_from_dynflow' for nil:NilClass
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/lib/foreman_tasks/dynflow/persistence.rb:38:in `on_execution_plan_save'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/lib/foreman_tasks/dynflow/persistence.rb:12:in `block in save_execution_plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/lib/foreman_tasks/dynflow/persistence.rb:10:in `tap'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/lib/foreman_tasks/dynflow/persistence.rb:10:in `save_execution_plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/persistence.rb:73:in `save_execution_plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan.rb:438:in `save'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan.rb:144:in `update_state'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan.rb:282:in `plan'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/world.rb:204:in `block in plan_with_options'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/world.rb:202:in `tap'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/world.rb:202:in `plan_with_options'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:83:in `block in trigger'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/world.rb:172:in `trigger'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:83:in `trigger'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.8.2/app/lib/actions/remote_execution/run_hosts_job.rb:45:in `block in create_sub_plans'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/delegation.rb:41:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/delegation.rb:41:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.8.2/app/lib/actions/remote_execution/run_hosts_job.rb:40:in `map'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.8.2/app/lib/actions/remote_execution/run_hosts_job.rb:40:in `create_sub_plans'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:40:in `spawn_plans'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_bulk_sub_plans.rb:70:in `spawn_plans'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:36:in `initiate'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_bulk_sub_plans.rb:35:in `initiate'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_polling_sub_plans.rb:23:in `initiate'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:16:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in `block in assigns'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in `tap'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in `assigns'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in `match_value'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in `block in match?'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in `match?'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:23:in `match'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_sub_plans.rb:11:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_bulk_sub_plans.rb:23:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/with_polling_sub_plans.rb:12:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.8.2/app/lib/actions/remote_execution/run_hosts_job.rb:88:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:538:in `block (3 levels) in execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/proxy_batch_triggering.rb:9:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb:17:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:31:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:31:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/rails_executor_wrap.rb:14:in `block in run'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/execution_wrapper.rb:87:in `wrap'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/rails_executor_wrap.rb:13:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/progress.rb:30:in `with_progress_calculation'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action/progress.rb:16:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_request_id.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_request_id.rb:49:in `restore_current_request_id'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_request_id.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_timezone.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_timezone.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_user.rb:44:in `restore_curent_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.15.7/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:26:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:18:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware.rb:31:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/stack.rb:22:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/middleware/world.rb:30:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:537:in `block (2 levels) in execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:536:in `catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:536:in `block in execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:450:in `block in with_error_handling'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:450:in `catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:450:in `with_error_handling'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:531:in `execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/action.rb:277:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block (2 levels) in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan/steps/abstract.rb:162:in `with_meta_calculation'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `block in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:30:in `open_action'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:15:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/director.rb:43:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/executors/parallel/worker.rb:14:in `block in on_message'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/executors.rb:12:in `run_user_code'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/executors/parallel/worker.rb:13:in `on_message'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/context.rb:46:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/executes_context.rb:7:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.2.3/lib/dynflow/actor.rb:26:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/awaits.rb:15:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/sets_results.rb:14:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/buffer.rb:38:in `process_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/buffer.rb:31:in `process_envelopes?'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/buffer.rb:20:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/termination.rb:55:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/removes_child.rb:10:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/abstract.rb:25:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/behaviour/sets_results.rb:14:in `on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/core.rb:162:in `process_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/core.rb:96:in `block in on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/core.rb:119:in `block (2 levels) in schedule_execution'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/synchronization/mutex_lockable_object.rb:41:in `block in synchronize'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/synchronization/mutex_lockable_object.rb:41:in `synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.4.1/lib-edge/concurrent/actor/core.rb:116:in `block in schedule_execution'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/serialized_execution.rb:18:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/serialized_execution.rb:96:in `work'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/serialized_execution.rb:77:in `block in call_job'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/concurrent-ruby-1.1.4/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Hi, this is interesting, how did you perform the upgrade?

I’ve followed the Upgrade guide in the docs, basically running yum -y upgrade, then the foreman-rake commands and foreman-installer last.

I can also see in production.log some errors during the upgrade process

2019-08-12T14:32:52 [E|dyn|] invalid worlds found {"3beb8e27-b723-4d5f-b7a1-8bbdcc9a18e2"=>:valid, "42b8b11f-ac96-4e15-a113-4d4d95b11c5e"=>:invalidated, "a7223ceb-f621-4fe8-85f2-ba9e5ed85d94"=>:invalidated}
...
2019-08-12T14:37:17 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `state_updated_at=' for #<ForemanTasks::Task::DynflowTask:0x000000000e9879a8>
Did you mean?  started_at=
...
2019-08-12T14:37:17 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `update_from_dynflow' for nil:NilClass
...
2019-08-12T14:37:17 [W|dyn|] Error on on_execution_plan_save event
NoMethodError: undefined method `state_updated_at=' for #<ForemanTasks::Task::DynflowTask:0x000000000e460b78>
Did you mean?  started_at=
...
2019-08-12T14:37:17 [W|dyn|] Error on on_execution_plan_save event
ActiveRecord::RecordNotFound: Couldn't find ForemanTasks::Task::DynflowTask
...
2019-08-12T14:37:17 [E|app|] Error performing StoredValuesCleanupJob (Job ID: 4ffa22cb-8d89-4251-8200-8a3c9ea0b302) from Dynflow(default) in 164.14ms: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation "stored_values" does not exist
...
2019-08-12T14:37:17 [E|bac|] StoredValues cleanup: Error while cleaning up stored_values table - PG::UndefinedTable: ERROR:  relation "stored_values" does not exist
...
2019-08-12T14:37:17 [E|bac|] PG::UndefinedTable: ERROR:  relation "stored_values" does not exist
...

I got it working, however I have no idea what fixed it.
I have reinstalled foreman using yum -y reinstall foreman (because I wanted to get the package’s settings.yaml file again as I have deleted the .rpmnew one), I’ve run foreman-rake foreman_tasks:cleanup:config and foreman-rake foreman_tasks:cleanup:run and restarted all services in order httpd->foreman-tasks->foreman-proxy->dynflowd->smart_proxy_dynflow_core and I no longer get the errors and jobs are running fine.

But I can post some logs if you need them.

It looks the db wasn’t fully migrated. Reinstalling foreman most likely triggered another run of the migrations which fixed the issue.