From bb53b548102ce700a32c287c1470875c1725fd6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Moyne?= Date: Sat, 12 Aug 2023 14:48:38 -0700 Subject: [PATCH 1/3] Remove the gate on a profiling port being defined in the server config for the profilez request to return profiling data even if the server doesn't have a profiling port set. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Noël Moyne --- server/monitor.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/server/monitor.go b/server/monitor.go index 2579fe1d..64a8259d 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -3657,11 +3657,6 @@ type ProfilezStatus struct { } func (s *Server) profilez(opts *ProfilezOptions) *ProfilezStatus { - if s.profiler == nil { - return &ProfilezStatus{ - Error: "Profiling is not enabled", - } - } if opts.Name == _EMPTY_ { return &ProfilezStatus{ Error: "Profile name not specified", From 40b8aa434b01385bf0f0a4a003184418e67b9c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Moyne?= Date: Sun, 13 Aug 2023 18:00:08 -0700 Subject: [PATCH 2/3] Remove part of the test that expects an error since now you can always get the profilez through the system account request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Noël Moyne --- server/monitor_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/server/monitor_test.go b/server/monitor_test.go index d9155dd4..89d347eb 100644 --- a/server/monitor_test.go +++ b/server/monitor_test.go @@ -4647,14 +4647,6 @@ func TestMonitorProfilez(t *testing.T) { s := RunServer(DefaultOptions()) defer s.Shutdown() - // First of all, check that the profiles aren't accessible - // when profiling hasn't been started in the usual way. - if ps := s.profilez(&ProfilezOptions{ - Name: "allocs", Debug: 0, - }); ps.Error == "" { - t.Fatal("Profile should not be accessible when profiling not started") - } - // Then start profiling. s.StartProfiler() From 61a05553365c49b5f29e6306af87e2dc238401ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Moyne?= Date: Mon, 14 Aug 2023 10:58:20 -0700 Subject: [PATCH 3/3] Call SetBlockProfileRate even it the profiling port is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Noël Moyne --- server/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/server.go b/server/server.go index c858974d..e1011bae 100644 --- a/server/server.go +++ b/server/server.go @@ -2093,6 +2093,9 @@ func (s *Server) Start() { // Pprof http endpoint for the profiler. if opts.ProfPort != 0 { s.StartProfiler() + } else { + // Enable blocking profile even if no port defined since profiling is always possible over $SYS requests + runtime.SetBlockProfileRate(1) } if opts.ConfigFile != _EMPTY_ {