inst-jobs 2.4.3 → 2.4.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: 90e78e46299d111959e7e48f25fe4e05a7939c6fb54fcd423deff4b960e79e6c
|
|
4
|
+
data.tar.gz: 20963910cd2cb1856f73cabbdc1547131a0d5096e26f7cc444f0a6e7d26b0ded
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22155dba3fd9f1201e67930be8a3cc488da21b02b2066b59fe9a0f28f5670393534ddbb87a937979df356ba602c23a27e97f7650463fa2eb7c53e76647df5f02
|
|
7
|
+
data.tar.gz: 41a6bec7f263657aac33b62eeb8169db1898dfdcdbfadc32d91a985f54cb037a5691d75f02dff80b9c80ea57387a746fa70e6710545fe6b9c12724dde9f8f720
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDeleteConflictingSingletonsBeforeUnlockTrigger < ActiveRecord::Migration[5.2]
|
|
4
|
+
def up
|
|
5
|
+
execute(<<~SQL)
|
|
6
|
+
CREATE FUNCTION delayed_jobs_before_unlock_delete_conflicting_singletons_row_fn () RETURNS trigger AS $$
|
|
7
|
+
BEGIN
|
|
8
|
+
IF EXISTS (SELECT 1 FROM delayed_jobs j2 WHERE j2.singleton=OLD.singleton) THEN
|
|
9
|
+
DELETE FROM delayed_jobs WHERE id<>OLD.id AND singleton=OLD.singleton;
|
|
10
|
+
END IF;
|
|
11
|
+
RETURN NEW;
|
|
12
|
+
END;
|
|
13
|
+
$$ LANGUAGE plpgsql;
|
|
14
|
+
SQL
|
|
15
|
+
execute(<<~SQL)
|
|
16
|
+
CREATE TRIGGER delayed_jobs_before_unlock_delete_conflicting_singletons_row_tr BEFORE UPDATE ON delayed_jobs FOR EACH ROW WHEN (
|
|
17
|
+
OLD.singleton IS NOT NULL AND
|
|
18
|
+
OLD.singleton=NEW.singleton AND
|
|
19
|
+
OLD.locked_by IS NOT NULL AND
|
|
20
|
+
NEW.locked_by IS NULL) EXECUTE PROCEDURE delayed_jobs_before_unlock_delete_conflicting_singletons_row_fn();
|
|
21
|
+
SQL
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def down
|
|
25
|
+
execute("DROP FUNCTION delayed_jobs_before_unlock_delete_conflicting_singletons_row_tr_fn()")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -98,11 +98,11 @@ module Delayed
|
|
|
98
98
|
fn_name = connection.quote_table_name("half_md5_as_bigint")
|
|
99
99
|
sql = "SELECT pg_advisory_xact_lock(#{fn_name}(#{connection.quote(values['strand'])})); #{sql}"
|
|
100
100
|
end
|
|
101
|
-
result = connection.execute(sql, "#{self} Create")
|
|
101
|
+
result = connection.execute(sql, "#{self.class} Create")
|
|
102
102
|
self.id = result.values.first&.first
|
|
103
103
|
result.clear
|
|
104
104
|
else
|
|
105
|
-
result = connection.exec_query(sql, "#{self} Create", binds)
|
|
105
|
+
result = connection.exec_query(sql, "#{self.class} Create", binds)
|
|
106
106
|
self.id = connection.send(:last_inserted_id, result)
|
|
107
107
|
end
|
|
108
108
|
|
data/lib/delayed/version.rb
CHANGED
|
@@ -491,6 +491,19 @@ shared_examples_for "a backend" do
|
|
|
491
491
|
expect(@job2).to be_new_record
|
|
492
492
|
end
|
|
493
493
|
end
|
|
494
|
+
|
|
495
|
+
context "when unlocking with another singleton pending" do
|
|
496
|
+
it "deletes the pending singleton" do
|
|
497
|
+
@job1 = create_job(singleton: "myjobs", max_attempts: 2)
|
|
498
|
+
expect(Delayed::Job.get_and_lock_next_available("w1")).to eq(@job1)
|
|
499
|
+
|
|
500
|
+
@job2 = create_job(singleton: "myjobs", max_attempts: 2)
|
|
501
|
+
|
|
502
|
+
@job1.reload.reschedule
|
|
503
|
+
expect { @job1.reload }.not_to raise_error
|
|
504
|
+
expect { @job2.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
|
505
|
+
end
|
|
506
|
+
end
|
|
494
507
|
end
|
|
495
508
|
end
|
|
496
509
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "delayed_job"
|
|
|
4
4
|
require "delayed/testing"
|
|
5
5
|
|
|
6
6
|
require "database_cleaner"
|
|
7
|
+
require "fileutils"
|
|
7
8
|
require "rack/test"
|
|
8
9
|
require "timecop"
|
|
9
10
|
require "webmock/rspec"
|
|
@@ -80,7 +81,8 @@ Delayed::Backend::ActiveRecord::Job.reset_column_information
|
|
|
80
81
|
Delayed::Backend::ActiveRecord::Job::Failed.reset_column_information
|
|
81
82
|
|
|
82
83
|
Time.zone = "UTC" # rubocop:disable Rails/TimeZoneAssignment
|
|
83
|
-
|
|
84
|
+
FileUtils.mkdir_p("tmp")
|
|
85
|
+
ActiveRecord::Base.logger = Rails.logger = Logger.new("tmp/test.log")
|
|
84
86
|
|
|
85
87
|
# Purely useful for test cases...
|
|
86
88
|
class Story < ActiveRecord::Base
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inst-jobs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.4.
|
|
4
|
+
version: 2.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Luetke
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2021-09-
|
|
12
|
+
date: 2021-09-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
@@ -431,6 +431,7 @@ files:
|
|
|
431
431
|
- db/migrate/20200825011002_add_strand_order_override.rb
|
|
432
432
|
- db/migrate/20210809145804_add_n_strand_index.rb
|
|
433
433
|
- db/migrate/20210812210128_add_singleton_column.rb
|
|
434
|
+
- db/migrate/20210917232626_add_delete_conflicting_singletons_before_unlock_trigger.rb
|
|
434
435
|
- exe/inst_jobs
|
|
435
436
|
- lib/delayed/backend/active_record.rb
|
|
436
437
|
- lib/delayed/backend/base.rb
|
|
@@ -511,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
511
512
|
- !ruby/object:Gem::Version
|
|
512
513
|
version: '0'
|
|
513
514
|
requirements: []
|
|
514
|
-
rubygems_version: 3.2.
|
|
515
|
+
rubygems_version: 3.2.24
|
|
515
516
|
signing_key:
|
|
516
517
|
specification_version: 4
|
|
517
518
|
summary: Instructure-maintained fork of delayed_job
|