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

Bug Report: select with where in on secondary vindex is not working #10301

Closed
L3o-pold opened this issue May 13, 2022 · 2 comments · Fixed by #10422
Closed

Bug Report: select with where in on secondary vindex is not working #10301

L3o-pold opened this issue May 13, 2022 · 2 comments · Fixed by #10422

Comments

@L3o-pold
Copy link
Collaborator

L3o-pold commented May 13, 2022

Overview of the Issue

Runing where in(...) query with no sharding key on a secondary vindex (consistent_lookup_unique) is throwing an error.

select `username` from `users`  where `id` in ("test2", "test")
vttablet: rpc error: code = InvalidArgument desc = missing bind var __vals (CallerID: userData1)

Reproduction Steps

  1. Deploy the following vschema:
{
   "sharded":true,
   "vindexes":{
      "unicode_loose_md5":{
         "type":"unicode_loose_md5"
      },
      "users_keyspace_id":{
         "type":"consistent_lookup_unique",
         "params":{
            "table":"commerce.users_keyspace_id",
            "from":"id",
            "to":"keyspace_id"
         },
         "owner":"users"
      }
   },
   "tables":{
      "users":{
         "column_vindexes":[
            {
               "column":"team_id",
               "name":"unicode_loose_md5"
            },
            {
               "column":"id",
               "name":"users_keyspace_id"
            }
         ]
      },
      "users_keyspace_id":{
         "column_vindexes":[
            {
               "column":"id",
               "name":"unicode_loose_md5"
            }
         ]
      }
   }
}
  1. Deploy the following schema
create table users(id char(36), team_id char(36), username varchar(50), primary key(id));
  1. Run the query
select `username` from `users`  where `id` in ("test2", "test")
  1. View error
vttablet: rpc error: code = InvalidArgument desc = missing bind var __vals (CallerID: userData1)

Explain

Route	IN	user		UNKNOWN	select username from users where id in ::__vals

Binary Version

Version: 14.0.0-SNAPSHOT (Git revision 209c5747c529b001ad71b5f9bed53f57c6f5fdeb branch 'main') built on Tue May  3 09:53:06 UTC 2022 by vitess@buildkitsandbox using go1.18.1 linux/amd64

Operating System and Environment details

Docker

Log Fragments

No response

@L3o-pold L3o-pold added Needs Triage This issue needs to be correctly labelled and triaged Type: Bug labels May 13, 2022
@shlomi-noach shlomi-noach added Component: Query Serving and removed Needs Triage This issue needs to be correctly labelled and triaged labels May 19, 2022
@aquarapid
Copy link
Contributor

Confirmed. I ran into this separately.

My repro is minimal:

schema:

CREATE TABLE t1 (
        c1 bigint unsigned NOT NULL,
        c2 varchar(16) NOT NULL,
        PRIMARY KEY (c1)
) ENGINE InnoDB;

CREATE TABLE lookup_t1 (
        c2 varchar(16) NOT NULL,
        keyspace_id varbinary(16) NOT NULL,
        PRIMARY KEY (c2)
) ENGINE InnoDB;

vschema:

{
  "sharded": true,
  "vindexes": {
    "lookup_idx": {
      "type": "lookup",
      "params": {
        "from": "c2",
        "to": "keyspace_id",
        "table": "lookup_t1"
      },
      "owner": "t1"
    },
    "xxhash": {
      "type": "xxhash"
    }
  },
  "tables": {
    "t1": {
      "columnVindexes": [
        {
          "column": "c1",
          "name": "xxhash"
        },
        {
          "column": "c2",
          "name": "lookup_idx"
        }
      ]
    },
    "lookup_t1": {
      "columnVindexes": [
        {
          "column": "c2",
          "name": "xxhash"
        }
      ]
    }
  }
}

Once the vschema is applied to a sharded (2 shards) keyspace, with table t1 still empty:

mysql> select * from t1;               
Empty set (0.00 sec)

mysql> select* from t1 where c2 = "abc";
Empty set (0.01 sec)

This is OK so far. However, if I pass values (whether one or many) via an IN clause that flows via the lookup:

mysql> select* from t1 where c2 in ("abc");
ERROR 1105 (HY000): target: sharded.80-.primary: vttablet: rpc error: code = InvalidArgument desc = missing bind var __vals (CallerID: user)

mysql> select* from t1 where c2 in ("abc", "def");
ERROR 1105 (HY000): target: sharded.-80.primary: vttablet: rpc error: code = InvalidArgument desc = missing bind var __vals (CallerID: user)

That seems bad.

@systay systay self-assigned this Jun 3, 2022
@systay
Copy link
Collaborator

systay commented Jun 3, 2022

I tried reproducing it locally but was not able to. created a PR to test it in CI: #10422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants