Skip to content

Commit

Permalink
workload/tpcc: fix race condition in scattering tables
Browse files Browse the repository at this point in the history
When iterating over the names of tables to scatter, we were sharing the
loop variable between the goroutines, which is racy and caused a test
failure due to reading a garbage string value for the table name. In
general, this function is not going to scatter each table exactly once.
This PR fixes it by making a copy of the variable per loop iteration.

Release note (bug fix): Fixed a race condition in the `tpcc` workload
with the `--scatter` flag where tables could be scattered multiple times
or not at all.
  • Loading branch information
thoszhang committed Nov 20, 2020
1 parent c4032c2 commit e303535
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/workload/tpcc/ddls.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func scatterRanges(db *gosql.DB) error {

var g errgroup.Group
for _, table := range tables {
table := table
g.Go(func() error {
sql := fmt.Sprintf(`ALTER TABLE %s SCATTER`, table)
if _, err := db.Exec(sql); err != nil {
Expand Down

0 comments on commit e303535

Please sign in to comment.