switchman-inst-jobs 4.0.13 → 4.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +5 -3
  3. data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +2 -0
  4. data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +2 -0
  5. data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +2 -0
  6. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +9 -7
  7. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +20 -18
  8. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +28 -26
  9. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +20 -18
  10. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +4 -2
  11. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +61 -59
  12. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +3 -1
  13. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +3 -1
  14. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +2 -0
  15. data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +2 -0
  16. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -0
  17. data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +2 -0
  18. data/db/migrate/20140512213941_add_source_to_jobs.rb +2 -0
  19. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +51 -49
  20. data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +2 -0
  21. data/db/migrate/20151210162949_improve_max_concurrent.rb +37 -35
  22. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +4 -2
  23. data/db/migrate/20170308045400_add_shard_id_to_delayed_jobs.rb +2 -0
  24. data/db/migrate/20170308045401_add_delayed_jobs_shard_id_to_switchman_shards.rb +2 -0
  25. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +73 -71
  26. data/db/migrate/20190726154743_make_critical_columns_not_null.rb +2 -0
  27. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +14 -10
  28. data/db/migrate/20200818130101_add_on_hold_to_switchman_shards.rb +2 -0
  29. data/db/migrate/20200822014259_add_block_stranded_to_switchman_shards.rb +2 -0
  30. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +6 -4
  31. data/db/migrate/20200825011002_add_strand_order_override.rb +10 -7
  32. data/db/migrate/20210809145804_add_n_strand_index.rb +4 -3
  33. data/db/migrate/20210812210128_add_singleton_column.rb +12 -12
  34. data/db/migrate/20210917232626_add_delete_conflicting_singletons_before_unlock_trigger.rb +3 -3
  35. data/db/migrate/20210928174754_fix_singleton_condition_in_before_insert.rb +2 -2
  36. data/db/migrate/20210929204903_update_conflicting_singleton_function_to_use_index.rb +2 -2
  37. data/db/migrate/20211101190934_update_after_delete_trigger_for_singleton_index.rb +2 -2
  38. data/db/migrate/20211207094200_update_after_delete_trigger_for_singleton_transition_cases.rb +2 -2
  39. data/db/migrate/20211220112800_fix_singleton_race_condition_insert.rb +2 -2
  40. data/db/migrate/20211220113000_fix_singleton_race_condition_delete.rb +2 -2
  41. data/db/migrate/20220127091200_fix_singleton_unique_constraint.rb +6 -6
  42. data/db/migrate/20220128084800_update_insert_trigger_for_singleton_unique_constraint_change.rb +2 -2
  43. data/db/migrate/20220128084900_update_delete_trigger_for_singleton_unique_constraint_change.rb +2 -2
  44. data/db/migrate/20220203063200_remove_old_singleton_index.rb +8 -8
  45. data/db/migrate/20220328152900_add_failed_jobs_indicies.rb +2 -2
  46. data/lib/switchman-inst-jobs.rb +3 -1
  47. data/lib/switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter.rb +3 -1
  48. data/lib/switchman_inst_jobs/active_record/migration.rb +5 -3
  49. data/lib/switchman_inst_jobs/delayed/backend/active_record/abstract_job.rb +2 -0
  50. data/lib/switchman_inst_jobs/delayed/backend/base.rb +10 -2
  51. data/lib/switchman_inst_jobs/delayed/message_sending.rb +2 -0
  52. data/lib/switchman_inst_jobs/delayed/pool.rb +2 -0
  53. data/lib/switchman_inst_jobs/delayed/settings.rb +3 -1
  54. data/lib/switchman_inst_jobs/delayed/worker/health_check.rb +5 -3
  55. data/lib/switchman_inst_jobs/delayed/worker.rb +2 -0
  56. data/lib/switchman_inst_jobs/engine.rb +7 -5
  57. data/lib/switchman_inst_jobs/guard_rail.rb +2 -0
  58. data/lib/switchman_inst_jobs/jobs_migrator.rb +58 -55
  59. data/lib/switchman_inst_jobs/new_relic.rb +2 -0
  60. data/lib/switchman_inst_jobs/switchman/database_server.rb +3 -1
  61. data/lib/switchman_inst_jobs/switchman/default_shard.rb +2 -0
  62. data/lib/switchman_inst_jobs/switchman/shard.rb +27 -23
  63. data/lib/switchman_inst_jobs/timed_cache.rb +2 -0
  64. data/lib/switchman_inst_jobs/version.rb +3 -1
  65. data/lib/switchman_inst_jobs/yaml_extensions.rb +3 -1
  66. data/lib/switchman_inst_jobs.rb +22 -20
  67. metadata +5 -5
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SwitchmanInstJobs
2
4
  module Switchman
3
5
  module Shard
@@ -28,9 +30,9 @@ module SwitchmanInstJobs
28
30
  return unless wait
29
31
 
30
32
  delayed_jobs_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do
31
- while ::Delayed::Job.where(shard_id: id).
32
- where.not(locked_at: nil).
33
- where.not(locked_by: ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY).exists?
33
+ while ::Delayed::Job.where(shard_id: id)
34
+ .where.not(locked_at: nil)
35
+ .where.not(locked_by: ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY).exists?
34
36
  sleep 10
35
37
  lock_jobs_for_hold
36
38
  end
@@ -44,18 +46,18 @@ module SwitchmanInstJobs
44
46
  # Wait a little over the 60 second in-process shard cache clearing
45
47
  # threshold to ensure that all new jobs are now being enqueued
46
48
  # unlocked
47
- Rails.logger.debug('Waiting for caches to clear')
49
+ Rails.logger.debug("Waiting for caches to clear")
48
50
  sleep(65)
49
51
  end
50
52
  delayed_jobs_shard.activate(::Delayed::Backend::ActiveRecord::AbstractJob) do
51
- ::Delayed::Job.where(locked_by: ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY, shard_id: id).
52
- in_batches(of: 10_000).
53
- update_all(
54
- locked_by: nil,
55
- locked_at: nil,
56
- attempts: 0,
57
- failed_at: nil
58
- )
53
+ ::Delayed::Job.where(locked_by: ::Delayed::Backend::Base::ON_HOLD_LOCKED_BY, shard_id: id)
54
+ .in_batches(of: 10_000)
55
+ .update_all(
56
+ locked_by: nil,
57
+ locked_at: nil,
58
+ attempts: 0,
59
+ failed_at: nil
60
+ )
59
61
  end
60
62
  end
61
63
 
@@ -105,25 +107,27 @@ module SwitchmanInstJobs
105
107
  end
106
108
 
107
109
  def delayed_jobs_shards
108
- return none unless ::Switchman::Shard.columns_hash.key?('delayed_jobs_shard_id')
110
+ return none unless ::Switchman::Shard.columns_hash.key?("delayed_jobs_shard_id")
109
111
 
110
- scope = ::Switchman::Shard.unscoped.
111
- where(id: ::Switchman::Shard.unscoped.distinct.where.not(delayed_jobs_shard_id: nil).
112
- select(:delayed_jobs_shard_id))
112
+ scope = ::Switchman::Shard.unscoped
113
+ .where(id: ::Switchman::Shard.unscoped
114
+ .distinct
115
+ .where.not(delayed_jobs_shard_id: nil)
116
+ .select(:delayed_jobs_shard_id))
113
117
  db_jobs_shards = ::Switchman::DatabaseServer.all.map { |db| db.config[:delayed_jobs_shard] }.uniq
114
118
  db_jobs_shards.delete(nil)
115
- has_self = db_jobs_shards.delete('self')
119
+ has_self = db_jobs_shards.delete("self")
116
120
  scope = scope.or(::Switchman::Shard.unscoped.where(id: db_jobs_shards)) unless db_jobs_shards.empty?
117
121
 
118
122
  if has_self
119
- self_dbs = ::Switchman::DatabaseServer.all.
120
- select { |db| db.config[:delayed_jobs_shard] == 'self' }.map(&:id)
121
- scope = scope.or(::Switchman::Shard.unscoped.
122
- where(id: ::Switchman::Shard.unscoped.where(delayed_jobs_shard_id: nil, database_server_id: self_dbs).
123
- select(:id)))
123
+ self_dbs = ::Switchman::DatabaseServer.all
124
+ .select { |db| db.config[:delayed_jobs_shard] == "self" }.map(&:id)
125
+ scope = scope.or(::Switchman::Shard.unscoped
126
+ .where(id: ::Switchman::Shard.unscoped.where(delayed_jobs_shard_id: nil, database_server_id: self_dbs)
127
+ .select(:id)))
124
128
  end
125
129
  @jobs_scope_empty = !scope.exists? unless instance_variable_defined?(:@jobs_scope_empty)
126
- return [::Switchman::Shard.default] if @jobs_scope_empty
130
+ return ::Switchman::Shard.where(id: ::Switchman::Shard.default.id) if @jobs_scope_empty
127
131
 
128
132
  ::Switchman::Shard.merge(scope)
129
133
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SwitchmanInstJobs
2
4
  class TimedCache
3
5
  def initialize(timeout, &block)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SwitchmanInstJobs
2
- VERSION = '4.0.13'.freeze
4
+ VERSION = "4.0.14"
3
5
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SwitchmanInstJobs
2
4
  module PsychExt
3
5
  module ToRuby
4
6
  def visit_Psych_Nodes_Scalar(object) # rubocop:disable Naming/MethodName
5
- if object.tag == '!ruby/ActiveRecord:Switchman::Shard'
7
+ if object.tag == "!ruby/ActiveRecord:Switchman::Shard"
6
8
  ::Switchman::Shard.lookup(object.value) ||
7
9
  raise(Delayed::Backend::RecordNotFound,
8
10
  "Couldn't find Switchman::Shard with id #{object.value.inspect}")
@@ -1,5 +1,7 @@
1
- require 'inst-jobs'
2
- require 'switchman'
1
+ # frozen_string_literal: true
2
+
3
+ require "inst-jobs"
4
+ require "switchman"
3
5
 
4
6
  module SwitchmanInstJobs
5
7
  cattr_accessor :delayed_jobs_shard_fallback
@@ -35,21 +37,21 @@ module SwitchmanInstJobs
35
37
  end
36
38
  end
37
39
 
38
- require 'switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter'
39
- require 'switchman_inst_jobs/active_record/migration'
40
- require 'switchman_inst_jobs/delayed/settings'
41
- require 'switchman_inst_jobs/delayed/backend/active_record/abstract_job'
42
- require 'switchman_inst_jobs/delayed/backend/base'
43
- require 'switchman_inst_jobs/delayed/message_sending'
44
- require 'switchman_inst_jobs/delayed/pool'
45
- require 'switchman_inst_jobs/delayed/worker'
46
- require 'switchman_inst_jobs/delayed/worker/health_check'
47
- require 'switchman_inst_jobs/engine'
48
- require 'switchman_inst_jobs/guard_rail'
49
- require 'switchman_inst_jobs/jobs_migrator'
50
- require 'switchman_inst_jobs/new_relic'
51
- require 'switchman_inst_jobs/switchman/database_server'
52
- require 'switchman_inst_jobs/switchman/default_shard'
53
- require 'switchman_inst_jobs/switchman/shard'
54
- require 'switchman_inst_jobs/timed_cache'
55
- require 'switchman_inst_jobs/yaml_extensions'
40
+ require "switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter"
41
+ require "switchman_inst_jobs/active_record/migration"
42
+ require "switchman_inst_jobs/delayed/settings"
43
+ require "switchman_inst_jobs/delayed/backend/active_record/abstract_job"
44
+ require "switchman_inst_jobs/delayed/backend/base"
45
+ require "switchman_inst_jobs/delayed/message_sending"
46
+ require "switchman_inst_jobs/delayed/pool"
47
+ require "switchman_inst_jobs/delayed/worker"
48
+ require "switchman_inst_jobs/delayed/worker/health_check"
49
+ require "switchman_inst_jobs/engine"
50
+ require "switchman_inst_jobs/guard_rail"
51
+ require "switchman_inst_jobs/jobs_migrator"
52
+ require "switchman_inst_jobs/new_relic"
53
+ require "switchman_inst_jobs/switchman/database_server"
54
+ require "switchman_inst_jobs/switchman/default_shard"
55
+ require "switchman_inst_jobs/switchman/shard"
56
+ require "switchman_inst_jobs/timed_cache"
57
+ require "switchman_inst_jobs/yaml_extensions"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman-inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.13
4
+ version: 4.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Petty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inst-jobs
@@ -219,19 +219,19 @@ dependencies:
219
219
  - !ruby/object:Gem::Version
220
220
  version: '5.0'
221
221
  - !ruby/object:Gem::Dependency
222
- name: rubocop
222
+ name: rubocop-inst
223
223
  requirement: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - "~>"
226
226
  - !ruby/object:Gem::Version
227
- version: '1.15'
227
+ version: '1'
228
228
  type: :development
229
229
  prerelease: false
230
230
  version_requirements: !ruby/object:Gem::Requirement
231
231
  requirements:
232
232
  - - "~>"
233
233
  - !ruby/object:Gem::Version
234
- version: '1.15'
234
+ version: '1'
235
235
  - !ruby/object:Gem::Dependency
236
236
  name: rubocop-rails
237
237
  requirement: !ruby/object:Gem::Requirement