vtexplain seems failing even with a simple VSchema json file

71 views
Skip to first unread message

Marche

unread,
Feb 11, 2020, 10:34:53 PM2/11/20
to vitess
Hi all,

I've been struggling to explain a query using a simple vschema.json file (in an unsharded database; the one provided as an example [./101_initial_cluster.sh]) but unfortunately, I always get an unknown field error like this: ERROR: initVtgateExecutor: unknown field "commerce" in vschema.Keyspace

Steps to reproduce it:

1. I get the VSchema from http://[myhost]:15001/debug/vschema and just copy/paste the result on a file:

{
 "routing_rules": {},
 "keyspaces": {
  "commerce": {
   "tables": {
    "corder": {
     "name": "corder"
    },
    "customer": {
     "name": "customer"
    },
    "dual": {
     "type": "reference",
     "name": "dual"
    },
    "product": {
     "name": "product"
    }
   }
  }
 }
}

2. After that I created a schema.sql file like this:

CREATE TABLE corder (
  order_id bigint(20) NOT NULL AUTO_INCREMENT,
  customer_id bigint(20) DEFAULT NULL,
  sku varbinary(128) DEFAULT NULL,
  price bigint(20) DEFAULT NULL,
  PRIMARY KEY (order_id)
);

CREATE TABLE customer (
  customer_id bigint(20) NOT NULL AUTO_INCREMENT,
  email varbinary(128) DEFAULT NULL,
  PRIMARY KEY (customer_id)
);

CREATE TABLE product (
  sku varbinary(128) NOT NULL,
  description varbinary(128) DEFAULT NULL,
  price bigint(20) DEFAULT NULL,
  PRIMARY KEY (sku)
);


3. And finally I just execute the following:

$ ./vtexplain -schema-file schema.sql -vschema-file vschema.json -sql "select * from customer"

ERROR: initVtgateExecutor: unknown field "commerce" in vschema.Keyspace

1. The commerce keyspace exists and it seems okay.
3. To create the cluster I just followed the example from https://vitess.io/docs/get-started/local/ (/101_initial_cluster.sh)

In addition, I also tried to to get the VSchema using vtctl like this: ./vtctl $TOPOLOGY GetVSchema commerce and the VSchema result is different (a little more simple), i.e:

{
  "tables": {
    "corder": {

    },
    "customer": {

    },
    "product": {

    }
  }
}

But, in any case I keep getting the same unknown field error:

ERROR: initVtgateExecutor: unknown field "order" in vschema.Keyspace
(the field name keeps changing on each execution) 

It's worth saying that I tried with a sharded database using the horizontal sharding example, I mean with a more complex vschema, but the result is the same. 

Did anyone else run into this error before? Why I'm obtaining different results getting vschema from http://{server}:15001/debug/vschema or getting it from vtctl?

Appreciate any help or guidance to understand what the issue is.

Thanks in advance.


Jacques Grove

unread,
Mar 4, 2020, 11:56:17 AM3/4/20
to vitess
(Resurrecting an old thread, just saw this for the first time)

vtexplain expects it's vSchema input in a slightly different format from what is presented on the /debug/vschema page.  For your example, this should work:

{
    "commerce": {
        "tables": {
            "corder": {},
            "customer": {},
            "product": {}
        }
    }
}

So, the "name" fields need to be removed;  the "dual" reference is unnecessary (added automatically), and you start the vSchema JSON with everything inside the "keyspaces" key from /debug/vschema.

Jacques
Reply all
Reply to author
Forward
0 new messages