apache / cassandra-gocql-driver

GoCQL Driver for Apache Cassandra®
https://cassandra.apache.org/
Apache License 2.0
2.57k stars 616 forks source link

Panic in after adding a few columns to table #1460

Open erikbos opened 4 years ago

erikbos commented 4 years ago

What version of Cassandra are you using?

Azure CosmosDB using Cassandra API

What version of Gocql are you using?

v0.0.0-20200615160627-420e3b873d91

What did you do?

Go app runs SELECT * from table in continuous loop and prints values of a handful known columns of each row in the resultset.

While go app is running:

Restart go app, it will now panic in gocql after a few seconds.

What did you expect to see?

I did not expect my Go app to crash by calling MapScan().

What did you see instead?

panic: not enough bytes in buffer to read int require 4 got: 0

goroutine 1 [running]: github.com/gocql/gocql.(framer).readInt(0xc0001fc580, 0xe) /Users/erik/go/pkg/mod/github.com/gocql/gocql@v0.0.0-20200615160627-420e3b873d91/frame.go:1778 +0x132 github.com/gocql/gocql.(framer).readBytesInternal(0xc0001fc580, 0xc0001e0e00, 0x10516c6, 0x10645a0, 0xc0001c18c8, 0x0) /Users/erik/go/pkg/mod/github.com/gocql/gocql@v0.0.0-20200615160627-420e3b873d91/frame.go:1852 +0x2f github.com/gocql/gocql.(Iter).readColumn(...) /Users/erik/go/pkg/mod/github.com/gocql/gocql@v0.0.0-20200615160627-420e3b873d91/session.go:1401 github.com/gocql/gocql.(Iter).Scan(0xc0001d8b40, 0xc0001e0ee0, 0xe, 0xe, 0x15545c0) /Users/erik/go/pkg/mod/github.com/gocql/gocql@v0.0.0-20200615160627-420e3b873d91/session.go:1440 +0x227 github.com/gocql/gocql.(*Iter).MapScan(0xc0001d8b40, 0xc0002a0480, 0xc0001c1cc0) /Users/erik/go/pkg/mod/github.com/gocql/gocql@v0.0.0-20200615160627-420e3b873d91/helpers.go:417 +0x16c main.main() /Users/erik/go/src/cosmosdbtest2/cosmosdb_gocql_column_order_issue.go:46 +0x514 exit status 2

The weird thing is such crash happens after I restart the golang app. It feels a bit like the symptoms in https://github.com/gocql/gocql/issues/1056, metadata issues resulting in column ordering issues?

When I change "SELECT *" to select from specifically named columns the app does not panic in gocql anymore..

martin-sucha commented 2 years ago

Yeah, could be some metadata related issue. It seems that there are fewer columns in the response than in the metadata? But the metadata is part of the result from server. It would help to see how the responses from the server looked like to determine if this is an issue in the client or the server. Contents of iter.meta.columns would be helpful too.

In any case, the driver definitely should not panic (regardless of whether the issue with columns is client- or server-side).