Thanks to visit codestin.com
Credit goes to github.com

Skip to content

flake: data race in sql or pq: runtime.slicecopy() #731

Open
@johnstcn

Description

@johnstcn

Seen here: https://github.com/coder/coder/actions/runs/15744308298/job/44377135862?pr=18425

=== FAIL: coderd/prometheusmetrics TestActiveUsers/One (0.15s)
==================
WARNING: DATA RACE
Write at 0x00c00120ef38 by goroutine 2215:
  runtime.slicecopy()
      /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/slice.go:355 +0x0
  bufio.(*Reader).Read()
      /opt/hostedtoolcache/go/1.24.4/x64/src/bufio/bufio.go:258 +0x[689](https://github.com/coder/coder/actions/runs/15744308298/job/44377135862?pr=18425#step:8:690)
  io.ReadAtLeast()
      /opt/hostedtoolcache/go/1.24.4/x64/src/io/io.go:335 +0xca
  io.ReadFull()
      /opt/hostedtoolcache/go/1.24.4/x64/src/io/io.go:354 +0x356
  github.com/lib/pq.(*conn).recvMessage()
      /home/runner/go/pkg/mod/github.com/coder/[email protected]/conn.go:1032 +0x2f2
  github.com/lib/pq.(*conn).recv1Buf()
      /home/runner/go/pkg/mod/github.com/coder/[email protected]/conn.go:1073 +0x34
  github.com/lib/pq.(*rows).Next()
      /home/runner/go/pkg/mod/github.com/coder/[email protected]/conn.go:1587 +0x25b
  github.com/lib/pq.(*rows).Close()
      /home/runner/go/pkg/mod/github.com/coder/[email protected]/conn.go:1544 +0xac
  database/sql.(*Rows).close.func1()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:3458 +0x50
  database/sql.withLock()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:3574 +0xa6
  database/sql.(*Rows).close()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:3457 +0x27c
  database/sql.(*Rows).awaitDone()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:3020 +0x2b8
  database/sql.(*Rows).initContextClose.gowrap1()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:2996 +0x8f

Previous read at 0x00c00120ef3c by goroutine 2187:
  runtime.slicecopy()
      /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/slice.go:355 +0x0
  bytes.Clone()
      /opt/hostedtoolcache/go/1.24.4/x64/src/bytes/bytes.go:1412 +0xfbc
  database/sql.convertAssignRows()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/convert.go:272 +0xfbd
  database/sql.(*Rows).Scan()
      /opt/hostedtoolcache/go/1.24.4/x64/src/database/sql/sql.go:3400 +0x727
  github.com/coder/coder/v2/coderd/database.(*sqlQuerier).GetAPIKeysLastUsedAfter()
      /home/runner/work/coder/coder/coderd/database/queries.sql.go:315 +0x667
  github.com/coder/coder/v2/coderd/database.(*sqlQuerier).GetAPIKeysLastUsedAfter()
      /home/runner/work/coder/coder/coderd/database/queries.sql.go:307 +0x154
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae
  github.com/coder/coder/v2/coderd/prometheusmetrics.ActiveUsers.func1()
      /home/runner/work/coder/coder/coderd/prometheusmetrics/prometheusmetrics.go:61 +0x2ae

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions