rpush 3.1.0 → 3.1.1

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: d01653298bef15cc73e0010be8bb353c3adcb0aecc442f3883858415189a9265
4
- data.tar.gz: ff64bca96549d684dfd2c4c6c0184dd55d3c93750c377a857f99d7ddb51405ec
3
+ metadata.gz: deccc35a73da0b426daeb20fdbbe287be5e9df9e4b8c8fcd5ef2b69c6663da68
4
+ data.tar.gz: c7038ba47604bde8a322beff513ab999e1a2692e56bd83b983cb757301e7e590
5
5
  SHA512:
6
- metadata.gz: b4ced1c3c0a14607758568a0e717b75651b4721dcb10b6f0466450e65e8a3665f6b696b90d586085e358c79c6da7cc11c336b74ddeb82561be56a5cb5bcc58eb
7
- data.tar.gz: 69f82291e5c071e93703f25385397a2dbc968f2f22685721382df52f657a2f788597dea2d110778ee342b82d0e0dab043da96f66d3a9402fcedbaf50d0a8df28
6
+ metadata.gz: 2a405b20855ef2d3c77f33c842058f95da8c7436a911712e221d5d199af82708dc8b5757f11219d2e31787311f8ea8f25384f85821c806f5492998436770743e
7
+ data.tar.gz: 4fdfe15b520768b4cbcc24c09c8859fa220fccfe18aed3a00680ff317d70ef95a4503f240262a1bdaf4aa0c4ea10be20478a4d1080e11b9b466458a8a68374c0
@@ -1,16 +1,35 @@
1
- ## HEAD
1
+ ## HEAD
2
2
 
3
- ### Breaking Changes
3
+ ### Breaking Changes
4
+
5
+ - None
4
6
 
5
- - None
7
+ ### Added
6
8
 
7
- ### Added
9
+ - None
8
10
 
9
- - None
11
+ ### Fixed
12
+
13
+ - None
14
+
15
+ ## 3.1.1 (2018-04-16)
16
+
17
+ ### Breaking Changes
10
18
 
11
- ### Fixed
19
+ - None
20
+
21
+ ### Added
22
+
23
+ - None
24
+
25
+ ### Fixed
26
+
27
+ - Database deadlock [#200](https://github.com/rpush/rpush/issues/200) (by [@loadhigh](https://github.com/loadhigh) in [#428](https://github.com/rpush/rpush/issues/428))
28
+
29
+ ### Enhancements
12
30
 
13
- - None
31
+ - Change the index on `rpush_notifications` to minimize number of locked records and pre-sort the records ([#428](https://github.com/rpush/rpush/issues/428) by [@loadhigh](https://github.com/loadhigh))
32
+ - Minimize the locking duration by moving the row dump code outside of the transaction ([#428](https://github.com/rpush/rpush/issues/428) by [@loadhigh](https://github.com/loadhigh))
14
33
 
15
34
  ## 3.1.0 (2018-04-11)
16
35
 
@@ -45,6 +45,7 @@ class RpushMigrationGenerator < Rails::Generators::Base
45
45
  add_rpush_migration('rpush_3_0_0_updates')
46
46
  add_rpush_migration('rpush_3_0_1_updates')
47
47
  add_rpush_migration('rpush_3_1_0_add_pushy')
48
+ add_rpush_migration('rpush_3_1_1_updates')
48
49
  end
49
50
 
50
51
  protected
@@ -0,0 +1,15 @@
1
+ class Rpush311Updates < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
2
+ def self.up
3
+ change_table :rpush_notifications do |t|
4
+ t.remove_index name: 'index_rpush_notifications_multi'
5
+ t.index [:delivered, :failed, :processing, :deliver_after, :created_at], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed'
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ change_table :rpush_notifications do |t|
11
+ t.remove_index name: 'index_rpush_notifications_multi'
12
+ t.index [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed'
13
+ end
14
+ end
15
+ end
@@ -11,7 +11,6 @@ module Rpush
11
11
  DEFAULT_MARK_OPTIONS = { persist: true }
12
12
 
13
13
  def initialize
14
- @using_oracle = adapter_name =~ /oracle/
15
14
  reopen_log unless Rpush.config.embedded
16
15
  end
17
16
 
@@ -29,13 +28,21 @@ module Rpush
29
28
 
30
29
  def deliverable_notifications(limit)
31
30
  with_database_reconnect_and_retry do
32
- Rpush::Client::ActiveRecord::Notification.transaction do
31
+ notifications = Rpush::Client::ActiveRecord::Notification.transaction do
33
32
  relation = ready_for_delivery
34
33
  relation = relation.limit(limit)
35
- notifications = claim(relation)
36
- mark_processing(notifications)
37
- notifications
34
+ ids = relation.lock(true).ids
35
+ unless ids.empty?
36
+ relation = Rpush::Client::ActiveRecord::Notification.where(id: ids)
37
+ # mark processing
38
+ relation.update_all(processing: true, updated_at: Time.now)
39
+ relation
40
+ else
41
+ []
42
+ end
38
43
  end
44
+
45
+ notifications.to_a
39
46
  end
40
47
  end
41
48
 
@@ -190,23 +197,7 @@ module Rpush
190
197
 
191
198
  def ready_for_delivery
192
199
  relation = Rpush::Client::ActiveRecord::Notification.where('processing = ? AND delivered = ? AND failed = ? AND (deliver_after IS NULL OR deliver_after < ?)', false, false, false, Time.now)
193
- @using_oracle ? relation : relation.order('created_at ASC')
194
- end
195
-
196
- def mark_processing(notifications)
197
- return if notifications.empty?
198
-
199
- ids = []
200
- notifications.each do |n|
201
- n.processing = true
202
- ids << n.id
203
- end
204
- Rpush::Client::ActiveRecord::Notification.where(id: ids).update_all(['processing = ?', true])
205
- end
206
-
207
- def claim(relation)
208
- notifications = relation.lock(true).to_a
209
- @using_oracle ? notifications.sort_by(&:created_at) : notifications
200
+ relation.order('deliver_after ASC, created_at ASC')
210
201
  end
211
202
 
212
203
  def adapter_name
@@ -2,7 +2,7 @@ module Rpush
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
@@ -34,6 +34,7 @@ require 'generators/templates/rpush_2_7_0_updates'
34
34
  require 'generators/templates/rpush_3_0_0_updates'
35
35
  require 'generators/templates/rpush_3_0_1_updates'
36
36
  require 'generators/templates/rpush_3_1_0_add_pushy'
37
+ require 'generators/templates/rpush_3_1_1_updates'
37
38
 
38
39
  migrations = [
39
40
  AddRpush,
@@ -43,7 +44,8 @@ migrations = [
43
44
  Rpush270Updates,
44
45
  Rpush300Updates,
45
46
  Rpush301Updates,
46
- Rpush310AddPushy
47
+ Rpush310AddPushy,
48
+ Rpush311Updates
47
49
  ]
48
50
 
49
51
  unless ENV['TRAVIS']
@@ -63,7 +63,7 @@ describe Rpush::Daemon::Store::ActiveRecord do
63
63
  Rpush.config.batch_size = 5000
64
64
  relation = double.as_null_object
65
65
  expect(relation).to receive(:limit).with(5000)
66
- allow(relation).to receive_messages(to_a: [])
66
+ allow(relation).to receive_messages(pluck: [])
67
67
  allow(store).to receive_messages(ready_for_delivery: relation)
68
68
  store.deliverable_notifications(Rpush.config.batch_size)
69
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Leitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -371,6 +371,7 @@ files:
371
371
  - lib/generators/templates/rpush_3_0_0_updates.rb
372
372
  - lib/generators/templates/rpush_3_0_1_updates.rb
373
373
  - lib/generators/templates/rpush_3_1_0_add_pushy.rb
374
+ - lib/generators/templates/rpush_3_1_1_updates.rb
374
375
  - lib/rpush.rb
375
376
  - lib/rpush/apns_feedback.rb
376
377
  - lib/rpush/cli.rb