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

[cassandra driver] Assign consistency level of BatchStatement to first BoundStatement #10

Open
wants to merge 1 commit into
base: 4.6.0-yb-x
Choose a base branch
from

Conversation

tedyu
Copy link

@tedyu tedyu commented Jul 26, 2021

In getQueryPlan(Session session, BatchStatement batch), the first BoundStatement is used to construct UpHostIterator.

If the consistency level of BatchStatement is set but that of the first BoundStatement is not set, we should assign consistency level of BatchStatement to first BoundStatement.

Thanks to Aravind for the observation.

Without this fix, ConsistencyLevel.YB_CONSISTENT_PREFIX would be used for the first BoundStatement (whose ConsistencyLevel is not set).

    private ConsistencyLevel getConsistencyLevel() {
      return statement.getConsistencyLevel() != null
          ? statement.getConsistencyLevel()
          : ConsistencyLevel.YB_CONSISTENT_PREFIX;

which would result in shuffling of the hosts, leaving leader not in the front:

      if (getConsistencyLevel() == ConsistencyLevel.YB_CONSISTENT_PREFIX) {
        Collections.shuffle(hosts);

@tedyu tedyu requested a review from nchandrappa July 26, 2021 16:16
Copy link

@aravind-nallan-yb aravind-nallan-yb left a comment

Choose a reason for hiding this comment

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

We should also decide what our defaults should be - string consistency and routing to leaders by default or weak consistency and route to followers.

Also what about tests? This is such a critical piece of our software and it doesn't seem to be tested properly.

@tedyu
Copy link
Author

tedyu commented Jul 26, 2021

Implication of changing defaults needs thorough review.
That should be done in another PR.

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.

2 participants