lib/foreman_tasks/dynflow/persistence.rb in foreman-tasks-0.7.0 vs lib/foreman_tasks/dynflow/persistence.rb in foreman-tasks-0.7.1
- old
+ new
@@ -5,20 +5,22 @@
# Dynflow will probably get more events-based API but it should be enought
# for start, until the requiements on the API are clear enough.
class Dynflow::Persistence < ::Dynflow::PersistenceAdapters::Sequel
def save_execution_plan(execution_plan_id, value)
+ # clear connection only if not running in some active record transaction already
+ clear_connections = ActiveRecord::Base.connection.open_transactions == 0
super.tap do
begin
on_execution_plan_save(execution_plan_id, value)
rescue => e
ForemanTasks.dynflow.world.logger.error('Error on on_execution_plan_save event')
ForemanTasks.dynflow.world.logger.error(e.message)
ForemanTasks.dynflow.world.logger.error(e.backtrace.join("\n"))
end
end
ensure
- ::ActiveRecord::Base.clear_active_connections!
+ ::ActiveRecord::Base.clear_active_connections! if clear_connections
end
def on_execution_plan_save(execution_plan_id, data)
# We can load the data unless the execution plan was properly planned and saved
# including its steps