pgmq-ruby 0.6.0 → 0.6.1

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: 812f7254909aa9125fa79b5304cb3fad8461cce5372dd02206c7cfdf9b99afa9
4
- data.tar.gz: 754f398b518800546fa2c2fe2bbaf3a3d3eb742ca5c162d9c89cd1415ac40a57
3
+ metadata.gz: c2a31db1ba5a65a0666bb496ae5b54e0a51de5cafe9b92ebf55b432ea309ef44
4
+ data.tar.gz: cbf292400bff6ca3f34bdb95ff8a7c6910df5da4db3cbabc574c7b3173864523
5
5
  SHA512:
6
- metadata.gz: 40b65d9001f469d2e88c04cc5f4bcf85b234b850a19ee4089e0b25f52b266bf45c8680398de43a61a042998a08760b867d3be1878aad518567caa6a0801cec80
7
- data.tar.gz: 175b62d75d9fa46391570026e345b18c099ab75dabfe4518acd89e750de4fce97eebd01fcc8733ce771492343a74f50dbca9534c2305e47599eebe966dd04d9d
6
+ metadata.gz: 687e92a06cb6fd93f2015390153693fb267faebc7b4bc8c54fd547cfda2ec87a1621e2be47bb9f2ac70c40b1394a854daee85c4d069845b3756c980672fc49c0
7
+ data.tar.gz: cb4c6c32f6d69e6329dd12fba2e319865087b08994e894ce169e3360595bc59fb425c6b432ca2ee040b13c4367f0b20ccf307f6fadf9b4d9619dbfc3a509f0a4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1 (2026-04-16)
4
+
5
+ ### Connection Management
6
+ - **[Fix]** `PGMQ::Connection#verify_connection!` now also resets connections whose status is `PG::CONNECTION_BAD`. Previously it only checked `conn.finished?`, which misses connections closed server-side by the database or an intermediate pooler (PgBouncer `server_idle_timeout` / `client_idle_timeout`, admin kill, TCP RST). A pooled connection with a dead socket would survive `verify_connection!` and fail on the next operation with `PQsocket() can't get socket descriptor`.
7
+ - **[Fix]** `PGMQ::Connection#connection_lost_error?` now recognises `"PQsocket() can't get socket descriptor"` (plus `"connection is closed"` / `"connection has been closed"`). This is the exact error the `pg` gem raises from its C extension when the cached libpq socket FD is gone. Without the match, the `auto_reconnect` retry path in `with_connection` skipped this error and producers failed on the first call following a server-side close.
8
+
3
9
  ## 0.6.0 (2026-04-02)
4
10
 
5
11
  ### Breaking Changes
@@ -111,29 +111,41 @@ module PGMQ
111
111
  # @param error [PG::Error] the error to check
112
112
  # @return [Boolean] true if connection was lost
113
113
  def connection_lost_error?(error)
114
- # Common connection lost errors
114
+ # Common connection lost errors. Include the pg-gem C-extension message
115
+ # ("PQsocket() can't get socket descriptor") that is raised when the
116
+ # cached libpq socket descriptor is gone — e.g. after a server-side
117
+ # close by a connection pooler such as PgBouncer.
115
118
  lost_connection_messages = [
116
119
  "server closed the connection",
117
120
  "connection not open",
121
+ "connection is closed",
122
+ "connection has been closed",
118
123
  "no connection to the server",
119
124
  "terminating connection",
120
125
  "connection to server was lost",
121
- "could not receive data from server"
126
+ "could not receive data from server",
127
+ "pqsocket() can't get socket descriptor"
122
128
  ]
123
129
 
124
- message = error.message.downcase
130
+ message = error.message.to_s.downcase
125
131
  lost_connection_messages.any? { |pattern| message.include?(pattern) }
126
132
  end
127
133
 
128
- # Verifies a connection is alive and working
134
+ # Verifies a connection is alive and working.
135
+ #
136
+ # Also resets when the connection reports `PG::CONNECTION_BAD`, which
137
+ # happens when the server (or an intermediate pooler such as PgBouncer)
138
+ # has closed the socket while the client-side `PG::Connection` object
139
+ # still exists. `#finished?` alone only catches connections closed
140
+ # explicitly from the client side.
141
+ #
129
142
  # @param conn [PG::Connection] connection to verify
130
- # @raise [PG::Error] if connection is not working
143
+ # @raise [PG::Error] if the reset itself fails
131
144
  def verify_connection!(conn)
132
- # Quick check - is connection object in bad state?
133
- return unless conn.finished?
145
+ return conn.reset if conn.finished?
146
+ return conn.reset if conn.status == PG::CONNECTION_BAD
134
147
 
135
- # Connection is finished/closed, try to reset it
136
- conn.reset
148
+ nil
137
149
  end
138
150
 
139
151
  # Normalizes various connection parameter formats
data/lib/pgmq/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module PGMQ
4
4
  # Current version of the pgmq-ruby gem
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgmq-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld