ncabatoff opened a new issue, #1473:
URL: https://github.com/apache/cassandra-gocql-driver/issues/1473

   Please answer these questions before submitting your issue. Thanks!
   
   ### What version of Cassandra are you using?
   
   Docker image cassandra:3.11.
   
   ### What version of Gocql are you using?
   
   ```
   $ grep gocql go.mod
           github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e
   ```
   
   ### What did you do?
   
   ```
        sess, err := cluster.CreateSession()
        if err != nil {
                return nil, err
        }
        sess.SetConsistency(consistency)
   ```
   
   Elsewhere:
   ```
           sess.Query(...)
   ```
   
   ### What did you expect to see?
   
   No data race when running with `-race`.
   
   ### What did you see instead?
   
   ```
   === FAIL: physical/cassandra TestCassandraBackend (25.07s)
   ==================
   WARNING: DATA RACE
   Read at 0x00c0001d8380 by goroutine 25:
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*Conn).UseKeyspace()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/conn.go:1235 
+0x186
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*hostConnPool).connect()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/connectionpool.go:534
 +0x53d
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*hostConnPool).connectMany.func1()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/connectionpool.go:487
 +0x79
   
   Previous write at 0x00c0001d8380 by goroutine 7:
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*Session).SetConsistency()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/session.go:336 
+0x54
     github.com/hashicorp/vault/physical/cassandra.NewCassandraBackend()
         /go/src/github.com/hashicorp/vault/physical/cassandra/cassandra.go:144 
+0x917
     github.com/hashicorp/vault/physical/cassandra.TestCassandraBackend()
         
/go/src/github.com/hashicorp/vault/physical/cassandra/cassandra_test.go:29 
+0x2dc
     testing.tRunner()
         /usr/local/go/src/testing/testing.go:1039 +0x1eb
   
   Goroutine 25 (running) created at:
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*hostConnPool).connectMany()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/connectionpool.go:485
 +0x159
     
github.com/hashicorp/vault/vendor/github.com/gocql/gocql.(*hostConnPool).fill.func1()
         
/go/src/github.com/hashicorp/vault/vendor/github.com/gocql/gocql/connectionpool.go:439
 +0x42
   
   Goroutine 7 (running) created at:
     testing.(*T).Run()
         /usr/local/go/src/testing/testing.go:1090 +0x700
     testing.runTests.func1()
         /usr/local/go/src/testing/testing.go:1334 +0xa6
     testing.tRunner()
         /usr/local/go/src/testing/testing.go:1039 +0x1eb
     testing.runTests()
         /usr/local/go/src/testing/testing.go:1332 +0x527
     testing.(*M).Run()
         /usr/local/go/src/testing/testing.go:1249 +0x43f
     main.main()
         _testmain.go:46 +0x223
   ```
   
   ---
   
   To reproduce, clone `github.com/hashicorp/vault`, then:
   
   ```
   go test -race ./physical/cassandra
   ```
   
   The issue looks to be that although `Session.SetConsistency` uses a lock to 
protect writes to `s.cons`, `Conn.UseKeyscape` reads `c.session.cons` without 
any mechanism to manage thread safety.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to