rails-profiler 0.44.3 → 0.44.5
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 +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/profiler/cluster/master_client.rb +26 -13
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cb191b8de3a9b4bcb01a005af462202505e2a0af9b2991a7413f4a6a9114333
|
|
4
|
+
data.tar.gz: 16a1de65f0434ab64130c24340acb1df7db2de3db0809eee2bfd356be6157346
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6cc47fb6e12938ec9118e0be7e86f903de911695075e2feade3fa8bd9916581850446fcc0b5960d8c3ff278e65931adee0da3833ca5064df40d0a5cc12d2cf47
|
|
7
|
+
data.tar.gz: 19ec8ff63c93f61751287a1bfd02e22af74b98d8c4d11d9492855fe2b09d113f79ed841fef629efe3a4fd283a26caafa438d39b47e3418c26a2e9ced11bab5ad
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,24 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.5] - 2026-10-21
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Cluster:** `docs/cluster.md` now says that the master must run as a single process. Its registry
|
|
29
|
+
of slaves is kept in memory, so with several workers each heartbeat reaches one of them and a
|
|
30
|
+
slave appears `offline` on the others.
|
|
31
|
+
|
|
32
|
+
## [0.44.4] - 2026-10-21
|
|
33
|
+
|
|
34
|
+
<!-- stamped -->
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **Cluster:** a slave no longer delays the boot of the server, of `rails console` or of a rake task when its master is unreachable. The first registration now runs in the heartbeat thread instead of `after_initialize`, and calls to the master time out after 3 seconds to connect and 5 seconds to read, instead of 60 seconds each.
|
|
39
|
+
|
|
22
40
|
## [0.44.3] - 2026-10-21
|
|
23
41
|
|
|
24
42
|
<!-- stamped -->
|
|
@@ -20,6 +20,10 @@ module Profiler
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# A master that does not answer must cost the heartbeat thread a few seconds, not a minute.
|
|
24
|
+
OPEN_TIMEOUT = 3
|
|
25
|
+
READ_TIMEOUT = 5
|
|
26
|
+
|
|
23
27
|
class << self
|
|
24
28
|
# The client the railtie started in this process, for the fork hook to restart.
|
|
25
29
|
attr_accessor :current
|
|
@@ -42,12 +46,7 @@ module Profiler
|
|
|
42
46
|
self.class.current = self
|
|
43
47
|
self.class.install_fork_hook!
|
|
44
48
|
@registered = false
|
|
45
|
-
|
|
46
|
-
register!
|
|
47
|
-
@registered = true
|
|
48
|
-
rescue => e
|
|
49
|
-
log_warn("could not register with master at startup, will retry in the heartbeat loop", e)
|
|
50
|
-
end
|
|
49
|
+
@failed = false
|
|
51
50
|
@started = true
|
|
52
51
|
start_heartbeat_thread
|
|
53
52
|
end
|
|
@@ -59,6 +58,7 @@ module Profiler
|
|
|
59
58
|
return if @started.nil? || @thread&.alive?
|
|
60
59
|
|
|
61
60
|
@registered = false
|
|
61
|
+
@failed = false
|
|
62
62
|
start_heartbeat_thread
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -68,7 +68,7 @@ module Profiler
|
|
|
68
68
|
config = Profiler.configuration
|
|
69
69
|
uri = master_uri("register")
|
|
70
70
|
body = { name: config.resolved_name, url: config.self_url }.to_json
|
|
71
|
-
resp =
|
|
71
|
+
resp = post(uri, body)
|
|
72
72
|
unless resp.code.to_i.between?(200, 299)
|
|
73
73
|
raise "Master returned #{resp.code}: #{resp.body.to_s.slice(0, 200)}"
|
|
74
74
|
end
|
|
@@ -80,10 +80,19 @@ module Profiler
|
|
|
80
80
|
config = Profiler.configuration
|
|
81
81
|
uri = master_uri("heartbeat")
|
|
82
82
|
body = { name: config.resolved_name }.to_json
|
|
83
|
-
resp =
|
|
83
|
+
resp = post(uri, body)
|
|
84
84
|
raise "Heartbeat rejected #{resp.code}" unless resp.code.to_i.between?(200, 299)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
def post(uri, body)
|
|
88
|
+
Profiler.untracked_http do
|
|
89
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https",
|
|
90
|
+
open_timeout: OPEN_TIMEOUT, read_timeout: READ_TIMEOUT) do |http|
|
|
91
|
+
http.post(uri.request_uri, body, request_headers)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
87
96
|
# Refused before any request when the secret would cross the network in clear, or when
|
|
88
97
|
# there is no secret for the master to accept.
|
|
89
98
|
def master_uri(action)
|
|
@@ -111,20 +120,24 @@ module Profiler
|
|
|
111
120
|
@thread = Profiler::Instrumentation::RequestContext.detached { Thread.new { heartbeat_loop } }
|
|
112
121
|
end
|
|
113
122
|
|
|
123
|
+
# The first registration is the first turn of the loop, so an unreachable master never
|
|
124
|
+
# delays the boot of the process that started the client.
|
|
114
125
|
def heartbeat_loop
|
|
115
126
|
interval = Profiler.configuration.cluster_heartbeat_interval
|
|
116
127
|
loop do
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
if @registered
|
|
129
|
+
heartbeat!
|
|
130
|
+
else
|
|
119
131
|
register!
|
|
120
132
|
@registered = true
|
|
121
|
-
log_info("Re-registered with master after previous failure")
|
|
122
|
-
else
|
|
123
|
-
heartbeat!
|
|
133
|
+
log_info("Re-registered with master after previous failure") if @failed
|
|
124
134
|
end
|
|
125
135
|
rescue => e
|
|
126
136
|
@registered = false
|
|
137
|
+
@failed = true
|
|
127
138
|
log_warn("communication with the master failed, will retry", e)
|
|
139
|
+
ensure
|
|
140
|
+
sleep interval
|
|
128
141
|
end
|
|
129
142
|
end
|
|
130
143
|
|
data/lib/profiler/version.rb
CHANGED