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

Error 1105 instead of 1062 when inserting duplicate into consistent_lookup vindex #6144

Closed
aquarapid opened this issue May 1, 2020 · 0 comments · Fixed by #6145
Closed
Milestone

Comments

@aquarapid
Copy link
Contributor

Scenario:

  • Two tablespaces; one unsharded with a sequence; one sharded, with a lookup vindex and an owned table that has a dot (period) in the name

Unsharded keyspace schema:

CREATE TABLE id_seq ( id INT, next_id BIGINT, cache BIGINT, PRIMARY KEY(id)) comment 'vitess_sequence';
INSERT INTO id_seq (id, next_id, cache) values (0, 1, 1000);

Unsharded keyspace vschema:

{
  "tables": {
    "id_seq": {
      "type": "sequence"
    }
  }
}

Sharded keyspace schema:

CREATE TABLE tablename (
    id BIGINT NOT NULL,
    c1 DOUBLE NOT NULL,
    c2 BIGINT,
    PRIMARY KEY (id),
    UNIQUE KEY (c1, c2)
);

CREATE TABLE lookup_vindex (
    c1 DOUBLE NOT NULL,
    c2 BIGINT,
    keyspace_id BLOB,
    UNIQUE KEY (`c1`, `c2`)
);

Sharded keyspace vschema:

{
  "sharded": true,
  "vindexes": {
    "lookup_vindex": {
      "type": "consistent_lookup",
      "params": {
        "from": "c1,c2",
        "table": "lookup_vindex",
        "to": "keyspace_id"
      },
      "owner": "tablename"
    },
    "hash": {
      "type": "hash"
    }
  },
  "tables": {
    "dotted.tablename": {
      "columnVindexes": [
        {
          "column": "id",
          "name": "hash"
        },
        {
          "name": "lookup_vindex",
          "columns": [ "c1", "c2" ]
        }
      ],
      "autoIncrement": {
        "column": "id",
        "sequence": "id_seq"
      }
    },
    "lookup_vindex": {
      "columnVindexes": [
        {
          "column": "c1",
          "name": "hash"
        }
      ]
    }
  }
}

Now, the bug appears when you try and insert a unique column pair twice:

First time (works fine):

mysql> insert into tablename (c1,c2) values (10,10);
Query OK, 1 row affected (0.07 sec)

mysql> select * from tablename;
+----+----+------+
| id | c1 | c2   |
+----+----+------+
|  5 | 10 |   10 |
+----+----+------+
1 row in set (0.00 sec)

mysql> select * from lookup_vindex;
+----+------+--------------------------+
| c1 | c2   | keyspace_id              |
+----+------+--------------------------+
| 10 |   10 | 0x70BB023C810CA87A       |
+----+------+--------------------------+
1 row in set (0.00 sec)

Insert duplicate:

mysql> insert into tablename (c1,c2) values (10,10);
ERROR 1105 (HY000): vtgate: http://localhost:15001/: execInsertSharded: getInsertShardedRoute: duplicate entry [INT64(10) INT64(10)]

The error is expected; but the type of error is incorrect. 1105 is an UNKNOWN_ERROR; and you would expect a 1062 Duplicate Entry error.

For comparison, when using a vindex of type lookup instead of consistent lookup, the type of error is correct, something like:

ERROR 1062 (23000): vtgate: http://localhost:15001/: execInsertSharded: getInsertShardedRoute: lookup.Create: Code: ALREADY_EXISTS
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 a pull request may close this issue.

2 participants