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

   Please remove the global function NewBatch. It has been marked as deprecated 
since commit 3688d5fd. Using NewBatch can cause crashes and is not covered by 
existing tests. Removal would break some existing apps, but a compile-time 
failure is better than a runtime crash.
   
   NewBatch was first deprecated with this commit on Dec 30, 2017:
   
https://github.com/gocql/gocql/commit/3688d5fd49d899f49773e1e5c7250d4cf3486d54
   
   Related issue : #1065 Remove NewBatch function, marked for next major 
version. I think this refers also to Session.NewBatch.
   
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### What version of Cassandra are you using?
   3.11.6
   
   ### What version of Gocql are you using?
   Commit 6d895e38b0a53cd804a3a2f547c9d9c0666aef35, Mar 24, 2020
   
   ### What did you do?
   Called the NewBatch function and used TokenAwareHostPolicy.
   
   ### What did you expect to see?
   Works.
   
   ### What did you see instead?
   Crashes, because TokenAwareHostPolicy calls Batch.GetRoutingKey, which calls 
Session.routingKeyInfo, but the session pointer in the Batch struct is nil.
   
   ```
   panic: runtime error: invalid memory address or nil pointer dereference
   [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x8df228]
   goroutine 5059 [running]:
   foo/github.com/gocql/gocql.(*Session).routingKeyInfo(0x0, 0x1cc6d00, 
0xc007c76090, 0x1acb4ed, 0x84, 0x0, 0x0, 0x0)
           /go/src/foo/github.com/gocql/gocql/session.go:495 +0x68
   foo/github.com/gocql/gocql.(*Batch).GetRoutingKey(0xc000d50620, 0x20, 
0xc001bbdd70, 0x8db023, 0xc0001f8540, 0x1cdb460)
           /go/src/foo/github.com/gocql/gocql/session.go:1774 +0xcf
   foo/github.com/gocql/gocql.(*tokenAwareHostPolicy).Pick(0xc0001f8540, 
0x1cdb3e0, 0xc000d50620, 0x1cc6d00)
           /go/src/foo/github.com/gocql/gocql/policies.go:575 +0x52
   foo/github.com/gocql/gocql.(*queryExecutor).do(0xc00000eae0, 0x1cc6d00, 
0xc007c76090, 0x1cdb3e0, 0xc000d50620, 0xc00027c2d8)
           /go/src/foo/github.com/gocql/gocql/query_executor.go:87 +0x63
   foo/github.com/gocql/gocql.(*queryExecutor).executeQuery(0xc00000eae0, 
0x1cdb3e0, 0xc000d50620, 0x0, 0x0, 0x0)
           /go/src/foo/github.com/gocql/gocql/query_executor.go:60 +0x42e
   foo/github.com/gocql/gocql.(*Session).executeBatch(0xc00020e000, 
0xc000d50620, 0x1cd67a0)
           /go/src/foo/github.com/gocql/gocql/session.go:642 +0xc5
   foo/github.com/gocql/gocql.(*Session).ExecuteBatch(0xc00020e000, 
0xc000d50620, 0xc004e4c590, 0x1b01fa0)
           /go/src/foo/github.com/gocql/gocql/session.go:653 +0x39
   ```
   
   ---
   
   If you are having connectivity related issues please share the following 
additional information
   
   ### Describe your Cassandra cluster
   please provide the following information
   
   - output of `nodetool status`
   - output of `SELECT peer, rpc_address FROM system.peers`
   - rebuild your application with the `gocql_debug` tag and post the output


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to