Skip to content

data race in pool.go #488

@kmanley

Description

@kmanley

Describe the bug
pool.go has a race condition around p.conns

WARNING: DATA RACE
Write at 0x00c00010e130 by goroutine 67:
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Pool).conn()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/pool.go:127 +0x7d1
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Pool).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/pool.go:183 +0x50
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Node).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/node.go:96 +0x151
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Cluster).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/cluster.go:92 +0x199
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Session).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/session.go:305 +0x1ba
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.Term.Run()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/query.go:356 +0x208
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.Term.RunWrite()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/query.go:369 +0x140

Previous read at 0x00c00010e130 by goroutine 122:
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Pool).conn()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/pool.go:122 +0x163
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Pool).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/pool.go:183 +0x50
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Node).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/node.go:96 +0x151
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Cluster).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/cluster.go:92 +0x199
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.(*Session).Query()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/session.go:305 +0x1ba
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.Term.Run()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/query.go:356 +0x208
  gopkg.in/rethinkdb/rethinkdb-go%2ev6.Term.RunWrite()
      /home/kevin/code/go/pkg/mod/gopkg.in/rethinkdb/[email protected]/query.go:369 +0x140

To Reproduce
Steps to reproduce the behavior:

  • I found this while running proprietary code that is highly concurrent. I don't have time to create a simpler test case to repro it, but looking at the code the problem is obvious. The mutex needs to be locked before the first read of p.conns

Expected behavior

  • No race

Screenshots
Applicable code
image

System info

  • Ubuntu 18.04.4 under WSL2/Windows 10
  • RethinkDB Version: 2.3.6.srh.1~0bionic

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    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