Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session.Closed returns false when cassandra went down or stopped after client made a successful session. #1601

Open
amanjain08 opened this issue Feb 28, 2022 · 3 comments

Comments

@amanjain08
Copy link

amanjain08 commented Feb 28, 2022

What version of Cassandra are you using?

3.11.3

What version of Gocql are you using?

v0.0.0-20200221113847-372a19b1a852

What version of Go are you using?

1.14

What did you do?

I tried getting the metadata of keyspace to check the table existence while gocql client is connected to cassandra. After I stopped the cassandra, gocql wasn't throwing any error and returning cached metadata to check the table existence.
Also, when I checked session.Closed it returns false when cassandra wasn't running.

What did you expect to see?

Error should have been thrown.
session.Closed should have returned true, when cassandra went down or stopped after client made a successful session.

What did you see instead?

session.Closed it returns false when cassandra wasn't running.

@martin-sucha
Copy link
Contributor

Session.Closed() returns true only after you call Session.Close(). That is a feature, not a bug.
When the Cassandra server is not reachable, the session is still open and will reconnect automatically once the Cassandra server becomes available. We should update the documentation to describe what Close() does.

Individual queries or batches that you execute will return errors. If you want to check if the Cassandra cluster is available, you could execute a regular query.

The driver caches keyspace metadata because it would be expensive to load it on every query. Why is it a problem for you if the driver returns cached keyspace metadata?

v0.0.0-20200221113847-372a19b1a852

This version is two years old. Please use the latest version of the driver.

@amanjain08
Copy link
Author

we are using gocql in a central health manager where other apps will call central health manager to check for the cassandra connectivity and the existence of tables those are required by the apps. So, if we get the cache data then there is a chance that app might start and cassandra is not running. Kind of hard dependency on cassandra.

So, now we are executing a query with limit 1 that is returning error whenever cassandra is not connected and fulfilling the purpose.

Reason behind using older version of gocql is that we are using old version of go 1.14

@tengu-alt
Copy link
Contributor

We should update the documentation to describe what Close() does.

I'll Handle this. Also, I am currently working on doc update which covers undocumented user API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants