good_job 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91a09f77d3cb46eb91c4673732e1c52ea752f8d94f95c23c81d3457dc63aa051
4
- data.tar.gz: ef21168d4aa96f3dfbf50ebed2339132bea52542209d5732d84ac23028227537
3
+ metadata.gz: d78c670393e4cddbedfe9512fdda95855709d830618cd63cfde7e724f26ce6c8
4
+ data.tar.gz: 494d3b0d6ec2b05d0bcc3386c14baca6071635647ed808a9b3543b5f1ebc4bfb
5
5
  SHA512:
6
- metadata.gz: 8140a558ee43eeb2e3673462b7279f25cbed256bac385b131aa48c2f0ff59106d2038a39c65f3f1fd11f65cbcf7d3fb232bbfd20c790e7de629047a8eaed742b
7
- data.tar.gz: 9daf8d432f5a013fbe5af10176b788c6c2e8c89e0f9b5e12568cbef7a7ecddda2b9296968e1076f71e5f26ed35a2f37d987227e7ad260030807f95404c7dbdeb
6
+ metadata.gz: bef7307febc465eab519c44a214287d5203bf0a024d83e46160dbbaf94b3a0fcd1317fbe99e446d9b0f01fb2bc8845a6dfe722fb123020aab96fe31b0c189d71
7
+ data.tar.gz: 737c03b9ad35169c9db43070abca6f644816876217fd333831db568f43eca6738dd9327eb7a403eb901ab6643e06445ba7764453d3f9b05e9e7c1159f7ba0963
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.11.2](https://github.com/bensheldon/good_job/tree/v1.11.2) (2021-07-20)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.11.1...v1.11.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Notifier waits to retry listening when database is unavailable [\#301](https://github.com/bensheldon/good_job/pull/301) ([bensheldon](https://github.com/bensheldon))
10
+
11
+ **Closed issues:**
12
+
13
+ - Handle database connection drops [\#296](https://github.com/bensheldon/good_job/issues/296)
14
+ - Using the `async` worker results in `ActiveModel::UnknownAttributeError unknown attribute 'create_with_advisory_lock' for GoodJob::Job`. [\#290](https://github.com/bensheldon/good_job/issues/290)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Rename development and test databases to be `good_job` [\#300](https://github.com/bensheldon/good_job/pull/300) ([bensheldon](https://github.com/bensheldon))
19
+ - Move generators spec into top-level spec directory; update dependencies [\#299](https://github.com/bensheldon/good_job/pull/299) ([bensheldon](https://github.com/bensheldon))
20
+
3
21
  ## [v1.11.1](https://github.com/bensheldon/good_job/tree/v1.11.1) (2021-07-07)
4
22
 
5
23
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.11.0...v1.11.1)
data/lib/good_job/job.rb CHANGED
@@ -15,6 +15,7 @@ module GoodJob
15
15
  DEFAULT_PRIORITY = 0
16
16
 
17
17
  self.table_name = 'good_jobs'.freeze
18
+ self.advisory_lockable_column = 'id'.freeze
18
19
 
19
20
  attr_readonly :serialized_params
20
21
 
@@ -24,6 +24,8 @@ module GoodJob # :nodoc:
24
24
  max_queue: 1,
25
25
  fallback_policy: :discard,
26
26
  }.freeze
27
+ # Seconds to wait if database cannot be connected to
28
+ RECONNECT_INTERVAL = 5
27
29
  # Seconds to block while LISTENing for a message
28
30
  WAIT_INTERVAL = 1
29
31
 
@@ -114,7 +116,13 @@ module GoodJob # :nodoc:
114
116
  ActiveSupport::Notifications.instrument("notifier_notify_error.good_job", { error: thread_error })
115
117
  end
116
118
 
117
- listen unless shutdown?
119
+ return if shutdown?
120
+
121
+ if thread_error.is_a?(ActiveRecord::ConnectionNotEstablished) || thread_error.is_a?(ActiveRecord::StatementInvalid)
122
+ listen(delay: RECONNECT_INTERVAL)
123
+ else
124
+ listen
125
+ end
118
126
  end
119
127
 
120
128
  private
@@ -125,8 +133,8 @@ module GoodJob # :nodoc:
125
133
  @executor = Concurrent::ThreadPoolExecutor.new(EXECUTOR_OPTIONS)
126
134
  end
127
135
 
128
- def listen
129
- future = Concurrent::Future.new(args: [@recipients, executor, @listening], executor: @executor) do |thr_recipients, thr_executor, thr_listening|
136
+ def listen(delay: 0)
137
+ future = Concurrent::ScheduledTask.new(delay, args: [@recipients, executor, @listening], executor: @executor) do |thr_recipients, thr_executor, thr_listening|
130
138
  with_listen_connection do |conn|
131
139
  ActiveSupport::Notifications.instrument("notifier_listen.good_job") do
132
140
  conn.async_exec("LISTEN #{CHANNEL}").clear
@@ -1,4 +1,4 @@
1
1
  module GoodJob
2
2
  # GoodJob gem version.
3
- VERSION = '1.11.1'.freeze
3
+ VERSION = '1.11.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-07 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob