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

Do not choose less busy connection if query is LWT #208

Merged

Conversation

sylwiaszunejko
Copy link
Collaborator

There is a code in gocql that selects another connection to a node if chosen connection is too busy (has less than half available stream ids).

We should not do this with LWT.

@sylwiaszunejko
Copy link
Collaborator Author

I thought it might be better to have Pick(Token, ExecutableQuery) *Conn interface instead of Pick(Token, string, string, bool) *Conn but I had issues with rewriting scylla_test.go with that version so I decided to first go with the simpler solution and ask about second opinion.

@Lorak-mmk
Copy link

Out of all the LWT fixes this one is the least urgent, imo we can do it properly. What are the problems that you faced?

@sylwiaszunejko
Copy link
Collaborator Author

Out of all the LWT fixes this one is the least urgent, imo we can do it properly. What are the problems that you faced?

I just wasn't sure how to mock ExecutableQuery for the test purpose, but I guess I could just implement something like MockQuery and implement all of the methods as empty (returning nil, "", false etc.) to have .Keyspace(), .Table() and IsLWT() for the purpose of Pick (e.g. here: https://github.com/scylladb/gocql/blob/master/scylla_test.go#L27)

@Lorak-mmk
Copy link

One thing to consider; is type ConnPicker interface something that the user may implement?
Because this PR changes it's definition, so if it is exposed to the user (I'm not sure how that works in Go) then this is a breaking change

@dkropachev
Copy link
Collaborator

There is a code in gocql that selects another connection to a node if chosen connection is too busy (has less than half available stream ids).

We should not do this with LWT.

@sylwiaszunejko , why we should not do that with LTW queries ? is there core issue on that or something that have details on reasoning ?

@dkropachev
Copy link
Collaborator

There is a code in gocql that selects another connection to a node if chosen connection is too busy (has less than half available stream ids).
We should not do this with LWT.

@sylwiaszunejko , why we should not do that with LTW queries ? is there core issue on that or something that have details on reasoning ?

I think I found answer, please correct me if I am wrong, but related issues are:
https://github.com/scylladb/scylla-enterprise/issues/4369
#201

@dkropachev
Copy link
Collaborator

Out of all the LWT fixes this one is the least urgent, imo we can do it properly. What are the problems that you faced?

I just wasn't sure how to mock ExecutableQuery for the test purpose, but I guess I could just implement something like MockQuery and implement all of the methods as empty (returning nil, "", false etc.) to have .Keyspace(), .Table() and IsLWT() for the purpose of Pick (e.g. here: https://github.com/scylladb/gocql/blob/master/scylla_test.go#L27)

I guess that in most cases you can just pass nil

@dkropachev
Copy link
Collaborator

One thing to consider; is type ConnPicker interface something that the user may implement? Because this PR changes it's definition, so if it is exposed to the user (I'm not sure how that works in Go) then this is a breaking change

Greate idea, but it would be better to address it in separate PR since not only connpicker is currently not a publicly availalbe, but also we will have to somehow provide API that would suggest to use certain conn picker in certain conditions, or, maybe have one connpicker to handle all the cases.

@dkropachev dkropachev force-pushed the not_use_alternative_if_lwt branch 2 times, most recently from a76df35 to 14ad573 Compare July 6, 2024 03:14
@dkropachev
Copy link
Collaborator

@sylwiaszunejko, I made attempt to make Pick(Token, ExecutableQuery), please take a look.

@Lorak-mmk
Copy link

One thing to consider; is type ConnPicker interface something that the user may implement? Because this PR changes it's definition, so if it is exposed to the user (I'm not sure how that works in Go) then this is a breaking change

Greate idea, but it would be better to address it in separate PR since not only connpicker is currently not a publicly availalbe, but also we will have to somehow provide API that would suggest to use certain conn picker in certain conditions, or, maybe have one connpicker to handle all the cases.

I wasnt suggesting to make it publicly available. If it isn't - great, we don't have to worry about breaking changes.

scylla.go Show resolved Hide resolved
@sylwiaszunejko
Copy link
Collaborator Author

@dkropachev I used the code proposed by you just changed two lines to simplify

There is a code in gocql that selects another connection
to a node if chosen connection is too busy (has less than
half available stream ids).

We should not do this with LWT.
@sylwiaszunejko sylwiaszunejko merged commit fbccf92 into scylladb:master Jul 8, 2024
1 check passed
@wprzytula wprzytula self-assigned this Jul 11, 2024
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