Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
68359: server: initialize trace dumper conditionally r=pbardea a=adityamaru

This change ensures that a trace dumper is initialized only
if the corresponding trace dump directory was configured when
setting up logging, during node start.

Fixes: cockroachdb#68356

Release note: None

Co-authored-by: Aditya Maru <adityamaru@gmail.com>
  • Loading branch information
craig[bot] and adityamaru committed Aug 4, 2021
2 parents eef03a4 + 8747efd commit 875b969
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,8 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
if cfg.TestingKnobs.JobsTestingKnobs != nil {
jobsKnobs = cfg.TestingKnobs.JobsTestingKnobs.(*jobs.TestingKnobs)
}
td, err := tracedumper.NewTraceDumper(ctx, cfg.InflightTraceDirName, cfg.Settings)
if err != nil {
log.Errorf(ctx, "failed to initialize trace dumper: %+v", err)
}

td := tracedumper.NewTraceDumper(ctx, cfg.InflightTraceDirName, cfg.Settings)
*jobRegistry = *jobs.MakeRegistry(
cfg.AmbientCtx,
cfg.stopper,
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func makeTestConfigFromParams(params base.TestServerArgs) Config {
if cfg.GoroutineDumpDirName == "" {
cfg.GoroutineDumpDirName = filepath.Join(storeSpec.Path, "logs", base.GoroutineDumpDir)
}
if cfg.InflightTraceDirName == "" {
cfg.InflightTraceDirName = filepath.Join(storeSpec.Path, "logs", base.InflightTraceDir)
}
}
}
cfg.Stores = base.StoreSpecList{Specs: params.StoreSpecs}
Expand Down
6 changes: 3 additions & 3 deletions pkg/server/tracedumper/tracedumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func (t *TraceDumper) Dump(
// NewTraceDumper returns a TraceDumper.
//
// dir is the directory in which dumps are stored.
func NewTraceDumper(ctx context.Context, dir string, st *cluster.Settings) (*TraceDumper, error) {
func NewTraceDumper(ctx context.Context, dir string, st *cluster.Settings) *TraceDumper {
if dir == "" {
return nil, errors.New("directory to store dumps could not be determined")
return nil
}

log.Infof(ctx, "writing job trace dumps to %s", dir)
Expand All @@ -122,5 +122,5 @@ func NewTraceDumper(ctx context.Context, dir string, st *cluster.Settings) (*Tra
currentTime: timeutil.Now,
store: dumpstore.NewStore(dir, totalDumpSizeLimit, st),
}
return td, nil
return td
}

0 comments on commit 875b969

Please sign in to comment.