sidekiq 7.3.3 → 7.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f278eab88087d46198fc13a2f5019f1d7e399810ecfebeba5044ff9bfd25e271
4
- data.tar.gz: fb790ae54375a60b30b9eaf6676291a8f42c5a17a9f9487c6f018447810bb46f
3
+ metadata.gz: ada259b22664fbbb740c3d28fa06578cb6fc00a42590ea459a1f2395f8e38a92
4
+ data.tar.gz: 0636466a99e8a0df4d955b0928d76b504df74bba4e3ab13a2d08237ccd57b162
5
5
  SHA512:
6
- metadata.gz: 676ca234e7ce2218a72266f793a686c4fe5c944535ad5a76d7b7c263190a1eccb9341c06fbff0ab2e11acd4875c5dee74d959b9d1019687904b8cb53a84a6267
7
- data.tar.gz: ab7f1f5acbfc9064d93d8881354bd5a572a96f45f125c1074cf50212f23a1d60df8ac196843a45963064009f41e074eb322a50acb3680fd62ee727fcae36c14f
6
+ metadata.gz: 209f76b8ceebdb2cac83d22aab78873dad373a9ba488e7d320972e8ced4d3ac71454ef6669db321727ce3e4a85fdc5744005ff64d1a0f4cd48d9a4231bddf384
7
+ data.tar.gz: df094fd4baa169249e92309814d67d0fb5a53b5da4990c0510f5ae1d96e07541356a3014f75b8b79a97f0a91b03b92b576331422c54f36bb2c4943f2f0f87b08
data/Changes.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/sidekiq/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/sidekiq/sidekiq/blob/main/Ent-Changes.md)
4
4
 
5
+ 7.3.5
6
+ ----------
7
+
8
+ - Reimplement `retry_all` and `kill_all` API methods to use ZPOPMIN,
9
+ approximately 30-60% faster. [#6481]
10
+ - Add preload testing binary at `examples/testing/sidekiq_boot` to verify your Rails app boots correctly with Sidekiq Enterprise's app preloading.
11
+ - Fix circular require with ActiveJob adapter [#6477]
12
+ - Fix potential race condition leading to incorrect serialized values for CurrentAttributes [#6475]
13
+ - Restore missing elapsed time when default job logging is disabled
14
+
15
+ 7.3.4
16
+ ----------
17
+
18
+ - Fix FrozenError when starting Sidekiq [#6470]
19
+
5
20
  7.3.3
6
21
  ----------
7
22
 
@@ -16,7 +16,7 @@ end
16
16
  module ActiveJob
17
17
  module QueueAdapters
18
18
  # Explicitly remove the implementation existing in older rails'.
19
- remove_const(:SidekiqAdapter) if defined?(:SidekiqAdapter)
19
+ remove_const(:SidekiqAdapter) if defined?("::#{name}::SidekiqAdapter")
20
20
 
21
21
  # Sidekiq adapter for Active Job
22
22
  #
data/lib/sidekiq/api.rb CHANGED
@@ -668,6 +668,41 @@ module Sidekiq
668
668
  end
669
669
  end
670
670
 
671
+ def pop_each
672
+ Sidekiq.redis do |c|
673
+ size.times do
674
+ data, score = c.zpopmin(name, 1)&.first
675
+ break unless data
676
+ yield data, score
677
+ end
678
+ end
679
+ end
680
+
681
+ def retry_all
682
+ c = Sidekiq::Client.new
683
+ pop_each do |msg, _|
684
+ job = Sidekiq.load_json(msg)
685
+ # Manual retries should not count against the retry limit.
686
+ job["retry_count"] -= 1 if job["retry_count"]
687
+ c.push(job)
688
+ end
689
+ end
690
+
691
+ # Move all jobs from this Set to the Dead Set.
692
+ # See DeadSet#kill
693
+ def kill_all(notify_failure: false, ex: nil)
694
+ ds = DeadSet.new
695
+ opts = {notify_failure: notify_failure, ex: ex, trim: false}
696
+
697
+ begin
698
+ pop_each do |msg, _|
699
+ ds.kill(msg, opts)
700
+ end
701
+ ensure
702
+ ds.trim
703
+ end
704
+ end
705
+
671
706
  def each
672
707
  initial_size = @_size
673
708
  offset_size = 0
@@ -765,10 +800,6 @@ module Sidekiq
765
800
 
766
801
  ##
767
802
  # The set of scheduled jobs within Sidekiq.
768
- # Based on this, you can search/filter for jobs. Here's an
769
- # example where I'm selecting jobs based on some complex logic
770
- # and deleting them from the scheduled set.
771
- #
772
803
  # See the API wiki page for usage notes and examples.
773
804
  #
774
805
  class ScheduledSet < JobSet
@@ -779,26 +810,12 @@ module Sidekiq
779
810
 
780
811
  ##
781
812
  # The set of retries within Sidekiq.
782
- # Based on this, you can search/filter for jobs. Here's an
783
- # example where I'm selecting all jobs of a certain type
784
- # and deleting them from the retry queue.
785
- #
786
813
  # See the API wiki page for usage notes and examples.
787
814
  #
788
815
  class RetrySet < JobSet
789
816
  def initialize
790
817
  super("retry")
791
818
  end
792
-
793
- # Enqueues all jobs pending within the retry set.
794
- def retry_all
795
- each(&:retry) while size > 0
796
- end
797
-
798
- # Kills all jobs pending within the retry set.
799
- def kill_all
800
- each(&:kill) while size > 0
801
- end
802
819
  end
803
820
 
804
821
  ##
@@ -811,20 +828,31 @@ module Sidekiq
811
828
  super("dead")
812
829
  end
813
830
 
831
+ # Trim dead jobs which are over our storage limits
832
+ def trim
833
+ hash = Sidekiq.default_configuration
834
+ now = Time.now.to_f
835
+ Sidekiq.redis do |conn|
836
+ conn.multi do |transaction|
837
+ transaction.zremrangebyscore(name, "-inf", now - hash[:dead_timeout_in_seconds])
838
+ transaction.zremrangebyrank(name, 0, - hash[:dead_max_jobs])
839
+ end
840
+ end
841
+ end
842
+
814
843
  # Add the given job to the Dead set.
815
844
  # @param message [String] the job data as JSON
816
- # @option opts [Boolean] :notify_failure (true) Whether death handlers should be called
845
+ # @option opts [Boolean] :notify_failure (true) Whether death handlers should be called
846
+ # @option opts [Boolean] :trim (true) Whether Sidekiq should trim the structure to keep it within configuration
817
847
  # @option opts [Exception] :ex (RuntimeError) An exception to pass to the death handlers
818
848
  def kill(message, opts = {})
819
849
  now = Time.now.to_f
820
850
  Sidekiq.redis do |conn|
821
- conn.multi do |transaction|
822
- transaction.zadd(name, now.to_s, message)
823
- transaction.zremrangebyscore(name, "-inf", now - Sidekiq::Config::DEFAULTS[:dead_timeout_in_seconds])
824
- transaction.zremrangebyrank(name, 0, - Sidekiq::Config::DEFAULTS[:dead_max_jobs])
825
- end
851
+ conn.zadd(name, now.to_s, message)
826
852
  end
827
853
 
854
+ trim if opts[:trim] != false
855
+
828
856
  if opts[:notify_failure] != false
829
857
  job = Sidekiq.load_json(message)
830
858
  if opts[:ex]
@@ -839,11 +867,6 @@ module Sidekiq
839
867
  end
840
868
  true
841
869
  end
842
-
843
- # Enqueue all dead jobs
844
- def retry_all
845
- each(&:retry) while size > 0
846
- end
847
870
  end
848
871
 
849
872
  ##
@@ -5,31 +5,21 @@ module Sidekiq
5
5
  def initialize(config)
6
6
  @config = config
7
7
  @logger = @config.logger
8
- end
9
-
10
- # If true we won't do any job logging out of the box.
11
- # The user is responsible for any logging.
12
- def skip_default_logging?
13
- @config[:skip_default_job_logging]
8
+ @skip = !!@config[:skip_default_job_logging]
14
9
  end
15
10
 
16
11
  def call(item, queue)
17
- return yield if skip_default_logging?
18
-
19
- begin
20
- start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
21
- @logger.info("start")
12
+ start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
13
+ @logger.info { "start" } unless @skip
22
14
 
23
- yield
24
-
25
- Sidekiq::Context.add(:elapsed, elapsed(start))
26
- @logger.info("done")
27
- rescue Exception
28
- Sidekiq::Context.add(:elapsed, elapsed(start))
29
- @logger.info("fail")
15
+ yield
30
16
 
31
- raise
32
- end
17
+ Sidekiq::Context.add(:elapsed, elapsed(start))
18
+ @logger.info { "done" } unless @skip
19
+ rescue Exception
20
+ Sidekiq::Context.add(:elapsed, elapsed(start))
21
+ @logger.info { "fail" } unless @skip
22
+ raise
33
23
  end
34
24
 
35
25
  def prepare(job_hash, &block)
@@ -36,8 +36,8 @@ module Sidekiq
36
36
  # has a heartbeat thread, caller can use `async_beat: false`
37
37
  # and instead have thread call Launcher#heartbeat every N seconds.
38
38
  def run(async_beat: true)
39
- Sidekiq.freeze!
40
39
  logger.debug { @config.merge!({}) }
40
+ Sidekiq.freeze!
41
41
  @thread = safe_thread("heartbeat", &method(:start_heartbeat)) if async_beat
42
42
  @poller.start
43
43
  @managers.each(&:start)
@@ -33,11 +33,26 @@ module Sidekiq
33
33
  attrs = strklass.constantize.attributes
34
34
  # Retries can push the job N times, we don't
35
35
  # want retries to reset cattr. #5692, #5090
36
- job[key] = attrs if attrs.any?
36
+ if attrs.any?
37
+ # Older rails has a bug that `CurrentAttributes#attributes` always returns
38
+ # the same hash instance. We need to dup it to avoid being accidentally mutated.
39
+ job[key] = if returns_same_object?
40
+ attrs.dup
41
+ else
42
+ attrs
43
+ end
44
+ end
37
45
  end
38
46
  end
39
47
  yield
40
48
  end
49
+
50
+ private
51
+
52
+ def returns_same_object?
53
+ ActiveSupport::VERSION::MAJOR < 8 ||
54
+ (ActiveSupport::VERSION::MAJOR == 8 && ActiveSupport::VERSION::MINOR == 0)
55
+ end
41
56
  end
42
57
 
43
58
  class Load
data/lib/sidekiq/rails.rb CHANGED
@@ -3,12 +3,6 @@
3
3
  require "sidekiq/job"
4
4
  require "rails"
5
5
 
6
- begin
7
- require "active_job"
8
- require "active_job/queue_adapters/sidekiq_adapter"
9
- rescue LoadError
10
- end
11
-
12
6
  module Sidekiq
13
7
  class Rails < ::Rails::Engine
14
8
  class Reloader
@@ -45,6 +39,8 @@ module Sidekiq
45
39
  # end
46
40
  initializer "sidekiq.active_job_integration" do
47
41
  ActiveSupport.on_load(:active_job) do
42
+ require "active_job/queue_adapters/sidekiq_adapter"
43
+
48
44
  include ::Sidekiq::Job::Options unless respond_to?(:sidekiq_options)
49
45
  end
50
46
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sidekiq
4
- VERSION = "7.3.3"
4
+ VERSION = "7.3.5"
5
5
  MAJOR = 7
6
6
 
7
7
  def self.gem_version
@@ -650,6 +650,11 @@ div.interval-slider input {
650
650
  .redis-url {
651
651
  max-width: 160px;
652
652
  }
653
+
654
+ .navbar-fixed-bottom .nav {
655
+ margin-left: -15px;
656
+ margin-right: -15px;
657
+ }
653
658
  }
654
659
 
655
660
  @media (min-width: 992px) {
data/web/locales/it.yml CHANGED
@@ -6,44 +6,60 @@ it:
6
6
  AreYouSureDeleteJob: Sei sicuro di voler cancellare questo lavoro?
7
7
  AreYouSureDeleteQueue: Sei sicuro di voler cancellare la coda %{queue}?
8
8
  Arguments: Argomenti
9
+ BackToApp: Torna all'App
9
10
  Busy: Occupato
10
11
  Class: Classe
11
12
  Connections: Connessioni
13
+ CreatedAt: Creato il
12
14
  CurrentMessagesInQueue: Messaggi in <span class='title'>%{queue}</span>
13
15
  Dashboard: Dashboard
14
16
  Dead: Arrestato
15
17
  DeadJobs: Lavori arrestati
16
18
  Delete: Cancella
17
19
  DeleteAll: Cancella tutti
20
+ Deploy: Distribuire
18
21
  Enqueued: In coda
19
22
  Error: Errore
20
23
  ErrorBacktrace: Backtrace dell'errore
21
24
  ErrorClass: Classe dell'errore
22
25
  ErrorMessage: Messaggio di errore
26
+ ExecutionTime: Tempo di esecuzione
23
27
  Extras: Extra
24
28
  Failed: Fallito
25
29
  Failures: Fallimenti
30
+ Failure: Fallimento
26
31
  GoBack: ← Indietro
27
32
  History: Storia
28
33
  Job: Lavoro
29
34
  Jobs: Lavori
30
35
  Kill: Uccidere
36
+ KillAll: Uccidere tutti
31
37
  LastRetry: Ultimo tentativo
38
+ Latency: Latenza
32
39
  LivePoll: Live poll
33
40
  MemoryUsage: Memoria utilizzata
41
+ Name: Nome
34
42
  Namespace: Namespace
35
43
  NextRetry: Prossimo tentativo
36
44
  NoDeadJobsFound: Non ci sono lavori arrestati
37
45
  NoRetriesFound: Non sono stati trovati nuovi tentativi
38
46
  NoScheduledFound: Non ci sono lavori pianificati
47
+ NotYetEnqueued: Non ancora in coda
39
48
  OneMonth: 1 mese
40
49
  OneWeek: 1 settimana
41
50
  OriginallyFailed: Primo fallimento
51
+ Pause: Metti in pausa
52
+ Paused: In pausa
42
53
  PeakMemoryUsage: Memoria utilizzata (max.)
54
+ Plugins: Plugins
55
+ PollingInterval: Intervallo di polling
56
+ Process: Processo
43
57
  Processed: Processato
44
58
  Processes: Processi
45
59
  Queue: Coda
46
60
  Queues: Code
61
+ Quiet: Silenzia
62
+ QuietAll: Silenzia Tutti
47
63
  Realtime: Tempo reale
48
64
  Retries: Nuovi tentativi
49
65
  RetryAll: Riprova tutti
@@ -51,19 +67,34 @@ it:
51
67
  RetryNow: Riprova
52
68
  Scheduled: Pianificato
53
69
  ScheduledJobs: Lavori pianificati
70
+ Seconds: Secondi
54
71
  ShowAll: Mostra tutti
55
72
  SixMonths: 6 mesi
56
73
  Size: Dimensione
57
74
  Started: Iniziato
58
75
  Status: Stato
76
+ Stop: Ferma
77
+ StopAll: Ferma Tutti
59
78
  StopPolling: Ferma il polling
79
+ Success: Successo
80
+ Summary: Riepilogo
60
81
  Thread: Thread
61
- Threads: Thread
82
+ Threads: Threads
62
83
  ThreeMonths: 3 mesi
63
84
  Time: Ora
85
+ Unpause: Riattiva
64
86
  Uptime: Uptime (giorni)
87
+ Utilization: Utilizzo
65
88
  Version: Versione
66
89
  When: Quando
67
90
  Worker: Lavoratore
68
91
  active: attivo
69
92
  idle: inattivo
93
+ Metrics: Metriche
94
+ NoDataFound: Nessun dato trovato
95
+ TotalExecutionTime: Tempo totale di esecuzione
96
+ AvgExecutionTime: Tempo medio di esecuzione
97
+ Context: Contesto
98
+ NoJobMetricsFound: Metriche recenti di lavoro non trovate
99
+ Filter: Filtro
100
+ AnyJobContent: Qualsiasi contenuto di lavoro
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.3
4
+ version: 7.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-23 00:00:00.000000000 Z
11
+ date: 2024-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  - !ruby/object:Gem::Version
233
233
  version: '0'
234
234
  requirements: []
235
- rubygems_version: 3.5.11
235
+ rubygems_version: 3.5.16
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Simple, efficient background processing for Ruby