pgbus 0.13.4 → 0.13.5

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: 9f59e5211aa8a7dedbbca32416bf5f82943848229ea5cf0a967f3681f14c4613
4
- data.tar.gz: 8db3311f9117fbb1980982bb4f0de9a25ac610ff59898e8877631fdbc5c92f5f
3
+ metadata.gz: 2557dc106f7f9c66f1d8cd9aba8b08a984f9777f7c026fc66922b80006dcda92
4
+ data.tar.gz: 2ca250fe0621970c4de8135f3928214d5906b22f6e83d59389b592787b0b1eda
5
5
  SHA512:
6
- metadata.gz: 478a033b2857060eec4240e8556e789af8055fdc34fc3c17639646159e168289e1f7e0ea80443137b9980294dde3d114488abbb76317e7a2f079d2df22e79fb5
7
- data.tar.gz: 9e9ae02d538d96d30f141bed4a5da3e0420841da0364b452d0aa347b6ce242f9eae605514c148805542bdd24b44f949592e0d155f58b7a20f765e70231fd04b3
6
+ metadata.gz: e107b44c7463c408dad493570ad5393b2a2b13fc63b3d9925fbfc0ddfb00f08c3f56eb59fa91a1f6f1959a581b9bc6c6afce45286379f394c9c0b711001a5617
7
+ data.tar.gz: 9e20a794feac0b05270055a66ca6478ff3a7baeb4d845b267d624fc47b0d2038e1a1212a551bbd70ea461ca075728be81389b0e5497f105c0aa608ed7de43724
data/lib/pgbus/streams.rb CHANGED
@@ -386,10 +386,26 @@ module Pgbus
386
386
  # after_commit, so we have to check #open? explicitly — otherwise
387
387
  # every call path would hit the "deferred" branch and we'd lose the
388
388
  # msg_id return value.
389
+ #
390
+ # The probe must only inspect a connection the calling thread/fiber
391
+ # ALREADY leases — `connection_pool.active_connection?`, never
392
+ # `ActiveRecord::Base.connection`. On Rails 7.2+ `.connection` takes a
393
+ # sticky executor-scoped lease: on a non-executor thread (the
394
+ # Coalescer's flush thread, app worker threads) it is never released —
395
+ # one pool connection pinned per thread — and inside
396
+ # `with_connection` the sticky flag defeats the block-exit release, so
397
+ # the CALLER's connection leaks when its thread dies. Both variants
398
+ # exhausted an exactly-sized pool deterministically (Zazu fan-out
399
+ # incident, 2026-08-05). Semantics are unchanged: a transaction is
400
+ # per-lease, so a thread holding no connection can have no open
401
+ # transaction to defer on — the old code's fresh checkout always
402
+ # answered nil anyway, at the price of the leak.
389
403
  def current_open_transaction
390
404
  return nil unless defined?(::ActiveRecord::Base)
391
405
 
392
- connection = ::ActiveRecord::Base.connection
406
+ connection = ::ActiveRecord::Base.connection_pool.active_connection?
407
+ return nil unless connection
408
+
393
409
  transaction = connection.current_transaction
394
410
  transaction if transaction.open?
395
411
  rescue StandardError => e
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.13.4"
4
+ VERSION = "0.13.5"
5
5
  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.13.4
4
+ version: 0.13.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson