Skip to content

Bug Report: consistent lookup vindex bug with duplicate key error executes outside of transaction #17956

Open
@harshit-gangal

Description

@harshit-gangal

Overview of the Issue

When writing to a table with consistent lookup vindex.
A unique vindex gets inserted without failing.
When a duplicate error is received the vindex entry is rolledback but part of the query executes outside of the transaction.

Reproduction Steps

  "vindexes": {
    "hash": {
      "type": "hash"
    },
    "num_vdx": {
      "type": "consistent_lookup_unique",
      "params": {
        "table": "num_vdx_tbl",
        "from": "num",
        "to": "keyspace_id"
      },
      "owner": "s_tbl"
    },
  "tables": {
    "s_tbl": {
      "column_vindexes": [
        {
          "column": "id",
          "name": "hash"
        },
        {
          "column": "num",
          "name": "num_vdx"
        }
      ]
    },
    "num_vdx_tbl": {
      "column_vindexes": [
        {
          "column": "num",
          "name": "hash"
        }
      ]
    },

create table s_tbl
(
    id  bigint,
    num bigint,
    primary key (id)
) Engine = InnoDB;

create table num_vdx_tbl
(
    num         bigint,
    keyspace_id varbinary(20),
    primary key (num)
) Engine = InnoDB;

insert into s_tbl(id, num) values (1,10), (2,10), (3,10), (4,20), (5,5), (6,15), (7,17), (8,80)

This query should fail as inserted 10 value in num column on vindex table will return duplicate error.
Instead, query executes successfully holding all the rows in main table.

Binary Version

`main`, possibly in all versions.

Operating System and Environment details

NA

Log Fragments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions