maddyblue/esc

Data race on _escFile.name

zikaeroh opened this issue · 0 comments

I hit this data race in my CI:

==================
WARNING: DATA RACE
Read at 0x00c0000d2a68 by goroutine 7:
  github.com/hortbot/hortbot/internal/db/migrations/esc.(*_escFile).Name()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/esc/esc.go:130 +0x3e
  github.com/golang-migrate/migrate/v4/source/httpfs.(*PartialDriver).Init()
      /home/travis/gopath/pkg/mod/github.com/golang-migrate/migrate/v4@v4.8.0/source/httpfs/partial_driver.go:48 +0x34c
  github.com/golang-migrate/migrate/v4/source/httpfs.New()
      /home/travis/gopath/pkg/mod/github.com/golang-migrate/migrate/v4@v4.8.0/source/httpfs/driver.go:21 +0xaf
  github.com/hortbot/hortbot/internal/db/migrations.newMigrate()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/migrations.go:51 +0x77
  github.com/hortbot/hortbot/internal/db/migrations.Up()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/migrations.go:15 +0x8d
  github.com/hortbot/hortbot/internal/db/migrations_test.withDatabase()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/migrations_test.go:67 +0x11e
  github.com/hortbot/hortbot/internal/db/migrations_test.TestUp()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/migrations_test.go:33 +0x52
  testing.tRunner()
      /home/travis/.gimme/versions/go/src/testing/testing.go:993 +0x1eb

Previous write at 0x00c0000d2a68 by goroutine 77:
  github.com/hortbot/hortbot/internal/db/migrations/esc._escStaticFS.prepare.func1()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/esc/esc.go:59 +0xad
  sync.(*Once).doSlow()
      /home/travis/.gimme/versions/go/src/sync/once.go:66 +0x103
  sync.(*Once).Do()
      /home/travis/.gimme/versions/go/src/sync/once.go:57 +0x68
  github.com/hortbot/hortbot/internal/db/migrations/esc._escStaticFS.prepare()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/esc/esc.go:58 +0x160
  github.com/hortbot/hortbot/internal/db/migrations/esc._escStaticFS.Open()
      /home/travis/gopath/src/github.com/hortbot/hortbot/internal/db/migrations/esc/esc.go:78 +0x46
  github.com/hortbot/hortbot/internal/db/migrations/esc.(*_escStaticFS).Open()
      <autogenerated>:1 +0x5f
  github.com/golang-migrate/migrate/v4/source/httpfs.(*PartialDriver).ReadUp()
      /home/travis/gopath/pkg/mod/github.com/golang-migrate/migrate/v4@v4.8.0/source/httpfs/partial_driver.go:111 +0x1b9
  github.com/golang-migrate/migrate/v4/source/httpfs.(*driver).ReadUp()
      <autogenerated>:1 +0x5b
  github.com/golang-migrate/migrate/v4.(*Migrate).newMigration()
      /home/travis/gopath/pkg/mod/github.com/golang-migrate/migrate/v4@v4.8.0/migrate.go:837 +0x96
  github.com/golang-migrate/migrate/v4.(*Migrate).readUp()
      /home/travis/gopath/pkg/mod/github.com/golang-migrate/migrate/v4@v4.8.0/migrate.go:612 +0x22b

It appears as though there's a path where the static file is being returned before it has been prepared, but I can't see how at first glance.