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

Create Session Discovers Other Hosts #181

Merged
merged 11 commits into from
Jun 17, 2014
Merged

Create Session Discovers Other Hosts #181

merged 11 commits into from
Jun 17, 2014

Conversation

benfrye
Copy link

@benfrye benfrye commented Jun 13, 2014

When using Auto-scaling groups, it would be nice if the connection could discover the cluster for round-robin connections, rather than having to specify. This Pull Requests, adds this discovery when requesting a new session.

@0x6e6562
Copy link
Contributor

Is it possible to make this discovery optional (i.e. The client should specify explicitly that they want this behavior).

Also, do you have an idea how you could test this?

@benfrye
Copy link
Author

benfrye commented Jun 13, 2014

Yea I was thinking about making it optional. Adding that functionality right now.

As far as testing, I'm not sure yet. Without mocking out a response, it seems it would take a lot of work. Currently, I just manually tested it with our stack.

@@ -60,6 +62,30 @@ func (cfg *ClusterConfig) CreateSession() (*Session, error) {
if pool.Size() > 0 {
s := NewSession(pool, *cfg)
s.SetConsistency(cfg.Consistency)

if cfg.DiscoverHosts == true {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this value is a bool, it does not need an equality expression.

@0x6e6562
Copy link
Contributor

Yes, I can appreciate that this can be a difficult thing to test, especially given the fact that you need at least two different IP addresses in a test cluster. And then this needs to run as part of the CI build.

So we're the gocql team is not a fanatical TDD outfit by any means, but we are looking to strike a balance between accepting valuable contributions and preventing potential regressions in the library. Basically I think that for cases that we can't tractably test, we'll need two maintainers to sign off on it.

Speaking of CI builds, have you found out why the Travis build failed?

@benfrye
Copy link
Author

benfrye commented Jun 13, 2014

I have not. Looking into this now.

@0x6e6562
Copy link
Contributor

FWIW #179 is also afflicted by the problem of not being easy to test, despite introducing a reasonable change - I've started a thread on the discussion list to help us deal with this kind of thing.

@phillipCouto
Copy link
Contributor

Sorry for being mia but I was following this and felt like I needed to voice an opinion. The whole purpose of the abstraction of connection pooling is to stop introducing functionality like this into the core.
My high level concept would be a pool that uses the host list as a seeding list to then discover the rest of the topology. If the abstraction is missing components to allow this to happen then make a request to improve the abstraction.
Also I had implemented the auto discovery with testing in the autodiscovery branch so it is possible and I will gladly provide assistance on how to implement the tests to consistently test the functionality.
Again just my 2 cents :)
On Fri, Jun 13, 2014 at 3:33 PM, Ben Hood notifications@github.com wrote:FWIW #179 is also afflicted by the problem of not being easy to test, despite introducing a reasonable change - I've started a thread on the discussion list to help us deal with this kind of thing.

—Reply to this email directly or view it on GitHub.

@0x6e6562
Copy link
Contributor

Well this is precisely the discussion I wanted to have. On it's own, this patch has merit, because it provides a simple approach to autodiscovery. But viewed in the context of the autodiscovery branch @phillipCouto has been working on, this patch comes across as just a point solution. That said, this patch is small and it is theoretically mergeable in its current state (modulo tests). The autodiscovery branch, OTOH, whilst being the more wholistic approach, appears to be some time off landing. So this leaves us in a dilemma - do we wait for the best solution or do we go for something that fills a need and is available now?

@nemosupremo
Copy link
Contributor

Is it the aim then that every developer write their auto discovery connection pool? What is meant by the core and what is non-core? This is something that every cassandra developer would most likely benefit from and I really don't see what is gained by keeping it separate. An "autodiscovery connection pool" doesn't seem like that would be something terribly useful outside of cassandra.

IMO, the driver should aim to match the datastax driver's features.

@phillipCouto
Copy link
Contributor

Well I was use the auto discovery branch as points of reference for things that were done in it. I wouldn't merge the branch and again not against this functionality , I am just looking at what is core functionality and what is an extension to the core functionality.
This to me in my opinion is an extension to the core and because the logic for adding hosts to the pool can differ between users not a good idea to bake into gocql. An example would be what if I want to restrict hosts in the pool be from a specific DC or rack. Or maybe a few from a secondary DC.
I would rather provide an api to allow users to be creative and have custom logic for what is considered application specific.
Hence the connection pool being abstracted, someone wants latency selection or maybe even query distribution or auto discovery of cluster typology.
These are all requests we've seen in the past and I was under the impression the reason for the abstraction :P
On Fri, Jun 13, 2014 at 7:04 PM, Ben Hood notifications@github.com wrote:Well this is precisely the discussion I wanted to have. On it's own, this patch has merit, because it provides a simple approach to autodiscovery. But viewed in the context of the autodiscovery branch @phillipCouto has been working on, this patch comes across as just a point solution. That said, this patch is small and it is theoretically mergeable in its current state (modulo tests). The autodiscovery branch, OTOH, whilst being the more wholistic approach, appears to be some time off landing. So this leaves us in a dilemma - do we wait for the best solution or do we go for something that fills a need and is available now?

—Reply to this email directly or view it on GitHub.

@phillipCouto
Copy link
Contributor

Exactly and auto discovery in datastax is not part of the core but in an auxiliary package that has other nice to haves that do not clutter the main package with all of the driver low level function.
Also upon discussion of this earlier I was under the impression that a separate gocql-contrib package or something similar would be developed to house these nice to have features.
On Fri, Jun 13, 2014 at 7:08 PM, Nimi Wariboko Jr. notifications@github.com wrote:Is it the aim then that every developer write their auto discovery connection pool? What is meant by the core and what is non-core? This is something that every cassandra developer would most likely benefit from and I really don't see what is gained by keeping it separate. An "autodiscovery connection pool" doesn't seem like that would be something terribly useful outside of cassandra.

IMO, the driver should aim to match the datastax driver's features.

—Reply to this email directly or view it on GitHub.

@nemosupremo
Copy link
Contributor

In the Java driver? The Java driver as hosted at https://github.com/datastax/java-driver/tree/2.0/driver-core supports discovery, dc-aware load balancing, token awareness and configurable retry policies out of the box. While all of it is optional the driver does come "batteries included" with sane defaults (round robin is most likely good enough for a large number of deployments).

You do have a point as they have made sure to logically separate the two layers so if you want to implement your own load balancing its possible - but I don't see why gocql shouldn't come batteries included. If most people are going to have 3 node deployments in the same datacenter the off-the-shelf driver should at least be aware of that.

@phillipCouto
Copy link
Contributor

Haha sorry my memory served me wrong. Like I said I'm not opposed to it
just questioning is cluster.go a proper home
On Jun 13, 2014 7:33 PM, "Nimi Wariboko Jr." notifications@github.com
wrote:

In the Java driver? The Java driver as hosted at
https://github.com/datastax/java-driver/tree/2.0/driver-core supports
discovery, dc-aware load balancing, token awareness and configurable retry
policies out of the box. While all of it is optional the driver does come
"batteries included" with sane defaults (round robin is most likely good
enough for a large number of deployments).

You do have a point as they have made sure to logically separate the two
layers so if you want to implement your own load balancing its possible -
but I don't see why gocql shouldn't come batteries included. If most people
are going to have 3 node deployments in the same datacenter the
off-the-shelf driver should at least be aware of that.


Reply to this email directly or view it on GitHub
#181 (comment).

@benfrye
Copy link
Author

benfrye commented Jun 16, 2014

Not going to have the time to write the test for this, as of now. Let me know though if you need help in this area to get this merged in. We'd really like this functionality.

@0x6e6562
Copy link
Contributor

@phillipCouto How do we move forwards on this? This patch is not as comprehensive as the auto-discovery change you are proposing, but IMHO it is in a mergeable state now and hence I would be tempted to merge it. Another down side is that there is no regression tests for this, but realistically speaking, this would be very hard to do even with the auto-discovery branch. So given these two observations, I would go ahead with the merge.

@benf-inova Unfortunately you've picked a change where the opinions are divided. I think your change is short and sweet and will probably work, but I do see Phillip's point of view, which is why I won't merge this unless we can reach an agreement. In addition, you would need to brush up a few things in the patch such as making the indentation consistent (not sure whether you ran go fmt), adding your name to the AUTHORs file and documenting this feature in the README.

Furthermore, you should be aware of the fact that the absence of a test can potentially mean that a change in this area could break your app down the line. Obviously we'll try our best to maintain stability, but regressions can occur.

@phillipCouto
Copy link
Contributor

What we can do is implement the change and then gauge the requests from the community. If it services our users and no request come in to enhance it then it can stay as is.

If not we will spark ideas from our users to better the implementation and hone it in.

As for the test I can work on writting a test to validate the functionality since I have some experience writting the test in the auto discovery branch.

@0x6e6562
Copy link
Contributor

OK @phillipCouto, so you're down with this change for now (assuming that @benf-inova does the necessary tidy up and gets the build to pass)?

@0x6e6562
Copy link
Contributor

@benf-inova I think the godoc for the DiscoverHosts flag needs improvement, i.e. something like:

If set, gocql will attempt to automatically discover other members of the Cassandra cluster (default: false)

@benfrye
Copy link
Author

benfrye commented Jun 16, 2014

Changes are in, and TravisCI passed last time it ran. I assume it hasn't run again because no code was changed in the more recent commits?

@phillipCouto
Copy link
Contributor

Yes I agree with the change with the cleans ups.
On Jun 16, 2014 2:19 PM, "Ben Hood" notifications@github.com wrote:

OK @phillipCouto https://github.com/phillipCouto, so you're down with
this change for now (assuming that @benf-inova
https://github.com/benf-inova does the necessary tidy up and gets the
build to pass)?


Reply to this email directly or view it on GitHub
#181 (comment).

@0x6e6562
Copy link
Contributor

OK, I'd like to merge this, but right now it won't merge automatically.

@phillipCouto
Copy link
Contributor

Looks like there is a merge conflict. Best thing would be for @benf-inova to merge the master back into his branch and resolve the conflict and commit the resolution.

Or he can scrap this request and make a new one with less commits involved.

@0x6e6562
Copy link
Contributor

Yes, that was my polite way of saying "If you want this merged, make it mergeable" :-)

@benfrye
Copy link
Author

benfrye commented Jun 17, 2014

Should be good now.

0x6e6562 added a commit that referenced this pull request Jun 17, 2014
Create Session Discovers Other Hosts
@0x6e6562 0x6e6562 merged commit f2deeb6 into apache:master Jun 17, 2014
@0x6e6562
Copy link
Contributor

Thank you very much for your contribution :-)

glutamatt pushed a commit to glutamatt/gocql that referenced this pull request Sep 9, 2024
fix(dealer): make net.Dialer not to bind to reuse ephimeral ports
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

Successfully merging this pull request may close these issues.

4 participants