Skip to content

sql: fix newly introduced race#90962

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
ajwerner:ajwerner/fix-race
Oct 31, 2022
Merged

sql: fix newly introduced race#90962
craig[bot] merged 1 commit intocockroachdb:masterfrom
ajwerner:ajwerner/fix-race

Conversation

@ajwerner
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner commented Oct 31, 2022

All of the goroutines were writing to the same err variable. This race was introduced in #89540.

Epic: None

Release note: None

All of the goroutines were writing to the same `err` variable. This race was
introduced in cockroachdb#89540.

Release note: None
@ajwerner ajwerner requested review from a team and fqazi October 31, 2022 02:23
@ajwerner
Copy link
Copy Markdown
Contributor Author

==================
WARNING: DATA RACE
Write at 0x00c00b2561d0 by goroutine 567027:
  github.com/cockroachdb/cockroach/pkg/sql.ValidateInvertedIndexes.func3()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1700 +0x484
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx.func1()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:168 +0x4c
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:74 +0x86
Previous write at 0x00c00b2561d0 by goroutine 567025:
  github.com/cockroachdb/cockroach/pkg/sql.ValidateInvertedIndexes.func3()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1700 +0x484
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx.func1()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:168 +0x4c
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:74 +0x86
Goroutine 567027 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:71 +0x12e
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:167 +0x109
  github.com/cockroachdb/cockroach/pkg/sql.ValidateInvertedIndexes()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1691 +0xd04
  github.com/cockroachdb/cockroach/pkg/sql.(*SchemaChanger).validateIndexes.func3()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1498 +0x37c
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx.func1()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:168 +0x4c
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:74 +0x86
Goroutine 567025 (finished) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:71 +0x12e
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:167 +0x109
  github.com/cockroachdb/cockroach/pkg/sql.ValidateInvertedIndexes()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1691 +0xd04
  github.com/cockroachdb/cockroach/pkg/sql.(*SchemaChanger).validateIndexes.func3()
      github.com/cockroachdb/cockroach/pkg/sql/backfill.go:1498 +0x37c
  github.com/cockroachdb/cockroach/pkg/util/ctxgroup.Group.GoCtx.func1()
      github.com/cockroachdb/cockroach/pkg/util/ctxgroup/ctxgroup.go:168 +0x4c
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync/errgroup/external/org_golang_x_sync/errgroup/errgroup.go:74 +0x86
==================

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@ajwerner
Copy link
Copy Markdown
Contributor Author

The flake here is #90965.

@postamar
Copy link
Copy Markdown

Wow that's such an easy bug to write.

@ajwerner
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 31, 2022

Build succeeded:

@craig craig bot merged commit c476f0d into cockroachdb:master Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants