Skip to content

Commit

Permalink
Merge #137774
Browse files Browse the repository at this point in the history
137774: workload/schemachange: turn on exec logging for all statements r=rafiss a=rafiss

### workload: log full stack trace of error on failure

### workload/schemachange: make ErrorState implement Cause()

This will make the error formatting work more conventionally.

### workload/schemachange: turn on exec logging

This will help us see exactly which statements were executed by the
workload, including helper queries.

Epic: None
Release note: None

Co-authored-by: Rafi Shamim <[email protected]>
  • Loading branch information
craig[bot] and rafiss committed Dec 20, 2024
2 parents 951d890 + a8ccc45 commit 6eb6d49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/workload/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ func runRun(gen workload.Generator, urls []string, dbName string) error {
}
continue
}
// Log the error so we get the stack trace.
log.Errorf(ctx, "%v", err)
// Log the error with %+v so we get the stack trace.
log.Errorf(ctx, "workload run error: %+v", err)
return err

case <-ticker.C:
Expand Down
4 changes: 4 additions & 0 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,10 @@ func (es *ErrorState) Unwrap() error {
return es.cause
}

func (es *ErrorState) Cause() error {
return es.cause
}

func (es *ErrorState) Error() string {
return es.cause.Error()
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/workload/schemachange/schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,16 @@ func (s *schemaChange) Ops(
// setClusterSettings configures any settings required for the workload ahead
// of starting workers.
func (s *schemaChange) setClusterSettings(ctx context.Context, pool *workload.MultiConnPool) error {
_, err := pool.Get().Exec(ctx, `SET CLUSTER SETTING sql.defaults.super_regions.enabled = 'on'`)
return errors.WithStack(err)
for _, stmt := range []string{
`SET CLUSTER SETTING sql.defaults.super_regions.enabled = 'on'`,
`SET CLUSTER SETTING sql.log.all_statements.enabled = 'on'`,
} {
_, err := pool.Get().Exec(ctx, stmt)
if err != nil {
return errors.WithStack(err)
}
}
return nil
}

// initSeqName returns the smallest available sequence number to be
Expand Down

0 comments on commit 6eb6d49

Please sign in to comment.