antonlindstrom/pgstore

Data race issues are often found in `pgstore.(*PGStore).MaxAge()`

abekoh opened this issue · 0 comments

Data race issues are often found in pgstore.(*PGStore).MaxAge(), in our application when run with the -race flag.

==================
WARNING: DATA RACE
Write at 0x00c000bb0950 by goroutine 64:
  github.com/gorilla/securecookie.(*SecureCookie).MaxAge()
      /Users/kotaro_abe/pkg/mod/github.com/gorilla/securecookie@v1.1.2/securecookie.go:203 +0x51c
  github.com/antonlindstrom/pgstore.(*PGStore).MaxAge()
      /Users/kotaro_abe/pkg/mod/github.com/antonlindstrom/pgstore@v0.0.0-20170604072116-a407030ba6d0/pgstore.go:164 +0x52c
  github.com/antonlindstrom/pgstore.(*PGStore).New()
      /Users/kotaro_abe/pkg/mod/github.com/antonlindstrom/pgstore@v0.0.0-20170604072116-a407030ba6d0/pgstore.go:105 +0x428
  github.com/gorilla/sessions.(*Registry).Get()
      /Users/kotaro_abe/pkg/mod/github.com/gorilla/sessions@v1.2.2/sessions.go:139 +0xf8
  github.com/antonlindstrom/pgstore.(*PGStore).Get()
      /Users/kotaro_abe/pkg/mod/github.com/antonlindstrom/pgstore@v0.0.0-20170604072116-a407030ba6d0/pgstore.go:78 +0x4c
  main.NewEcho.Sessions.func5.1()
...

Previous read at 0x00c000bb0950 by goroutine 130:
  github.com/gorilla/securecookie.(*SecureCookie).Decode()
      /Users/kotaro_abe/pkg/mod/github.com/gorilla/securecookie@v1.1.2/securecookie.go:339 +0x32c
  github.com/gorilla/securecookie.DecodeMulti()
      /Users/kotaro_abe/pkg/mod/github.com/gorilla/securecookie@v1.1.2/securecookie.go:594 +0x11c
  github.com/antonlindstrom/pgstore.(*PGStore).New()
      /Users/kotaro_abe/pkg/mod/github.com/antonlindstrom/pgstore@v0.0.0-20170604072116-a407030ba6d0/pgstore.go:94 +0x374
  github.com/gorilla/sessions.(*Registry).Get()
      /Users/kotaro_abe/pkg/mod/github.com/gorilla/sessions@v1.2.2/sessions.go:139 +0xf8
  github.com/antonlindstrom/pgstore.(*PGStore).Get()
      /Users/kotaro_abe/pkg/mod/github.com/antonlindstrom/pgstore@v0.0.0-20170604072116-a407030ba6d0/pgstore.go:78 +0x4c
  main.NewEcho.Sessions.func5.1()
...

Goroutine 64 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/go/src/net/http/server.go:3285 +0x674
  github.com/labstack/echo/v4.(*Echo).Start()
      /Users/kotaro_abe/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:686 +0x11c
...

Goroutine 130 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/go/src/net/http/server.go:3285 +0x674
  github.com/labstack/echo/v4.(*Echo).Start()
      /Users/kotaro_abe/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:686 +0x11c
...