rails-profiler 0.44.9 → 0.44.10

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: c62bf2c6ff4ba9a085f5a191537053f815ba21f19a45fd88a9e59d664133d2bf
4
- data.tar.gz: 1a542ee05b89e4c6fe1e3951928fc033eec423c509ecd8175e4f98c53f7577f5
3
+ metadata.gz: d65021e93e3235c477b1195389f5baacf516c5d50aa23c4b6ece5d51c70de6c2
4
+ data.tar.gz: 533a3039e716fce5b2326cd543de33ea64294af5a086e2c6419840049fa6bd39
5
5
  SHA512:
6
- metadata.gz: 85ce2483f4621c4483adb4f285828900bc54f6514a1f7ba1238e013d437c9c726b21e3f695c65c679db5110ed6754f05757cd0d37c12509f7cb823d85c270503
7
- data.tar.gz: 617d75b713d39f96d4ec7729e51c0c7270e13311978b3922d2d40974828e08da5c8537ef46ccf67e40d23a5cfc27b7f00b051d6f8c43747a5f99c9db4a641e82
6
+ metadata.gz: 8f96e5eaaf3dd349747120d45777a10a889e94e1eead3ecefcf3beb8178b8010d6889dbc3f212b2f93371abc4a77a62a0fac7427dc4131d055a7d12970ee379e
7
+ data.tar.gz: f6cf807989e0e7eb87e2ec99723f17e79e94595d5be951c30f6c1fad2db0ef0aff5c8abc8ab99ffac69acd7840c2aa7f42b10510d99147c49daed0770d6fb616
data/CHANGELOG.md CHANGED
@@ -19,6 +19,19 @@ every commit of every tag interval is accounted for one way or the other.
19
19
 
20
20
  ## [Unreleased]
21
21
 
22
+ ## [0.44.10] - 2026-10-22
23
+
24
+ <!-- stamped -->
25
+
26
+ ### Fixed
27
+
28
+ - **Cluster:** the master now logs a warning when a process with `cluster_master=true` forks, and
29
+ when a heartbeat is received for a slave not seen in the current worker, to help detect the
30
+ misconfiguration of running multiple master workers without a shared registry.
31
+ - **Documentation:** `DECISIONS.md` now correctly states that the gem provides shared storage
32
+ backends (file, SQLite, Redis); the decision to keep the slave registry single-process is based
33
+ on avoiding per-heartbeat writes, not on the lack of storage options.
34
+
22
35
  ## [0.44.9] - 2026-10-22
23
36
 
24
37
  <!-- stamped -->
@@ -27,6 +27,7 @@ module Profiler
27
27
  name = params[:name].to_s
28
28
  entry = Profiler.slave_registry.heartbeat(name)
29
29
  if entry.nil?
30
+ Profiler.log_warn("Cluster: received heartbeat for unknown slave #{name.inspect} (possible multi-worker misconfiguration)")
30
31
  render json: { error: "Unknown slave - please re-register" }, status: :not_found
31
32
  else
32
33
  render json: { ok: true }
@@ -20,6 +20,15 @@ module Profiler
20
20
  end
21
21
  end
22
22
 
23
+ # Fork hook for a pure master (cluster_master=true, not a slave): logs a warning when forking.
24
+ module PureMasterForkHook
25
+ def _fork
26
+ pid = super
27
+ Profiler.log_warn("Cluster: master process forked: each worker maintains a separate slave registry") if pid.zero?
28
+ pid
29
+ end
30
+ end
31
+
23
32
  # A master that does not answer must cost the heartbeat thread a few seconds, not a minute.
24
33
  OPEN_TIMEOUT = 3
25
34
  READ_TIMEOUT = 5
@@ -35,6 +44,13 @@ module Profiler
35
44
  @fork_hook_installed = true
36
45
  end
37
46
 
47
+ def install_pure_master_fork_hook!
48
+ return false if @pure_master_fork_hook_installed || !Process.respond_to?(:_fork)
49
+
50
+ Process.singleton_class.prepend(PureMasterForkHook)
51
+ @pure_master_fork_hook_installed = true
52
+ end
53
+
38
54
  def restart_after_fork
39
55
  current&.restart_after_fork
40
56
  rescue => e
@@ -57,6 +73,10 @@ module Profiler
57
73
  def restart_after_fork
58
74
  return if @started.nil? || @thread&.alive?
59
75
 
76
+ if Profiler.configuration.cluster_master?
77
+ log_warn("master process forked: each worker maintains a separate slave registry")
78
+ end
79
+
60
80
  @registered = false
61
81
  @failed = false
62
82
  start_heartbeat_thread
@@ -133,9 +133,20 @@ module Profiler
133
133
  Profiler::Cluster::Security.warn_about_configuration(Rails.logger)
134
134
  require_relative "peers"
135
135
  Profiler::Peers.warn_about_configuration(Rails.logger)
136
- next unless Profiler.configuration.slave?
137
136
 
138
137
  require_relative "cluster/master_client"
138
+
139
+ cluster_master = Profiler.configuration.cluster_master?
140
+ is_slave = Profiler.configuration.slave?
141
+
142
+ # Install fork hook for pure masters (cluster_master=true, not a slave).
143
+ # If also a slave, MasterClient.start will install the fork hook and handle warnings.
144
+ if cluster_master && !is_slave
145
+ Profiler::Cluster::MasterClient.install_pure_master_fork_hook!
146
+ end
147
+
148
+ next unless is_slave
149
+
139
150
  Profiler::Cluster::MasterClient.new.start
140
151
  end
141
152
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profiler
4
- VERSION = "0.44.9"
4
+ VERSION = "0.44.10"
5
5
 
6
6
  GEM_ROOT = File.expand_path("../..", __dir__)
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.9
4
+ version: 0.44.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Duplessy