switchman-inst-jobs 3.2.2 → 3.2.4
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: 14940745f93050077a1b203e0fe42aa6df0fb7ba8b4ffd79c009bddfec34012f
|
|
4
|
+
data.tar.gz: 1f98af701978926bd2d2d1e51889d322b578357ce2fd18fc2a6c95ebc6688a44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e181123386e69c8ac6756c97180e656e78ef32f706453352372f0592b16f1f95bd30d6c4ae4357c293d4739c8223d609630e5fe880460f51d06572567ef60b67
|
|
7
|
+
data.tar.gz: f4b541f47270c59db82e653055acd26c39161dd9a6c4866a8d7e1232484aeb592222c920cdd1b45914a8d08d53ef7369c20891c871bae290609c8f573faba9bc
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UpdateConflictingSingletonFunctionToUseIndex < ActiveRecord::Migration[5.2]
|
|
4
|
+
def up
|
|
5
|
+
execute(<<~SQL)
|
|
6
|
+
CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_before_unlock_delete_conflicting_singletons_row_fn')} () RETURNS trigger AS $$
|
|
7
|
+
BEGIN
|
|
8
|
+
DELETE FROM delayed_jobs WHERE id<>OLD.id AND singleton=OLD.singleton AND locked_by IS NULL;
|
|
9
|
+
RETURN NEW;
|
|
10
|
+
END;
|
|
11
|
+
$$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
|
|
12
|
+
SQL
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def down
|
|
16
|
+
execute(<<~SQL)
|
|
17
|
+
CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_before_unlock_delete_conflicting_singletons_row_fn')} () RETURNS trigger AS $$
|
|
18
|
+
BEGIN
|
|
19
|
+
IF EXISTS (SELECT 1 FROM delayed_jobs j2 WHERE j2.singleton=OLD.singleton) THEN
|
|
20
|
+
DELETE FROM delayed_jobs WHERE id<>OLD.id AND singleton=OLD.singleton;
|
|
21
|
+
END IF;
|
|
22
|
+
RETURN NEW;
|
|
23
|
+
END;
|
|
24
|
+
$$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
|
|
25
|
+
SQL
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -277,7 +277,10 @@ module SwitchmanInstJobs
|
|
|
277
277
|
connection = ::Delayed::Job.connection
|
|
278
278
|
quoted_keys = keys.map { |k| connection.quote_column_name(k) }.join(', ')
|
|
279
279
|
|
|
280
|
-
connection.execute
|
|
280
|
+
connection.execute 'DROP TABLE IF EXISTS delayed_jobs_bulk_copy'
|
|
281
|
+
connection.execute "CREATE TEMPORARY TABLE delayed_jobs_bulk_copy
|
|
282
|
+
(LIKE #{::Delayed::Job.quoted_table_name} INCLUDING DEFAULTS)"
|
|
283
|
+
connection.execute "COPY delayed_jobs_bulk_copy (#{quoted_keys}) FROM STDIN"
|
|
281
284
|
records.map do |record|
|
|
282
285
|
connection.raw_connection.put_copy_data("#{keys.map { |k| quote_text(record[k]) }.join("\t")}\n")
|
|
283
286
|
end
|
|
@@ -289,6 +292,9 @@ module SwitchmanInstJobs
|
|
|
289
292
|
rescue StandardError => e
|
|
290
293
|
raise connection.send(:translate_exception, e, 'COPY FROM STDIN')
|
|
291
294
|
end
|
|
295
|
+
connection.execute "INSERT INTO #{::Delayed::Job.quoted_table_name} (#{quoted_keys})
|
|
296
|
+
SELECT #{quoted_keys} FROM delayed_jobs_bulk_copy
|
|
297
|
+
ON CONFLICT (singleton) WHERE singleton IS NOT NULL AND locked_by IS NULL DO NOTHING"
|
|
292
298
|
result.cmd_tuples
|
|
293
299
|
end
|
|
294
300
|
|
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: 3.2.
|
|
4
|
+
version: 3.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Petty
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: inst-jobs
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: 2.4.9
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '4.0'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: 2.4.9
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '4.0'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: parallel
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -300,6 +300,7 @@ files:
|
|
|
300
300
|
- db/migrate/20210812210128_add_singleton_column.rb
|
|
301
301
|
- db/migrate/20210917232626_add_delete_conflicting_singletons_before_unlock_trigger.rb
|
|
302
302
|
- db/migrate/20210928174754_fix_singleton_condition_in_before_insert.rb
|
|
303
|
+
- db/migrate/20210929204903_update_conflicting_singleton_function_to_use_index.rb
|
|
303
304
|
- lib/switchman-inst-jobs.rb
|
|
304
305
|
- lib/switchman_inst_jobs.rb
|
|
305
306
|
- lib/switchman_inst_jobs/active_record/connection_adapters/postgresql_adapter.rb
|
|
@@ -339,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
339
340
|
- !ruby/object:Gem::Version
|
|
340
341
|
version: '0'
|
|
341
342
|
requirements: []
|
|
342
|
-
rubygems_version: 3.
|
|
343
|
+
rubygems_version: 3.1.4
|
|
343
344
|
signing_key:
|
|
344
345
|
specification_version: 4
|
|
345
346
|
summary: Switchman and Instructure Jobs compatibility gem.
|