switchman-inst-jobs 4.3.0 → 4.3.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d126fdf9fae2bd957760dd1fdf1cac821e5103eb691fc2b293b3bda6170bb5c
|
|
4
|
+
data.tar.gz: 977e7915aea7e1e389ad95c190e5ae749a868f869f1d28542ee264342f57b89e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 407591bf52c6068c6133b1654a68ffacb4aae0c0d941f7bdab9536a682c70a0a3ca04017c68e61ac6475fbd75a0b7cb93c35b1ce94e6e54b69fb638020802225
|
|
7
|
+
data.tar.gz: d5a69e5b56e07f4c90dcd5fea9f28f491c56f832acdd821b081ee5d3bb068af516b9ca114d464cda4f154edf4765b91c3d10c05f60b31c6612b5e72dca0c79ec
|
|
@@ -35,12 +35,24 @@ module SwitchmanInstJobs
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def migrate_shards(shard_map)
|
|
38
|
-
|
|
38
|
+
effective_map = shard_map.dup
|
|
39
|
+
source_shards = Hash.new([].freeze)
|
|
39
40
|
target_shards = Hash.new([].freeze)
|
|
40
|
-
|
|
41
|
+
# Also add any incomplete moves to the source shards to ensure we clean up appropriately
|
|
42
|
+
::Switchman::Shard.where.not(previous_delayed_jobs_shard_id: nil).find_each do |shard|
|
|
43
|
+
effective_map[shard.id] ||= shard.delayed_jobs_shard.id
|
|
44
|
+
end
|
|
45
|
+
effective_map.each do |(shard, target_shard)|
|
|
41
46
|
shard = ::Switchman::Shard.find(shard) unless shard.is_a?(::Switchman::Shard)
|
|
42
|
-
source_shards << shard.delayed_jobs_shard.id
|
|
43
47
|
target_shard = target_shard.try(:id) || target_shard
|
|
48
|
+
# if a move was interrupted, the new shard is already set as the delayed_jobs_shard
|
|
49
|
+
# but we still have the old shard stored in previous_delayed_jobs_shard and should
|
|
50
|
+
# act as if we are moving from there in the first place
|
|
51
|
+
if shard.previous_delayed_jobs_shard_id && shard.delayed_jobs_shard.id == target_shard
|
|
52
|
+
source_shards[shard.previous_delayed_jobs_shard_id] += [shard.id]
|
|
53
|
+
else
|
|
54
|
+
source_shards[shard.delayed_jobs_shard.id] += [shard.id]
|
|
55
|
+
end
|
|
44
56
|
target_shards[target_shard] += [shard.id]
|
|
45
57
|
|
|
46
58
|
@validation_callbacks&.each do |proc|
|
|
@@ -48,26 +60,33 @@ module SwitchmanInstJobs
|
|
|
48
60
|
end
|
|
49
61
|
end
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
::Switchman::Shard.transaction do
|
|
64
|
+
# Do the updates in batches and then just clear redis instead of clearing them one at a time
|
|
65
|
+
source_shards.each do |source_shard, shards|
|
|
66
|
+
updates = { previous_delayed_jobs_shard_id: source_shard }
|
|
67
|
+
::Switchman::Shard.where(id: shards).update_all(updates)
|
|
68
|
+
end
|
|
69
|
+
target_shards.each do |target_shard, shards|
|
|
70
|
+
updates = { delayed_jobs_shard_id: target_shard, block_stranded: true }
|
|
71
|
+
updates[:updated_at] = Time.zone.now if ::Switchman::Shard.column_names.include?("updated_at")
|
|
72
|
+
::Switchman::Shard.where(id: shards).update_all(updates)
|
|
73
|
+
end
|
|
56
74
|
end
|
|
57
75
|
clear_shard_cache(default: ::Switchman::Shard.exists?(id: target_shards.values.flatten, default: true))
|
|
58
76
|
|
|
59
77
|
::Switchman::Shard.clear_cache
|
|
60
78
|
# rubocop:disable Style/CombinableLoops
|
|
61
79
|
# We first migrate strands so that we can stop blocking strands before we migrate unstranded jobs
|
|
62
|
-
source_shards.
|
|
80
|
+
source_shards.each_key do |s|
|
|
63
81
|
::Switchman::Shard.lookup(s).activate(::Delayed::Backend::ActiveRecord::AbstractJob) { migrate_strands }
|
|
64
82
|
end
|
|
65
83
|
|
|
66
|
-
source_shards.
|
|
84
|
+
source_shards.each_key do |s|
|
|
67
85
|
::Switchman::Shard.lookup(s).activate(::Delayed::Backend::ActiveRecord::AbstractJob) { migrate_everything }
|
|
68
86
|
end
|
|
69
|
-
ensure_unblock_stranded_for(
|
|
87
|
+
ensure_unblock_stranded_for(effective_map.map(&:first))
|
|
70
88
|
# rubocop:enable Style/CombinableLoops
|
|
89
|
+
::Switchman::Shard.where(id: effective_map.map(&:first)).update_all(previous_delayed_jobs_shard_id: nil)
|
|
71
90
|
end
|
|
72
91
|
|
|
73
92
|
# if :migrate_strands ran on any shards that fell into scenario 1, then
|
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.3.
|
|
4
|
+
version: 4.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Petty
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: inst-jobs
|
|
@@ -136,6 +136,7 @@ files:
|
|
|
136
136
|
- db/migrate/20220203063200_remove_old_singleton_index.rb
|
|
137
137
|
- db/migrate/20220328152900_add_failed_jobs_indicies.rb
|
|
138
138
|
- db/migrate/20220519204546_add_requeued_job_id_to_failed_jobs.rb
|
|
139
|
+
- db/migrate/20260120092005_add_previous_jobs_shard.rb
|
|
139
140
|
- lib/switchman-inst-jobs.rb
|
|
140
141
|
- lib/switchman_inst_jobs.rb
|
|
141
142
|
- lib/switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter.rb
|