tina4ruby 3.13.161 → 3.13.162

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: 819ee4d3aa8004a8ab9c4a36f0bf6ae4448da8025695a24d20609f96d2ef6cf4
4
- data.tar.gz: a2d690efa933ac65508944f721dab4d9cf31268853276a782ec30329f47c8d0b
3
+ metadata.gz: 15151f90c7170c25e2174fdf43bbf5c847c65478b082dd5bdbda8049a5b57b97
4
+ data.tar.gz: a040ce2ecad0cfe976a1eb579c001e07c4f9f27244f8c1e35591ba1b536ea8cc
5
5
  SHA512:
6
- metadata.gz: d363d16ad9e5aecd10fd33d448ab57d8d7d16c96d0a0946a648de15ec7d29bcd6025042532d97fde774711e8453dbf943a96d63c3f8b3216230bcd1f4e19f22d
7
- data.tar.gz: c3301274025ad604123048130bea9efe11b3c47261f3109bc81effcd9d29b14df2fd98462c33ed3e748c53bf3ace9dd84b54bbcdd95e543d906c5d8aadb8ae93
6
+ metadata.gz: e1a7d0ff48f5310c2ee54a8d33c78bdfdcbdb1480a7633136cbde22cdea58c2e8b4f27845d1a21a14c79e4f4789c8b9fc009ec0bd61026a639ee0842598279c4
7
+ data.tar.gz: 1bead80a66a17fe802aac1efdd010695e884966c0b6848bfe18d6892899bd6f48e0854303afb67f303532649302201eb85ffcee7308b2cef304e2cd03f9ae2e4
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ number means the same thing everywhere.
6
6
  **The authoritative release notes for every shipped version live in the documentation:**
7
7
  https://tina4.com/ruby/36-releases
8
8
 
9
+ ## 3.13.162 - 2026-11-10
10
+
11
+ ### Fixed
12
+
13
+ - Kafka tombstone (null-value) records no longer crash the consumer (tina4-python#303 twin). A tombstone — a record whose value is `null` (Debezium deletes, log-compacted delete markers) — reached `Tina4.parse_json(msg.payload)` on the rdkafka path, and `JSON.parse(nil)` raised `TypeError`, which `rescue Rdkafka::RdkafkaError` did not catch, so it escaped and killed the consumer; because the tombstone sits at the committed offset it was a poison pill that re-crashed on every restart. `dequeue` and the `dead_letters` reader now skip a `nil`-payload record and continue, so a following real record is still delivered. No mocks — driven against a real librdkafka producer/broker (#167).
14
+
9
15
  ## 3.13.161 - 2026-11-09
10
16
 
11
17
  ### Fixed
@@ -161,26 +161,8 @@ module Tina4
161
161
  end
162
162
  return nil unless msg
163
163
 
164
- data = Tina4.parse_json(msg.payload)
165
- coordinate = "#{topic}:#{msg.partition}:#{msg.offset}"
166
-
167
- # A record carrying a "payload" key is a Tina4 envelope: keep its own id
168
- # (falling back to the coordinate) and carry attempts/error back so a
169
- # redelivery does not reset the count and re-produce a poison record
170
- # forever. A record WITHOUT one is externally produced (Debezium/CDC and
171
- # friends, no envelope, no id -- tina4#274): its whole value IS the
172
- # payload, and the coordinate becomes its id. Either way the job gets the
173
- # id acknowledge() maps back to this record's offset.
174
- job =
175
- if data.is_a?(Hash) && data.key?("payload")
176
- id = data["id"].to_s.empty? ? coordinate : data["id"]
177
- Tina4::Job.new(
178
- topic: topic, payload: data["payload"], id: id,
179
- attempts: data["attempts"] || 0, error: data["error"]
180
- )
181
- else
182
- Tina4::Job.new(topic: topic, payload: data, id: coordinate, attempts: 0)
183
- end
164
+ job = job_from_message(topic, msg)
165
+ return nil unless job
184
166
 
185
167
  @in_flight[job.id.to_s] = msg
186
168
  job
@@ -188,6 +170,39 @@ module Tina4
188
170
  nil
189
171
  end
190
172
 
173
+ # Build a Job from a polled record, or nil for a record that carries no job.
174
+ #
175
+ # A null-value record is a tombstone / delete marker: Debezium emits these on
176
+ # deletes and log-compacted topics use them as delete markers, so they are
177
+ # normal on Kafka. rdkafka hands back a nil payload for one; return nil (skip
178
+ # it) so dequeue advances past it. Before this guard, JSON.parse(nil) raised a
179
+ # TypeError that dequeue's `rescue Rdkafka::RdkafkaError` did NOT catch, so the
180
+ # tombstone was a poison pill that killed the consumer on every restart
181
+ # (tina4-python#303, same crash in the rdkafka path).
182
+ #
183
+ # A record carrying a "payload" key is a Tina4 envelope: keep its own id
184
+ # (falling back to the coordinate) and carry attempts/error back so a
185
+ # redelivery does not reset the count and re-produce a poison record forever.
186
+ # A record WITHOUT one is externally produced (Debezium/CDC and friends, no
187
+ # envelope, no id -- tina4#274): its whole value IS the payload, and the
188
+ # coordinate becomes its id. Either way the job gets the id acknowledge()
189
+ # maps back to this record's offset.
190
+ def job_from_message(topic, msg)
191
+ return nil if msg.payload.nil?
192
+
193
+ data = Tina4.parse_json(msg.payload)
194
+ coordinate = "#{topic}:#{msg.partition}:#{msg.offset}"
195
+ if data.is_a?(Hash) && data.key?("payload")
196
+ id = data["id"].to_s.empty? ? coordinate : data["id"]
197
+ Tina4::Job.new(
198
+ topic: topic, payload: data["payload"], id: id,
199
+ attempts: data["attempts"] || 0, error: data["error"]
200
+ )
201
+ else
202
+ Tina4::Job.new(topic: topic, payload: data, id: coordinate, attempts: 0)
203
+ end
204
+ end
205
+
191
206
  # Kafka has no queue depth: a log is a sequence of offsets, not a queue,
192
207
  # and computing a "remaining" count means an admin round-trip per call.
193
208
  # ADR-0022 decision 5 records 0 as the documented answer, which Python and
@@ -287,6 +302,11 @@ module Tina4
287
302
  loop do
288
303
  msg = reader.poll(500)
289
304
  if msg
305
+ # Skip a tombstone / null-value record the same way dequeue does, so
306
+ # a null-value dead-letter never crashes the reader on JSON.parse(nil)
307
+ # (tina4-python#303).
308
+ next if msg.payload.nil?
309
+
290
310
  data = Tina4.parse_json(msg.payload)
291
311
  data["status"] = "dead"
292
312
  out << data
@@ -72,17 +72,29 @@ module Tina4
72
72
  return if @shutting_down
73
73
 
74
74
  @shutting_down = true
75
- Tina4::Log.info("Shutdown signal received, stopping gracefully...")
76
75
 
77
- stop_accepting
78
- drained = wait_for_in_flight
79
- release_resources
80
-
81
- Tina4::Log.info("Shutdown complete")
76
+ # The whole teardown runs INSIDE the signal handler's thread
77
+ # (install_signal_handlers). An exception escaping here - a failing log
78
+ # sink under TINA4_LOG_STRICT, a half-closed WebSocket, a dead database
79
+ # driver, Log.reset - would kill that thread mid-teardown. If it dies
80
+ # BEFORE stop_accepting, the listening socket never closes and the
81
+ # process HANGS on a signal that MUST drain and exit 0; if it dies
82
+ # later, resources leak. So every step degrades independently
83
+ # (guard_teardown) and the critical ones still run even when an earlier
84
+ # step threw - mirrors the per-step try/catch(\Throwable) in PHP's
85
+ # Server::cleanup()/stop().
86
+ guard_teardown { Tina4::Log.info("Shutdown signal received, stopping gracefully...") }
87
+ guard_teardown { stop_accepting }
88
+
89
+ drained = true
90
+ guard_teardown { drained = wait_for_in_flight }
91
+ guard_teardown { release_resources }
92
+
93
+ guard_teardown { Tina4::Log.info("Shutdown complete") }
82
94
  # Graceful shutdown owns the final call to reset() (Decision 24 /
83
95
  # LOG-I02): flush+close owned sinks AFTER the shutdown record above,
84
96
  # exactly once.
85
- Tina4::Log.reset
97
+ guard_teardown { Tina4::Log.reset }
86
98
  @shutdown_complete = true
87
99
  return if drained
88
100
 
@@ -139,6 +151,23 @@ module Tina4
139
151
 
140
152
  private
141
153
 
154
+ # Run one teardown step so that NO exception escapes the signal handler's
155
+ # thread (see initiate_shutdown). On a failure, degrade to a best-effort
156
+ # Tina4::Log.error; if the logger itself is what failed (a strict log sink
157
+ # that raises on write), fall back to $stderr so the degrade is never
158
+ # silent - then carry on, so the shutdown still completes and the process
159
+ # still exits 0. Keeps shutdown idempotent and exception-safe without
160
+ # changing the teardown order.
161
+ def guard_teardown
162
+ yield
163
+ rescue StandardError => e
164
+ begin
165
+ Tina4::Log.error("Error during graceful shutdown: #{e.class}: #{e.message}")
166
+ rescue StandardError
167
+ warn("tina4: graceful shutdown step failed: #{e.class}: #{e.message}")
168
+ end
169
+ end
170
+
142
171
  # TINA4_SHUTDOWN_TIMEOUT in seconds (same name and default in all four
143
172
  # frameworks). An unparseable or negative value warns and falls back to the
144
173
  # default: `"abc".to_i` is 0, and a silent 0-second drain would force-close
data/lib/tina4/version.rb CHANGED
@@ -7,5 +7,5 @@
7
7
 
8
8
 
9
9
  module Tina4
10
- VERSION = "3.13.161"
10
+ VERSION = "3.13.162"
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.161
4
+ version: 3.13.162
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-09 00:00:00.000000000 Z
11
+ date: 2026-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3