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

Update Keyspace/Table name in prepared Query statement #1714

Merged
merged 2 commits into from
Jul 21, 2023

Conversation

sylwiaszunejko
Copy link
Contributor

@sylwiaszunejko sylwiaszunejko commented Jul 11, 2023

Previously gocql.TokenAwareHostPolicy always used keyspace explicitly specified in .Keyspace in ClusterConfig regardless of the keyspace in the Query. This would mean that the token awareness feature would not work properly if the user did not specify .Keyspace in ClusterConfig or did a query to a different keyspace.

This PR introduces transferring Keyspace and Table names to the Query from the PREPARED response and updating information about that every time this information is received. After this change, the token awareness feature can work properly without user having to specify a keyspace in ClusterConfig.

I created automated integration test ( keyspace_table_test.go) on 3 nodes cluster.

Fixes: #1621

@sylwiaszunejko sylwiaszunejko changed the title Update Keyspace/Table name in prepared Query statement. Update Keyspace/Table name in prepared Query statement Jul 12, 2023
@sylwiaszunejko sylwiaszunejko force-pushed the keyspace_table branch 2 times, most recently from 85d3da3 to f420b60 Compare July 14, 2023 08:30
@sylwiaszunejko sylwiaszunejko force-pushed the keyspace_table branch 2 times, most recently from a22ba29 to 9cda9c0 Compare July 14, 2023 14:03
keyspace_table_test.go Outdated Show resolved Hide resolved
@avelanarius
Copy link

cc @martin-sucha

Copy link
Contributor

@martin-sucha martin-sucha left a comment

Choose a reason for hiding this comment

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

Thank you for the pull request!

The change looks good to me in general, I added just one comment regarding error handling in the test.

Could you please also update the AUTHORS and CHANGELOG.md files as per CONTRIBUTING.md?

keyspace_table_test.go Outdated Show resolved Hide resolved
@sylwiaszunejko sylwiaszunejko force-pushed the keyspace_table branch 2 times, most recently from 9dfe898 to 9760902 Compare July 21, 2023 07:44
Previously TokenAwarePolicy always used Keyspace explicitly set in
cluster.Keyspace regardless of the keyspace in the Query. Now after
preparing statement Keyspace and Table names are transferred to the
Query and it can make use of that.

Fixes: apache#1621
Copy link
Contributor

@martin-sucha martin-sucha left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

@martin-sucha martin-sucha merged commit 3bd352e into apache:master Jul 21, 2023
sylwiaszunejko added a commit to sylwiaszunejko/scylla-bench that referenced this pull request Aug 9, 2023
Setting the keyspace explicitly was done to workaround
the following bug: apache/cassandra-gocql-driver#1621

After fixing this bug it is not necessary anymore.
(PR fixing it: apache/cassandra-gocql-driver#1714)
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.

Token aware host policy chooses primary replicas only
3 participants