pgbus 0.8.2 → 0.8.3

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: 479168f8521b550bb2b786766ac630374cb80de0afb9e2e26afe87a9585b466c
4
- data.tar.gz: a6c28faae035eebd4eb925d66b2914e50112728b648eaefc79473a5ff8c1513c
3
+ metadata.gz: a68e87de88b53f6f1b421479e766cbb82b7e6a9fc7a4257cd11cd52ef560f1a7
4
+ data.tar.gz: d8b0f9aeb5f7cd9ff4f14db915d27066918b8fb66e8be80f1710ca07edff02ce
5
5
  SHA512:
6
- metadata.gz: 8c8dc58764091199f12b11befacf8f218038e2f09226350b52c625ea953751a25d39d3c28e74088fb9df19fe0f7b87a055b16cd380a5dae7618198ab35dda430
7
- data.tar.gz: 5a76fa6870bd3b207da626b4a8e5317d38470e4d2447cfbb20fa01faafe88eb23156d5a3ecb0ef309b758f41a8222ee8c80fe38ec66599f5239c951b4de82325
6
+ metadata.gz: 77afe26722276232120c9e0d0b41a3c3e849ac0f86c874500594db675a96b5571a7ec6a9edc30896883162d985f7081236c602f232896a04eafd660b20970b25
7
+ data.tar.gz: 8bd975ab73750cf7d22e99fcc672b86a85f125bf869f35672eb5675257d899a1526c196953f7ab4fe76c1b2a34383524ff105f63ad4bc82f79ccaf8f24c40e2e
data/lib/pgbus/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pgbus
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3"
5
5
  end
@@ -131,21 +131,16 @@ module Pgbus
131
131
  msg = @queue.pop
132
132
  break if msg == :__stop__
133
133
 
134
- # Wake coalescing: if a WakeMessage arrives, opportunistically
135
- # drain consecutive same-stream wakes from the queue. Without
136
- # this, N broadcasts in rapid succession produce N
137
- # WakeMessages, each running its own read_after roundtrip
138
- # even though one read_after with the lowest cursor would
139
- # have pulled all N messages. The drain is bounded by the
140
- # queue's current contents — once we hit a non-Wake or a
141
- # different stream, we stop and let the regular path handle
142
- # the rest.
143
- if msg.is_a?(WakeMessage) && msg.payload.nil?
144
- wakes, trailing = drain_wakes_for(msg)
145
- wakes.each { |w| handle(w) }
146
- handle(trailing) if trailing
147
- else
148
- handle(msg)
134
+ begin
135
+ if msg.is_a?(WakeMessage) && msg.payload.nil?
136
+ wakes, trailing = drain_wakes_for(msg)
137
+ wakes.each { |w| handle(w) }
138
+ handle(trailing) if trailing
139
+ else
140
+ handle(msg)
141
+ end
142
+ ensure
143
+ release_ar_connections
149
144
  end
150
145
  end
151
146
  rescue StandardError => e
@@ -483,6 +478,19 @@ module Pgbus
483
478
  # if operators actually look at it. All failures are
484
479
  # swallowed by StreamStat.record! itself so a stats-table
485
480
  # outage cannot block the dispatcher.
481
+ # Release any AR connections the dispatcher fiber acquired during
482
+ # this iteration (typically from StreamStat.record! via BusRecord).
483
+ # Without this, the connection stays leased while the fiber parks
484
+ # on @queue.pop, blocking clear_reloadable_connections! on the
485
+ # next Rails code reload (10s wedge under rack-timeout).
486
+ def release_ar_connections
487
+ return unless defined?(::ActiveRecord::Base)
488
+
489
+ Pgbus::BusRecord.connection_handler.clear_active_connections!
490
+ rescue StandardError => e
491
+ @logger.debug { "[Pgbus::Streamer::StreamEventDispatcher] AR connection release failed: #{e.class}: #{e.message}" }
492
+ end
493
+
486
494
  def record_stat(stream_name:, event_type:, started_at:, fanout: nil, ephemeral: false)
487
495
  return unless ephemeral || @config.streams_stats_enabled
488
496
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson