Skip to content

add support for vtexplain to override the dbname target#4150

Merged
sougou merged 1 commit intovitessio:masterfrom
tinyspeck:vtexplain-set-dbname
Aug 24, 2018
Merged

add support for vtexplain to override the dbname target#4150
sougou merged 1 commit intovitessio:masterfrom
tinyspeck:vtexplain-set-dbname

Conversation

@demmer
Copy link
Copy Markdown
Member

@demmer demmer commented Aug 23, 2018

This change adds a --dbname option to the vtexplain binary so that
callers can simulate what vtgate will do when the application connects
with a specific database name.

Add a test to show how this can be used to bypass the v3 routing and
send queries directly to a shard.

As an example, I used the same queries as the "options" test in a new "target" test where the shard is forced to ks_sharded/-40:

--- data/test/vtexplain/multi-output/options-output.txt	2018-08-16 06:57:55.000000000 -0700
+++ data/test/vtexplain/multi-output/target-output.txt	2018-08-23 06:14:05.000000000 -0700
@@ -1,26 +1,18 @@
 ----------------------------------------------------------------------
 select * from user where email='null@void.com'

-1 ks_sharded/-40: select * from user where email = 'null@void.com' limit 10001
 1 ks_sharded/40-80: select * from user where email = 'null@void.com' limit 10001
-1 ks_sharded/80-c0: select * from user where email = 'null@void.com' limit 10001
-1 ks_sharded/c0-: select * from user where email = 'null@void.com' limit 10001

 ----------------------------------------------------------------------
 select * from user where id in (1,2,3,4,5,6,7,8)

-1 ks_sharded/-40: select * from user where id in (1, 2) limit 10001
-1 ks_sharded/40-80: select * from user where id in (3, 5) limit 10001
-1 ks_sharded/c0-: select * from user where id in (4, 6, 7, 8) limit 10001
+1 ks_sharded/40-80: select * from user where id in (1, 2, 3, 4, 5, 6, 7, 8) limit 10001

 ----------------------------------------------------------------------
 insert into user (id, name) values (2, 'bob')

-1 ks_sharded/c0-: begin
-1 ks_sharded/c0-: insert into name_user_map(name, user_id) values ('bob', 2) /* _stream name_user_map (name user_id ) ('Ym9i' 2 ); */ /* vtgate:: keyspace_id:da8a82595aa28154c17717955ffeed8b */
-2 ks_sharded/-40: begin
-2 ks_sharded/-40: insert into user(id, name) values (2, 'bob') /* _stream user (id ) (2 ); */ /* vtgate:: keyspace_id:06e7ea22ce92708f */
-3 ks_sharded/c0-: commit
-4 ks_sharded/-40: commit
+1 ks_sharded/40-80: begin
+1 ks_sharded/40-80: insert into user(id, name) values (2, 'bob')/* vtgate:: filtered_replication_unfriendly */
+2 ks_sharded/40-80: commit

 ----------------------------------------------------------------------

This change adds a --dbname option to the vtexplain binary so that
callers can simulate what vtgate will do when the application connects
with a specific database name.

Add a test to show how this can be used to bypass the v3 routing and
send queries directly to a shard.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
@demmer demmer requested a review from sougou August 23, 2018 13:15
@sougou sougou merged commit d9f7390 into vitessio:master Aug 24, 2018
@rafael rafael deleted the vtexplain-set-dbname branch August 25, 2018 00:28
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