Add debugging for mutex, tracing (#6522)

master
Harshavardhana 6 years ago committed by Nitish Tiwari
parent 20378821cf
commit 1111419d4a
  1. 6
      cmd/admin-handlers.go
  2. 3
      cmd/admin-router.go
  3. 4
      cmd/utils.go
  4. 2
      pkg/madmin/api.go
  5. 22
      pkg/madmin/profiling-commands.go

@ -286,9 +286,9 @@ type StartProfilingResult struct {
Error string `json:"error"` Error string `json:"error"`
} }
// StartProfilingHandler - POST /minio/admin/v1/profiling/start/{profiler} // StartProfilingHandler - POST /minio/admin/v1/profiling/start?profilerType={profilerType}
// ---------- // ----------
// Enable profiling information // Enable server profiling
func (a adminAPIHandlers) StartProfilingHandler(w http.ResponseWriter, r *http.Request) { func (a adminAPIHandlers) StartProfilingHandler(w http.ResponseWriter, r *http.Request) {
adminAPIErr := checkAdminRequestAuthType(r, "") adminAPIErr := checkAdminRequestAuthType(r, "")
if adminAPIErr != ErrNone { if adminAPIErr != ErrNone {
@ -297,7 +297,7 @@ func (a adminAPIHandlers) StartProfilingHandler(w http.ResponseWriter, r *http.R
} }
vars := mux.Vars(r) vars := mux.Vars(r)
profiler := vars["profiler"] profiler := vars["profilerType"]
startProfilingResult := make([]StartProfilingResult, len(globalAdminPeers)) startProfilingResult := make([]StartProfilingResult, len(globalAdminPeers))

@ -61,7 +61,8 @@ func registerAdminRouter(router *mux.Router) {
adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}/{prefix:.*}").HandlerFunc(httpTraceAll(adminAPI.HealHandler)) adminV1Router.Methods(http.MethodPost).Path("/heal/{bucket}/{prefix:.*}").HandlerFunc(httpTraceAll(adminAPI.HealHandler))
// Profiling operations // Profiling operations
adminV1Router.Methods(http.MethodPost).Path("/profiling/start/{profiler}").HandlerFunc(httpTraceAll(adminAPI.StartProfilingHandler)) adminV1Router.Methods(http.MethodPost).Path("/profiling/start").HandlerFunc(httpTraceAll(adminAPI.StartProfilingHandler)).
Queries("profilerType", "{profilerType:.*}")
adminV1Router.Methods(http.MethodGet).Path("/profiling/download").HandlerFunc(httpTraceAll(adminAPI.DownloadProfilingHandler)) adminV1Router.Methods(http.MethodGet).Path("/profiling/download").HandlerFunc(httpTraceAll(adminAPI.DownloadProfilingHandler))
/// Config operations /// Config operations

@ -226,6 +226,10 @@ func startProfiler(profilerType, dirPath string) (interface {
profiler = profile.Start(profile.MemProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath)) profiler = profile.Start(profile.MemProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
case "block": case "block":
profiler = profile.Start(profile.BlockProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath)) profiler = profile.Start(profile.BlockProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
case "mutex":
profiler = profile.Start(profile.MutexProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
case "trace":
profiler = profile.Start(profile.TraceProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
default: default:
return nil, errors.New("profiler type unknown") return nil, errors.New("profiler type unknown")
} }

@ -176,7 +176,7 @@ func (c *AdminClient) TraceOff() {
type requestData struct { type requestData struct {
customHeaders http.Header customHeaders http.Header
queryValues url.Values queryValues url.Values
relPath string // Url path relative to admin API base endpoint relPath string // URL path relative to admin API base endpoint
content []byte content []byte
} }

@ -24,20 +24,20 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url"
) )
// ProfilerType represents the profiler type // ProfilerType represents the profiler type
// passed to the profiler subsystem, currently // passed to the profiler subsystem.
// it can be only "cpu", "mem" or "block"
type ProfilerType string type ProfilerType string
// Different supported profiler types.
const ( const (
// ProfilerCPU represents CPU profiler type ProfilerCPU ProfilerType = "cpu" // represents CPU profiler type
ProfilerCPU = ProfilerType("cpu") ProfilerMEM = "mem" // represents MEM profiler type
// ProfilerMEM represents MEM profiler type ProfilerBlock = "block" // represents Block profiler type
ProfilerMEM = ProfilerType("mem") ProfilerMutex = "mutex" // represents Mutex profiler type
// ProfilerBlock represents Block profiler type ProfilerTrace = "trace" // represents Trace profiler type
ProfilerBlock = ProfilerType("block")
) )
// StartProfilingResult holds the result of starting // StartProfilingResult holds the result of starting
@ -51,9 +51,11 @@ type StartProfilingResult struct {
// StartProfiling makes an admin call to remotely start profiling on a standalone // StartProfiling makes an admin call to remotely start profiling on a standalone
// server or the whole cluster in case of a distributed setup. // server or the whole cluster in case of a distributed setup.
func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingResult, error) { func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingResult, error) {
path := fmt.Sprintf("/v1/profiling/start/%s", profiler) v := url.Values{}
v.Set("profilerType", string(profiler))
resp, err := adm.executeMethod("POST", requestData{ resp, err := adm.executeMethod("POST", requestData{
relPath: path, relPath: "/v1/profiling/start",
queryValues: v,
}) })
defer closeResponse(resp) defer closeResponse(resp)
if err != nil { if err != nil {

Loading…
Cancel
Save