para 0.12.9 → 0.12.10

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: ebd0ada08791d045fb7437af457ce37ea4d61ffe47d6e809786ebf6ef6c6dff6
4
- data.tar.gz: ee5e91c50160e3ce4d838f0c530a3917dedff1339cc16d38b64adef87f108eb1
3
+ metadata.gz: e4cbe4fb5e062beed059dc791472978c89615505a9f7e148d72499293ccb71f3
4
+ data.tar.gz: 2affb52073121cab65975dd8b4b79929bd1a599662adc80dfe10c56a77db2b42
5
5
  SHA512:
6
- metadata.gz: 30e5d1f8554038eebcc28d3deba64e4ec7677106b760f2e79692b8e01752c5ecbbe9008283ba79335a3229a1415c84dbe4bcc81144272be8d6fc007090e721f8
7
- data.tar.gz: 2d21b1015f554e2b4c534c871996b334b1bbecf97b074bf4ece24313b77df97533236b56bcc2204509753a7612b0870858a28d519a4df62cd73f59459eca7496
6
+ metadata.gz: c8adbf077aa46ed899aae4e4aebfbcefae4925d9b3980bf0bbb77deb49bd05bdbc677fa52148447661cbf62d3413a7737a3d40a52c7a07b3f760a11e769ee581
7
+ data.tar.gz: f787f506e622ff1dffb71bbbed59f7698fef56bda83e5a4c25e8fac2d68822b9c2135e0fe5cbba13897663122afc49876fe66289f14c0659b554851b201ce34b
@@ -47,9 +47,19 @@ module Para
47
47
  # imports, that use the cache inside transactions but need other
48
48
  # processes to get their state in real time.
49
49
  #
50
- Thread.new do
50
+ # Outside of a transaction, the item is saved with the current connection,
51
+ # because the thread needs a second connection from the pool while the
52
+ # current thread keeps its own. When all the pool connections are held by
53
+ # busy threads, like background jobs that write their status, the thread
54
+ # waits for a connection until it times out.
55
+ #
56
+ if inside_transaction?
57
+ Thread.new do
58
+ item.save!
59
+ end.join
60
+ else
51
61
  item.save!
52
- end.join
62
+ end
53
63
 
54
64
  # Ensure cached item in RequestStore is up to date
55
65
  RequestStore.store[cache_key_for(key)] = item
@@ -60,6 +70,14 @@ module Para
60
70
 
61
71
  private
62
72
 
73
+ # The pool returns the connection already held by the current thread, or nil,
74
+ # so we don't check out a connection just to know if a transaction is open.
75
+ #
76
+ def inside_transaction?
77
+ connection = Item.connection_pool.active_connection?
78
+ connection && connection.transaction_open?
79
+ end
80
+
63
81
  def clear_expired_keys
64
82
  if Item.count > Para.config.database_cache_store_max_items
65
83
  remove_expired_items
data/lib/para/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Para
4
- VERSION = '0.12.9'
4
+ VERSION = '0.12.10'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: para
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.9
4
+ version: 0.12.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino