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

Initial connection vs. reconnections #230

Closed
knadh opened this issue Aug 6, 2024 · 5 comments · Fixed by #231
Closed

Initial connection vs. reconnections #230

knadh opened this issue Aug 6, 2024 · 5 comments · Fixed by #231
Assignees

Comments

@knadh
Copy link

knadh commented Aug 6, 2024

Hi there.

gocql.NewSession() returns an error if the target cluster is unreachable for any reason. However, if it succeeds and there is a disconnection or unavailability at a later point, ReconnectInterval and ReconnectionPolicy attempts reconnections in the background gracefully.

In production, this means that if the target cluster is unavailable for any reason during an app's boot, it will fail to start outright (unless it builds its own retry/reconnect abstractions). Post successful boot, any disconnections can be handled gracefully thanks to the reconnect behaviour. Is there any way to get around the initialization being a stop-the-world bottleneck? Can it not hook into the existing reconnect behaviour?

Thank you.

@sylwiaszunejko
Copy link
Collaborator

Please specify gocql and scylla version, and please paste the error you are getting when the target cluster is unreachable.

@knadh
Copy link
Author

knadh commented Aug 7, 2024

github.com/scylladb/gocqlx/v3 v3.0.0
github.com/scylladb/gocql v.14.3
package main

import (
	"fmt"

	"github.com/gocql/gocql"
	"github.com/scylladb/gocqlx/v3"
)

func main() {
	cluster := gocql.NewCluster("127.0.0.1")

	session, err := gocqlx.WrapSession(cluster.CreateSession())
	if err != nil {
		panic(err)
	}

	fmt.Println(session)
}

Initialization fails with the following error if the cluster is unavailable with no recourse for re-connection. If the cluster fails after initialization, then re-connection attempts kick in and work gracefully.

gocql: unable to create session: unable to discover protocol version: dial tcp 127.0.0.1:9042: connect: connection refused

I just realised, I should've opened this issue on https://github.com/scylladb/gocql - My bad. @sylwiaszunejko, I can close this and re-open on the driver's repo.

@sylwiaszunejko sylwiaszunejko transferred this issue from scylladb/gocqlx Aug 7, 2024
@sylwiaszunejko
Copy link
Collaborator

I've transferred it to the right repo

@mykaul
Copy link

mykaul commented Aug 7, 2024

I've transferred it to the right repo

I wonder if it's not an issue we have in other drivers as well.

@dkropachev
Copy link
Collaborator

Reconnection policy is being introduced at #231, part regarging doing Session.Init later or in parallel is goign to be handled at #234

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

Successfully merging a pull request may close this issue.

4 participants