pgbus 0.11.3 → 0.12.0

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.
@@ -146,7 +146,9 @@ module Pgbus
146
146
  wait_once
147
147
  end
148
148
  rescue StandardError => e
149
- @logger.error { "[Pgbus::NotifyListener] fatal: #{e.class}: #{e.message}" } if running?
149
+ # Report, don't just log: a listener that dies at boot silently
150
+ # degrades every worker to polling (issue #352).
151
+ ErrorReporter.report(e, { action: "notify_listener_fatal" }) if running?
150
152
  ensure
151
153
  # Clear @running so #start can spawn a fresh thread after a fatal exit
152
154
  # (e.g. build_connection raising at boot). Without this, the dead
@@ -242,7 +244,7 @@ module Pgbus
242
244
  # partially-built conn is orphaned and the next retry just allocates
243
245
  # another one — leaking PG connections on repeated failures.
244
246
  close_quietly(new_conn)
245
- @logger.error { "[Pgbus::NotifyListener] reconnect failed: #{e.class}: #{e.message}" }
247
+ ErrorReporter.report(e, { action: "notify_listener_reconnect" })
246
248
  sleep RECONNECT_BACKOFF_SECONDS
247
249
  next
248
250
  end
@@ -255,11 +257,11 @@ module Pgbus
255
257
  end
256
258
  end
257
259
 
260
+ # String/Hash go through DedicatedConnection so a :session-mode
261
+ # `:variables` key never reaches PG.connect (issue #352).
258
262
  def build_connection
259
- require "pg" unless defined?(::PG::Connection)
260
263
  case @connection_options
261
- when String then ::PG.connect(@connection_options)
262
- when Hash then ::PG.connect(**@connection_options)
264
+ when String, Hash then Pgbus::DedicatedConnection.connect(@connection_options)
263
265
  else
264
266
  raise Pgbus::ConfigurationError,
265
267
  "NotifyListener cannot build a PG connection from #{@connection_options.class}. " \
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.11.3"
4
+ VERSION = "0.12.0"
5
5
  end
@@ -74,7 +74,11 @@ module Pgbus
74
74
  unsupported_server
75
75
  end
76
76
  rescue StandardError => e
77
- logger.error { "[Pgbus::StreamApp] #{e.class}: #{e.message}" }
77
+ # Report, don't just log: a broken streamer config (e.g. bad
78
+ # streams_connection_options) 500s EVERY stream request on this
79
+ # worker — logger-only made that invisible to APM (issue #352).
80
+ ErrorReporter.report(e, { action: "stream_connect" }, config: config)
81
+ logger.debug { e.backtrace&.join("\n") }
78
82
  server_error
79
83
  end
80
84
 
@@ -230,16 +230,16 @@ module Pgbus
230
230
  probe(validate_primary(build_raw_pg_connection))
231
231
  end
232
232
 
233
- # Raw PG.connect with no validation or probe. This is what the Listener's
233
+ # Raw connect with no validation or probe. This is what the Listener's
234
234
  # connection_factory calls on every reconnect attempt: the reconnect loop
235
235
  # runs its own PrimaryValidator (retrying on a replica) and skips the
236
236
  # probe to stay cheap, mirroring Pgbus::Process::NotifyListener.
237
+ # String/Hash go through DedicatedConnection so a :session-mode
238
+ # `:variables` key never reaches PG.connect (issue #352).
237
239
  def build_raw_pg_connection
238
- require "pg" unless defined?(::PG::Connection)
239
240
  opts = @config.streams_connection_options
240
241
  case opts
241
- when String then ::PG.connect(opts)
242
- when Hash then ::PG.connect(**opts)
242
+ when String, Hash then Pgbus::DedicatedConnection.connect(opts)
243
243
  when Proc
244
244
  # The Proc branch in connection_options typically returns
245
245
  # ActiveRecord::Base.connection.raw_connection — a pooled
@@ -303,7 +303,7 @@ module Pgbus
303
303
  # don't leak PG connections, then back off and retry rather than
304
304
  # letting the exception kill the listener thread silently.
305
305
  close_quietly(new_conn)
306
- @logger.error { "[Pgbus::Streamer::Listener] reconnect failed: #{e.class}: #{e.message}" }
306
+ Pgbus::ErrorReporter.report(e, { action: "streamer_reconnect" })
307
307
  sleep RECONNECT_BACKOFF_SECONDS
308
308
  next
309
309
  end
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.11.3
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
@@ -63,14 +63,14 @@ dependencies:
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.7.0
66
+ version: 0.7.1
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: 0.7.0
73
+ version: 0.7.1
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: railties
76
76
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +266,7 @@ files:
266
266
  - lib/pgbus/concurrency/semaphore.rb
267
267
  - lib/pgbus/configuration.rb
268
268
  - lib/pgbus/configuration/capsule_dsl.rb
269
+ - lib/pgbus/dedicated_connection.rb
269
270
  - lib/pgbus/dedup_cache.rb
270
271
  - lib/pgbus/doctor.rb
271
272
  - lib/pgbus/engine.rb
@@ -320,6 +321,7 @@ files:
320
321
  - lib/pgbus/pgmq_schema.rb
321
322
  - lib/pgbus/pgmq_schema/pgmq_v1.11.0.sql
322
323
  - lib/pgbus/pgmq_schema/pgmq_v1.11.1.sql
324
+ - lib/pgbus/pgmq_schema/pgmq_v1.12.0.sql
323
325
  - lib/pgbus/process/consumer.rb
324
326
  - lib/pgbus/process/consumer_priority.rb
325
327
  - lib/pgbus/process/dispatcher.rb