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

[docdb][ysql] Provide follower reads through YSQL #5232

Closed
bmatican opened this issue Jul 27, 2020 · 3 comments
Closed

[docdb][ysql] Provide follower reads through YSQL #5232

bmatican opened this issue Jul 27, 2020 · 3 comments
Assignees
Labels
area/docdb YugabyteDB core features area/ysql Yugabyte SQL (YSQL)

Comments

@bmatican
Copy link
Contributor

bmatican commented Jul 27, 2020

One option we were discussion, that might be cheap to do, would be to retrofit some isolation level, such as READ_COMMITTED to signal this.

@bmatican bmatican added area/ysql Yugabyte SQL (YSQL) area/docdb YugabyteDB core features labels Jul 27, 2020
@jameshartig
Copy link
Contributor

I also think it might be good to explore the use of connection string params like how azure does it: https://docs.microsoft.com/en-us/azure/azure-sql/database/read-scale-out

@RaidAndFade
Copy link

Just writing to note that this is something I am deeply interested in, hopefully it comes soon.

hectorgcr added a commit that referenced this issue Oct 10, 2020
Summary:
Currently we support consistent prefix reads (read from followers) for both YCQL
and YEDIS, but not for YSQL. This diff adds new session variable to specify if
read from followers should be enabled. The value for this variable is being sent as
part of the execution parameters.

When read from followers is enabled, this is translated to CONSISTENT_PREFIX
consistency level which is sent to the tablet RPC layer. In this layer, if
CONSISTENT_PREFIX consistency is specified, the closest replica that can serve
the read is selected regardless of whether or not it it's the leader for such tablet.

This diff also adds new metrics to count how the number of CONSISTENT_PREFIX
requests, and also the number of YSQL rows read as part of a consistent prefix
request.

Test Plan:
Set the `yb_read_from_followers`, execute a select statement and verify that in the rpc layer, the read has consistent_prefix consistency.
New unit tests

Also for the compatibility with isolation levels:
```ysqlsh (11.2-YB-2.3.3.0-b0)
Type "help" for help.

yugabyte=# SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SET
yugabyte=# SET yb_read_from_followers = true;
ERROR:  cannot enable yb_read_from_followers with the current transaction isolation mode
HINT:  Use READ UNCOMMITTED or READ COMMITTED to enable yb_read_from_followers.
yugabyte=# SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET
yugabyte=# SET yb_read_from_followers = true;
SET
yugabyte=# SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ;
ERROR:  cannot use this transaction isolation level with yb_read_from_followers enabled
HINT:  Disable yb_read_from_followers to use REPEATABLE READ or SERIALIZABLE.
```

Reviewers: bogdan, amitanand, mihnea, zyu

Reviewed By: mihnea, zyu

Subscribers: bogdan, zyu, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D9205
@m-iancu
Copy link
Contributor

m-iancu commented Oct 29, 2020

Fixed by 5ee5764.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features area/ysql Yugabyte SQL (YSQL)
Projects
None yet
Development

No branches or pull requests

5 participants