vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.64k stars 2.1k forks source link

causal consistent read support from vitess replica #4718

Open inexplicable opened 5 years ago

inexplicable commented 5 years ago

Feature Description

Using obtained GTID to route queries to replica tablet type if and only if the replica has executed at least or beyond the given GTID, which provides a casual consistency guarantee and option to offload such reads from master.

For reference: https://proxysql.com/blog/proxysql-gtid-causal-reads

Use Case(s)

One of our actual use cases is that we have a binlog stream subscriber processing each row update event, and that is turned into a query to master to gather enough information for indexing purpose. The event we received or processed is associated with the GTID, and it needs to get just a snapshot that guarantees to be after the GTID in relation. One of the option we have is to use the https://dev.mysql.com/doc/refman/5.6/en/gtid-functions.html#function_wait-until-sql-thread-after-gtids but that's not quite ideal as it could have a blocking effect, and causing exhaustion of resources if all queries got stuck waiting for the GTID to be executed, we're looking for some option more async in nature.

Note that, the actual method of obtaining the GTID is not in scope of this:

  1. binlog subscription
  2. event token
  3. with mysql 5.7's https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_session_track_gtids Are all possible sources for the GTID, for this issue, we'd like to track just the routing/filtering side.
acharis commented 5 years ago

*causal

harshit-gangal commented 4 years ago

RFC is out #6843