sidekiq-batch-jobs 0.3.0 → 0.3.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: 148b48f6e660baae58a41a709b7b43010e8c7a1c29585368d9d624d23ce7bfa7
4
- data.tar.gz: 5c606573cc3b223bd29b6843dc041cb8296c157b2d063b5e6d5055a736dca4b7
3
+ metadata.gz: 8f4d7393e0ca05c738c5714bd6cf5da53a0d52995d52b37560a5e6385cb88ff6
4
+ data.tar.gz: dfac8100fb929a8f97268bcc8f40c229e1753b0f43921d0a523ec14137525681
5
5
  SHA512:
6
- metadata.gz: e6b4be14970f3567194ab9f8c81fe8dde1493308c83b73165fdcfb7291f2b3d67644d0ca97168f90816955a9de78479d81111abfdf4e42c1522fb4bc6d6be8a3
7
- data.tar.gz: 4c910d40ef9a6a183541a18c8fb5d8ff2f8483ea26ad5b1cc22b2d611f0728cc3f26c36d494715a36d64b0bce24cb51683ba672e967e01dd692b750ee004e96e
6
+ metadata.gz: 1a91c9a60b67597c4535f435c349a76dcfe75820e831def7e8085798a8c3be02e06e309082d5f1afef4a0221ff05a3d453e9b855f088b4530eaff006d31e170c
7
+ data.tar.gz: 1b1a1180879ecbda260d36763c087705e93e7dfbd867203d61c9ba3b8ba2b4e1787df1f31c5337940a4f9ab9e846cb9aacf3fdbf186f3cbbdf3c5525789b0146
data/CHANGELOG.md CHANGED
@@ -5,6 +5,33 @@ All notable changes to this project are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.1] - 2026-09-08
9
+
10
+ ### Fixed
11
+
12
+ - **The reaper could fail jobs that were still running.** `JidIndex` read an executing job's id
13
+ as `work.payload["jid"]`, but `payload` holds the job as a JSON *string* rather than a nested
14
+ object, so that expression is String indexing: it finds the key *name* in the JSON and returns
15
+ the literal `"jid"`, for every job on the cluster. The live-jid index filled with a single
16
+ constant, no executing job was ever found in it, and `StuckJobReaper` marked rows orphaned
17
+ whose jobs were running perfectly well. Unrecoverable once it happened, since the job's own
18
+ `complete!` then finds the row no longer pending and leaves it failed.
19
+
20
+ Reaching it took a batch quiet for `stuck_after` (two hours by default), so the exposure was
21
+ long-running jobs, which is much of what batches are for. Present since 0.1.0.
22
+
23
+ The example covering this branch built its Redis fixture with a nested Hash, a shape no
24
+ Sidekiq version writes, so it passed throughout. It now writes the string form, alongside one
25
+ example pinning that shape and one asserting the literal `"jid"` never reaches the index.
26
+
27
+ - **`JidIndex` raised `NoMethodError` on Sidekiq 7.0 to 7.2.** `WorkSet` yielded a raw Hash
28
+ until 7.3 and a `Sidekiq::Work` since, and the code called `#payload` on whatever it got. The
29
+ gemspec has always allowed `sidekiq >= 7.0`, and every CI lane resolves 7.3 or newer, so no
30
+ lane exercised the older shape. Both are now read through `Sidekiq::JobRecord`, which
31
+ normalises the string and hash forms the way `Sidekiq::Work#job` does.
32
+
33
+ No schema change, so nothing to migrate.
34
+
8
35
  ## [0.3.0] - 2026-09-07
9
36
 
10
37
  ### Breaking
@@ -34,12 +34,28 @@ class SidekiqBatch
34
34
  end
35
35
  private_class_method :add_sorted_sets
36
36
 
37
+ # Two shapes to survive here, and reading either one naively is silently
38
+ # wrong rather than loud.
39
+ #
40
+ # `payload` holds the job as a JSON *string*, not a nested object: the
41
+ # processor stores `{queue:, payload: jobstr, run_at:}`. So `payload["jid"]`
42
+ # is String indexing, which finds the key *name* in the JSON and returns the
43
+ # literal "jid" for every job on the cluster. The index fills with one
44
+ # constant, no executing job is ever found in it, and StuckJobReaper fails
45
+ # rows whose jobs are running perfectly well.
46
+ #
47
+ # The container around it moved too: WorkSet yielded a raw Hash until 7.3,
48
+ # and a Sidekiq::Work since. This gem supports both.
49
+ #
50
+ # JobRecord is Sidekiq's own reader for a job, and normalises the string and
51
+ # hash forms of a payload the same way `Sidekiq::Work#job` does.
37
52
  def self.add_executing(jids)
38
- # `Sidekiq::Work` is a class, not a Hash — `#payload` is the supported
39
- # accessor. Hash-style access still works through method_missing, but
40
- # Sidekiq deprecated it.
41
- ::Sidekiq::Workers.new.each do |_process_id, _thread_id, work|
42
- jid = work.payload["jid"]
53
+ ::Sidekiq::WorkSet.new.each do |_process_id, _thread_id, work|
54
+ payload = work.respond_to?(:payload) ? work.payload : work["payload"]
55
+
56
+ next unless payload
57
+
58
+ jid = ::Sidekiq::JobRecord.new(payload).jid
43
59
 
44
60
  jids << jid if jid
45
61
  end
@@ -3,7 +3,7 @@
3
3
  module Sidekiq
4
4
  module Batch
5
5
  module Jobs
6
- VERSION = "0.3.0"
6
+ VERSION = "0.3.1"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-batch-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Greyling