dynflow 1.4.6 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d3c22d2470835d38bb89ac45879837ac515268c40f919eb3b57de809cb912f4
4
- data.tar.gz: 8552edbffe0f91aa162b5b004d1ef40046f719dee746a2e2cf3da119786ac0d9
3
+ metadata.gz: ffff17987553c70b701f8f7e8b98f5a159c4d0498ccb45b9d41581204edb1b01
4
+ data.tar.gz: 1399c875ec759cf98a53925caa822e7e03aa8e1e61d9bd2e1957ab69bb07beb8
5
5
  SHA512:
6
- metadata.gz: cbc4d8031d1836644d0327b2afb83d95f0ada20955e6e5c60bde8de447a2cc83bb2b3bcb116a2e9eb4303ed54bef55ca31c4098d6e11003b3a3717d3f96127ec
7
- data.tar.gz: 48db612dd381a90474caac16c524304d15862d8947314abc21dd768b481402dae1c8785377eaf11cc9f9674520ec9061b279312fccc98d5aa932c00cf66284ce
6
+ metadata.gz: 51f14bfdcae3d32aaae92716a48668f119327cb8873130dbff7ce9551b40f64d0283037c5a77c5fdced78b612ed8046a449c44ec55e1377d56d247a0cedf3256
7
+ data.tar.gz: 54787c9fe54caa7227c4122470e398891e161618f5bb02f49332ea2e5a54190dd263e3d46a12691fe47218a81d026d67417b501e07785d6e9eda0aa89f4dd916
@@ -352,15 +352,12 @@ module Dynflow
352
352
  @step.state = state
353
353
  end
354
354
 
355
+ # If this save returns an integer, it means it was an update. The number
356
+ # represents the number of updated records. If it is 0, then the step was in
357
+ # an unexpected state and couldn't be updated
355
358
  def save_state(conditions = {})
356
359
  phase! Executable
357
- # If this save returns an integer, it means it was an update. The number
358
- # represents the number of updated records. If it is 0, then the step
359
- # was in an unexpected state and couldn't be updated, in which case we
360
- # raise an exception and crash hard to prevent the step from being
361
- # executed twice
362
- count = @step.save(conditions)
363
- raise 'Could not save state' if count.kind_of?(Integer) && !count.positive?
360
+ @step.save(conditions)
364
361
  end
365
362
 
366
363
  def delay(delay_options, *args)
@@ -536,11 +533,11 @@ module Dynflow
536
533
  end
537
534
 
538
535
  # TODO: This is getting out of hand, refactoring needed
536
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
539
537
  def execute_run(event)
540
538
  phase! Run
541
539
  @world.logger.debug format('%13s %s:%2d got event %s',
542
540
  'Step', execution_plan_id, @step.id, event) if event
543
- @input = OutputReference.dereference @input, world.persistence
544
541
 
545
542
  case
546
543
  when state == :running
@@ -551,8 +548,19 @@ module Dynflow
551
548
  raise 'event can be processed only when in suspended state'
552
549
  end
553
550
 
551
+ old_state = self.state
554
552
  self.state = :running unless self.state == :skipping
555
- save_state(:state => %w(pending error skipping suspended))
553
+ saved = save_state(:state => %w(pending error skipping suspended))
554
+ if saved.kind_of?(Integer) && !saved.positive?
555
+ # The step was already in a state we're trying to transition to, most
556
+ # likely we were about to execute it for the second time after first
557
+ # execution was forcefully interrupted.
558
+ # Set error and return to prevent the step from being executed twice
559
+ set_error "Could not transition step from #{old_state} to #{self.state}, step already in #{self.state}."
560
+ return
561
+ end
562
+
563
+ @input = OutputReference.dereference @input, world.persistence
556
564
  with_error_handling do
557
565
  event = Skip if state == :skipping
558
566
 
@@ -573,6 +581,7 @@ module Dynflow
573
581
  raise "wrong state #{state} when event:#{event}"
574
582
  end
575
583
  end
584
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
576
585
 
577
586
  def execute_finalize
578
587
  phase! Finalize
@@ -20,7 +20,7 @@ module Dynflow
20
20
  def terminate
21
21
  pending_work = @work_items.clear.values.flatten(1)
22
22
  pending_work.each do |w|
23
- if EventWorkItem === w
23
+ if EventWorkItem === w && w.event.result
24
24
  w.event.result.reject UnprocessableEvent.new("dropping due to termination")
25
25
  end
26
26
  end
@@ -252,7 +252,7 @@ module Dynflow
252
252
  future.fulfill(true)
253
253
  else
254
254
  if @ping_cache.executor?(request.receiver_id)
255
- future.reject
255
+ future.reject false
256
256
  else
257
257
  yield
258
258
  end
@@ -38,8 +38,8 @@ module Dynflow
38
38
  init_world.tap do |world|
39
39
  @world = world
40
40
  config.run_on_init_hooks(false, world)
41
+ config.increase_db_pool_size(world)
41
42
  unless config.remote?
42
- config.increase_db_pool_size(world)
43
43
  config.run_on_init_hooks(true, world)
44
44
  # leave this just for long-running executors
45
45
  unless config.rake_task_with_executor?
@@ -96,7 +96,11 @@ module Dynflow
96
96
  end
97
97
 
98
98
  def increase_db_pool_size?
99
- !::Rails.env.test? && !remote?
99
+ !::Rails.env.test? && (!remote? || sidekiq_worker?)
100
+ end
101
+
102
+ def sidekiq_worker?
103
+ defined?(::Sidekiq) && ::Sidekiq.options[:queues].any?
100
104
  end
101
105
 
102
106
  def calculate_db_pool_size(world)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dynflow
3
- VERSION = '1.4.6'
3
+ VERSION = '1.4.7'
4
4
  end
@@ -43,7 +43,7 @@ module Dynflow
43
43
  else
44
44
  :stopped
45
45
  end
46
- plan.update_state(state)
46
+ plan.update_state(state) if plan.state != state
47
47
 
48
48
  coordinator.release(planning_lock)
49
49
  execute(plan.id) if plan.state == :planned
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Necas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-06-23 00:00:00.000000000 Z
12
+ date: 1970-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -640,7 +640,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
640
640
  - !ruby/object:Gem::Version
641
641
  version: '0'
642
642
  requirements: []
643
- rubygems_version: 3.0.3
643
+ rubygems_version: 3.1.2
644
644
  signing_key:
645
645
  specification_version: 4
646
646
  summary: DYNamic workFLOW engine