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: Duplicate key error in lookup table of type lookup_unique is recorded as UNKNOWN error in vtgate metrics #14748

Closed
harshit-gangal opened this issue Dec 11, 2023 · 0 comments · Fixed by #14737

Comments

@harshit-gangal
Copy link
Member

Overview of the Issue

If the lookup table insert results in a duplicate key exception, it is recorded as UNKNOWN, e.g.

vtgate_api_error_counts{code="UNKNOWN",db_type="primary",keyspace="sharded",operation="Execute"} 28

This confuses and should record the metrics errors in alignment with what was sent back to the client.

Reproduction Steps

Vschema:

{
    "sharded": true,
    "vindexes": {
        "hash": {
            "type": "hash"
        },
        "xxhash": {
            "type": "xxhash"
        },
        "lookup_t1": {
            "type": "lookup_unique",
            "params": {
                "from": "c2",
                "table": "lookup_t1_backing",
                "to": "keyspace_id",
                "write_only": "false"
            },
            "owner": "t1"
        }
    },
    "tables": {
        "t1": {
            "column_vindexes": [
                {
                    "column": "c1",
                    "name": "xxhash"
                },
                {
                    "column": "c2",
                    "name": "lookup_t1"
                }
            ]
        },
        "lookup_t1_backing": {
            "column_vindexes": [
                {
                    "column": "c2",
                    "name": "hash"
                }
            ]
        }
    }
}

schema:

CREATE TABLE lookup_t1_backing (  `c2` bigint unsigned NOT NULL,  `keyspace_id` varbinary(128) DEFAULT NULL,  PRIMARY KEY (`c2`));
create table t1 (c1 bigint not null, c2 bigint not null, c3 bigint, primary key(c1));

Run:

insert into t1 (c1,c2) values (20,21);
insert into t1 (c1,c2) values (20,21);

Observe the error and that it is a duplicate key error (1062), then check the vtgate metrics, e.g.:

curl -s http://localhost:15001/metrics | grep api_error

and see that the error was recorded as UNKNOWN instead of ALREADY_EXISTS

Binary Version

`main`

Operating System and Environment details

NA

Log Fragments

No response

@harshit-gangal harshit-gangal added Type: Bug Needs Triage This issue needs to be correctly labelled and triaged Component: Query Serving and removed Needs Triage This issue needs to be correctly labelled and triaged labels Dec 11, 2023
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.

1 participant