Skip to content

Commit

Permalink
roachtest/awsdms: fix race condition that can cause panics
Browse files Browse the repository at this point in the history
In cockroachdb#95518, we added a new test case to check for a table error
during the DMS process. However there is a race when the check
happens depending on how quickly tasks have ran and the task
ReplicationTaskStats can be nil and we tried to access field
on the nil object that was returned from the API call.

This commit checks that the ReplicationTaskStat is not nil
before accessing the TablesErrored property.

Fixes: cockroachdb#93305
Release note: None
  • Loading branch information
Jeremyyang920 committed Jan 26, 2023
1 parent 3b5bcf0 commit 3ef8fbb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/cmd/roachtest/tests/awsdms.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,11 @@ func checkDMSNoPKTableError(ctx context.Context, t test.Test, dmsCli *dms.Client
}
}
for _, task := range dmsTasks.ReplicationTasks {
if task.ReplicationTaskStats.TablesErrored == 1 {
t.L().Printf("table error was found")
return nil
if task.ReplicationTaskStats != nil {
if task.ReplicationTaskStats.TablesErrored == 1 {
t.L().Printf("table error was found")
return nil
}
}
}
return errors.New("no table error found yet")
Expand Down

0 comments on commit 3ef8fbb

Please sign in to comment.