switchman-inst-jobs 3.2.10 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +1 -1
  3. data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +1 -1
  4. data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +1 -1
  5. data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +1 -1
  6. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +1 -1
  7. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +1 -1
  8. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +1 -1
  9. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +1 -1
  10. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +1 -1
  11. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +1 -1
  12. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +2 -2
  13. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -2
  14. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +1 -1
  15. data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +1 -1
  16. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -2
  17. data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +1 -1
  18. data/db/migrate/20140512213941_add_source_to_jobs.rb +1 -1
  19. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +1 -1
  20. data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +1 -1
  21. data/db/migrate/20151210162949_improve_max_concurrent.rb +1 -1
  22. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +1 -1
  23. data/db/migrate/20170308045400_add_shard_id_to_delayed_jobs.rb +1 -11
  24. data/db/migrate/20170308045401_add_delayed_jobs_shard_id_to_switchman_shards.rb +5 -0
  25. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +1 -1
  26. data/db/migrate/20190726154743_make_critical_columns_not_null.rb +1 -1
  27. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +2 -2
  28. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +1 -1
  29. data/db/migrate/20200825011002_add_strand_order_override.rb +2 -2
  30. data/lib/switchman_inst_jobs/active_record/connection_adapters/connection_pool.rb +15 -0
  31. data/lib/switchman_inst_jobs/delayed/backend/base.rb +10 -9
  32. data/lib/switchman_inst_jobs/delayed/pool.rb +1 -1
  33. data/lib/switchman_inst_jobs/delayed/worker/health_check.rb +10 -12
  34. data/lib/switchman_inst_jobs/delayed/worker.rb +2 -2
  35. data/lib/switchman_inst_jobs/engine.rb +8 -10
  36. data/lib/switchman_inst_jobs/jobs_migrator.rb +88 -144
  37. data/lib/switchman_inst_jobs/switchman/shard.rb +8 -21
  38. data/lib/switchman_inst_jobs/version.rb +1 -1
  39. data/lib/switchman_inst_jobs.rb +8 -0
  40. metadata +44 -51
  41. data/db/migrate/20210809145804_add_n_strand_index.rb +0 -12
  42. data/db/migrate/20210812210128_add_singleton_column.rb +0 -200
  43. data/db/migrate/20210917232626_add_delete_conflicting_singletons_before_unlock_trigger.rb +0 -27
  44. data/db/migrate/20210928174754_fix_singleton_condition_in_before_insert.rb +0 -56
  45. data/db/migrate/20210929204903_update_conflicting_singleton_function_to_use_index.rb +0 -27
  46. data/db/migrate/20211101190934_update_after_delete_trigger_for_singleton_index.rb +0 -137
  47. data/db/migrate/20211207094200_update_after_delete_trigger_for_singleton_transition_cases.rb +0 -171
  48. data/db/migrate/20211220112800_fix_singleton_race_condition_insert.rb +0 -59
  49. data/db/migrate/20211220113000_fix_singleton_race_condition_delete.rb +0 -207
  50. data/db/migrate/20220127091200_fix_singleton_unique_constraint.rb +0 -31
  51. data/db/migrate/20220128084800_update_insert_trigger_for_singleton_unique_constraint_change.rb +0 -60
  52. data/db/migrate/20220128084900_update_delete_trigger_for_singleton_unique_constraint_change.rb +0 -209
  53. data/db/migrate/20220203063200_remove_old_singleton_index.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7c79b622db6622d52f9fa4bc58b4b4bcd199ac246c93af1330b93f724ecec6b
4
- data.tar.gz: efa9db49c224a20c03cdb28e4c97b4071864bb8b2d7efd6c16469eeb6a32544a
3
+ metadata.gz: 1e76d31061b35e05fb85de802c868f5244c386f39490b236b7e2fa48160c1b4d
4
+ data.tar.gz: 81d2c12f67012e962b7d45157f5df7f045a3f4f0c45df2c9294661125524f234
5
5
  SHA512:
6
- metadata.gz: 3978fd1d2abc5f0adda8caeb77891153eda538e470712a2472268b104e989c573851a110db6a1e60c894a95b21ba66a348b403dcab68684e762765b8952729b8
7
- data.tar.gz: 67dfe54fc06dcf591b129d6aeda70c9019400696a3052b12e43d043a943dcd2db52f962de05acc45125e6f2824d99d9d9c72e6db4232b31adcaf9c3c1ade0512
6
+ metadata.gz: cb73f1c14a052801826a5f95cdfda52ecd73703cdc1b82b320a4b4ba69ba5ef2b4f77f01d41b1bec667df5b16a02529d8297f7de5726a392e65e086e0ad81570
7
+ data.tar.gz: 6b806f4e8e1e74e589090f75e54de9f12fe3e6ac5f97fc08296adc1c998055a082f7f815d0f7a6362d4745770e7791db100f640e6dadba5c8196ed0e940109b4
@@ -1,6 +1,6 @@
1
1
  class CreateDelayedJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddDelayedJobsTag < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddDelayedJobsMaxAttempts < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddDelayedJobsStrand < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class CleanupDelayedJobsIndexes < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class OptimizeDelayedJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddDelayedJobsNextInStrand < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class DelayedJobsDeleteTriggerLockForUpdate < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class DropPsqlJobsPopFn < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class DelayedJobsUseAdvisoryLocks < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,8 +1,8 @@
1
1
  class IndexJobsOnLockedBy < ActiveRecord::Migration[4.2]
2
- disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
2
+ disable_ddl_transaction!
3
3
 
4
4
  def connection
5
- Delayed::Backend::ActiveRecord::Job.connection
5
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
6
6
  end
7
7
 
8
8
  def up
@@ -1,8 +1,8 @@
1
1
  class AddJobsRunAtIndex < ActiveRecord::Migration[4.2]
2
- disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
2
+ disable_ddl_transaction!
3
3
 
4
4
  def connection
5
- Delayed::Backend::ActiveRecord::Job.connection
5
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
6
6
  end
7
7
 
8
8
  def up
@@ -1,6 +1,6 @@
1
1
  class ChangeDelayedJobsHandlerToText < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddFailedJobsOriginalJobId < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,11 +1,11 @@
1
1
  class CopyFailedJobsOriginalId < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
7
7
  # this is a smaller, less frequently accessed table, so we just update all at once
8
- Delayed::Backend::ActiveRecord::Job::Failed.where('original_job_id is null').update_all('original_job_id = original_id')
8
+ Delayed::Backend::ActiveRecord::Job::Failed.where(original_job_id: nil).update_all('original_job_id = original_id')
9
9
  end
10
10
 
11
11
  def down; end
@@ -1,6 +1,6 @@
1
1
  class DropFailedJobsOriginalId < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Backend::ActiveRecord::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddSourceToJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddMaxConcurrentToJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddExpiresAtToJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class ImproveMaxConcurrent < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class AddBackDefaultStringLimitsJobs < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -2,7 +2,7 @@ class AddShardIdToDelayedJobs < ActiveRecord::Migration[4.2]
2
2
  disable_ddl_transaction!
3
3
 
4
4
  def connection
5
- Delayed::Backend::ActiveRecord::Job.connection
5
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
6
6
  end
7
7
 
8
8
  def up
@@ -11,19 +11,9 @@ class AddShardIdToDelayedJobs < ActiveRecord::Migration[4.2]
11
11
 
12
12
  add_column :failed_jobs, :shard_id, :integer, limit: 8
13
13
  add_index :failed_jobs, :shard_id, algorithm: :concurrently
14
-
15
- add_column :switchman_shards, :delayed_jobs_shard_id, :integer, limit: 8
16
- add_foreign_key(
17
- :switchman_shards,
18
- :switchman_shards,
19
- column: :delayed_jobs_shard_id
20
- )
21
14
  end
22
15
 
23
16
  def down
24
- remove_foreign_key :switchman_shards, column: :delayed_jobs_shard_id
25
- remove_column :switchman_shards, :delayed_jobs_shard_id
26
-
27
17
  remove_index :failed_jobs, :shard_id
28
18
  remove_column :failed_jobs, :shard_id
29
19
 
@@ -0,0 +1,5 @@
1
+ class AddDelayedJobsShardIdToSwitchmanShards < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_reference :switchman_shards, :delayed_jobs_shard, foreign_key: { to_table: :switchman_shards }, index: false, if_not_exists: true
4
+ end
5
+ end
@@ -1,6 +1,6 @@
1
1
  class SpeedUpMaxConcurrentTriggers < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,6 +1,6 @@
1
1
  class MakeCriticalColumnsNotNull < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,8 +1,8 @@
1
1
  class AddIdToGetDelayedJobsIndex < ActiveRecord::Migration[4.2]
2
- disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
2
+ disable_ddl_transaction!
3
3
 
4
4
  def connection
5
- Delayed::Job.connection
5
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
6
6
  end
7
7
 
8
8
  def up
@@ -1,6 +1,6 @@
1
1
  class SpeedUpMaxConcurrentDeleteTrigger < ActiveRecord::Migration[4.2]
2
2
  def connection
3
- Delayed::Job.connection
3
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
4
4
  end
5
5
 
6
6
  def up
@@ -1,8 +1,8 @@
1
1
  class AddStrandOrderOverride < ActiveRecord::Migration[4.2]
2
- disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
2
+ disable_ddl_transaction!
3
3
 
4
4
  def connection
5
- Delayed::Job.connection
5
+ Delayed::Backend::ActiveRecord::AbstractJob.connection
6
6
  end
7
7
 
8
8
  def up
@@ -0,0 +1,15 @@
1
+ module SwitchmanInstJobs
2
+ module ActiveRecord
3
+ module ConnectionAdapters
4
+ module ConnectionPool
5
+ def shard
6
+ if connection_klass == ::Delayed::Backend::ActiveRecord::AbstractJob
7
+ return shard_stack.last || ::Switchman::Shard.current(::ActiveRecord::Base).delayed_jobs_shard
8
+ end
9
+
10
+ super
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -24,19 +24,18 @@ module SwitchmanInstJobs
24
24
  # In general this will only happen in unusual circumstances like tests
25
25
  # also if migrations are running, always use the current shard's job shard
26
26
  if ::ActiveRecord::Migration.open_migrations.zero? &&
27
- current_shard.delayed_jobs_shard != ::Switchman::Shard.current(:delayed_jobs)
27
+ current_shard.delayed_jobs_shard !=
28
+ ::Switchman::Shard.current(::Delayed::Backend::ActiveRecord::AbstractJob)
28
29
  enqueue_job.call
29
30
  else
30
- ::Switchman::Shard.default.activate do
31
- current_shard = ::Switchman::Shard.lookup(current_shard.id)
32
- end
31
+ current_shard = ::Switchman::Shard.lookup(current_shard.id)
33
32
  current_job_shard = current_shard.delayed_jobs_shard
34
33
 
35
34
  if (options[:singleton] || options[:strand]) && current_shard.block_stranded
36
35
  enqueue_options[:next_in_strand] = false
37
36
  end
38
37
 
39
- current_job_shard.activate(:delayed_jobs) do
38
+ current_job_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do
40
39
  enqueue_job.call
41
40
  end
42
41
  end
@@ -50,7 +49,7 @@ module SwitchmanInstJobs
50
49
  shard_ids = configured_shard_ids
51
50
  if shard_ids.any?
52
51
  shards = shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) }
53
- ::Switchman::Shard.with_each_shard(shards, [:delayed_jobs]) do
52
+ ::Switchman::Shard.with_each_shard(shards, [::Delayed::Backend::ActiveRecord::AbstractJob]) do
54
53
  super
55
54
  end
56
55
  else
@@ -61,7 +60,9 @@ module SwitchmanInstJobs
61
60
 
62
61
  def self.prepended(base)
63
62
  base.singleton_class.prepend(ClassMethods)
64
- base.shard_category = :delayed_jobs if base.name == 'Delayed::Backend::ActiveRecord::Job'
63
+ return unless base.name == 'Delayed::Backend::ActiveRecord::Job'
64
+
65
+ ::Delayed::Backend::ActiveRecord::AbstractJob.sharded_model
65
66
  end
66
67
 
67
68
  def current_shard
@@ -73,7 +74,7 @@ module SwitchmanInstJobs
73
74
  self.shard_id = shard.id
74
75
  self.shard_id = nil if shard.is_a?(::Switchman::DefaultShard)
75
76
  # If jobs are held for a shard, enqueue new ones as held as well
76
- return unless ::Switchman::Shard.columns_hash.key?('jobs_held') && shard.jobs_held
77
+ return unless shard.jobs_held
77
78
 
78
79
  self.locked_by = ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY
79
80
  self.locked_at = ::Delayed::Job.db_time_now
@@ -90,7 +91,7 @@ module SwitchmanInstJobs
90
91
  raise ShardNotFoundError, shard_id unless current_shard
91
92
 
92
93
  current_shard.activate { super }
93
- rescue ::Switchman::ConnectionError, PG::ConnectionBad, PG::UndefinedTable
94
+ rescue PG::ConnectionBad, PG::UndefinedTable
94
95
  # likely a missing shard with a stale cache
95
96
  current_shard.send(:clear_cache)
96
97
  ::Switchman::Shard.clear_cache
@@ -20,7 +20,7 @@ module SwitchmanInstJobs
20
20
  shard_ids = @config[:workers].pluck(:shard).uniq
21
21
  shards = shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) }
22
22
  end
23
- ::Switchman::Shard.with_each_shard(shards, [:delayed_jobs]) do
23
+ ::Switchman::Shard.with_each_shard(shards, [::Delayed::Backend::ActiveRecord::AbstractJob]) do
24
24
  super
25
25
  end
26
26
  end
@@ -21,18 +21,16 @@ module SwitchmanInstJobs
21
21
  def reschedule_abandoned_jobs
22
22
  shard_ids = ::SwitchmanInstJobs::Delayed::Settings.configured_shard_ids
23
23
  shards = shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) }
24
- ::Switchman::Shard.with_each_shard(shards, [:delayed_jobs]) do
25
- dj_shard = ::Switchman::Shard.current(:delayed_jobs)
26
- dj_shard.activate do
27
- munge_service_name(dj_shard) do
28
- # because this rescheduling process is running on every host, we need
29
- # to make sure that it's functioning for each shard the current
30
- # host is programmed to interact with, but ONLY for those shards.
31
- # reading the config lets us iterate over any shards this host should
32
- # work with and lets us pick the correct service name to identify which
33
- # hosts are currently alive and valid via the health checks
34
- super()
35
- end
24
+ ::Switchman::Shard.with_each_shard(shards,
25
+ [::ActiveRecord::Base, ::Delayed::Backend::ActiveRecord::AbstractJob]) do
26
+ munge_service_name(::Switchman::Shard.current) do
27
+ # because this rescheduling process is running on every host, we need
28
+ # to make sure that it's functioning for each shard the current
29
+ # host is programmed to interact with, but ONLY for those shards.
30
+ # reading the config lets us iterate over any shards this host should
31
+ # work with and lets us pick the correct service name to identify which
32
+ # hosts are currently alive and valid via the health checks
33
+ super()
36
34
  end
37
35
  end
38
36
  end
@@ -16,14 +16,14 @@ module SwitchmanInstJobs
16
16
  end
17
17
 
18
18
  def start
19
- shard.activate(:delayed_jobs) { super }
19
+ shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) { super }
20
20
  end
21
21
 
22
22
  # Worker#run is usually only called from Worker#start, but if the worker
23
23
  # is called directly from the console, we want to make sure it still gets
24
24
  # the right shard activated.
25
25
  def run
26
- shard.activate(:delayed_jobs) { super }
26
+ shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) { super }
27
27
  end
28
28
 
29
29
  def shard
@@ -11,7 +11,9 @@ module SwitchmanInstJobs
11
11
 
12
12
  ::Delayed::Worker.lifecycle.around(:work_queue_pop) do |worker, config, &block|
13
13
  if config[:shard]
14
- ::Switchman::Shard.lookup(config[:shard]).activate(:delayed_jobs) { block.call(worker, config) }
14
+ ::Switchman::Shard.lookup(config[:shard]).activate(::Delayed::Backend::ActiveRecord::AbstractJob) do
15
+ block.call(worker, config)
16
+ end
15
17
  else
16
18
  block.call(worker, config)
17
19
  end
@@ -19,17 +21,13 @@ module SwitchmanInstJobs
19
21
 
20
22
  # Ensure jobs get unblocked on the new shard if they exist
21
23
  ::Delayed::Worker.lifecycle.after(:perform) do |_worker, job|
22
- if job.strand || job.singleton
23
- column = job.strand ? :strand : :singleton
24
-
24
+ if job.strand
25
25
  ::Switchman::Shard.clear_cache
26
26
  ::Switchman::Shard.default.activate do
27
27
  current_job_shard = ::Switchman::Shard.lookup(job.shard_id).delayed_jobs_shard
28
- if current_job_shard != ::Switchman::Shard.current(:delayed_jobs)
29
- current_job_shard.activate(:delayed_jobs) do
30
- ::Delayed::Job.where(source: 'JobsMigrator::StrandBlocker', **{ column => job.try(column) }).delete_all
31
-
32
- j = ::Delayed::Job.where(**{ column => job.try(column) }).next_in_strand_order.first
28
+ if current_job_shard != ::Switchman::Shard.current(::Delayed::Backend::ActiveRecord::AbstractJob)
29
+ current_job_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do
30
+ j = ::Delayed::Job.where(strand: job.strand).next_in_strand_order.first
33
31
  j.update_column(:next_in_strand, true) if j && !j.next_in_strand
34
32
  end
35
33
  end
@@ -47,7 +45,7 @@ module SwitchmanInstJobs
47
45
  end
48
46
 
49
47
  config.after_initialize do
50
- ::Switchman::Shard.default.delayed_jobs_shard.activate!(:delayed_jobs)
48
+ ::Switchman::Shard.default.delayed_jobs_shard.activate!(::Delayed::Backend::ActiveRecord::AbstractJob)
51
49
  end
52
50
  end
53
51
  end