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

Duplicate-key error message for vinyl says index name is null #5975

Closed
pgulutzan opened this issue Apr 7, 2021 · 1 comment · Fixed by #10023
Closed

Duplicate-key error message for vinyl says index name is null #5975

pgulutzan opened this issue Apr 7, 2021 · 1 comment · Fixed by #10023
Assignees
Labels
2.11 Target is 2.11 and all newer release/master branches 3.1 Target is 3.1 and all newer release/master branches bug Something isn't working vinyl

Comments

@pgulutzan
Copy link
Contributor

pgulutzan commented Apr 7, 2021

I have Ubuntu 20.04
Tarantool version: Tarantool 2.7.1-186-g365e67c51 pulled from source today

I execute these requests:

box.execute([[CREATE TABLE j (s1 INT PRIMARY KEY, s2 STRING) WITH ENGINE='vinyl';]])
box.space.J:create_index('I3', {parts = {2, 'string'}})
box.space.J:create_index('I5', {parts = {2, 'string'}})
box.execute([[INSERT INTO j VALUES (7, 'a');]])
box.space.J.index.I3:drop()
box.execute([[INSERT INTO j VALUES (8, 'a');]])

Result: error message =
Duplicate key exists in unique index '(null)' in space 'J'
... There is a duplicate key but there is no unique index named '(null)'.
The expected behaviour is: error message =
Duplicate key exists in unique index 'I5' in space 'J'
.

@pgulutzan pgulutzan added the bug Something isn't working label Apr 7, 2021
@kyukhin kyukhin added this to the wishlist milestone Jul 14, 2021
@kyukhin kyukhin removed this from the wishlist milestone Jun 24, 2022
@ImeevMA
Copy link
Collaborator

ImeevMA commented Sep 8, 2022

Reproducer without SQL:

s = box.schema.space.create('a', {engine = 'vinyl', format = {{'a', 'integer'}, {'b', 'integer'}}})
_ = s:create_index('ii')
s:create_index('i1', {parts = {2, 'integer'}})
s:create_index('i2', {parts = {2, 'integer'}})
s:insert({1,1})
s.index.i1:drop()
s:insert({2,1})

Error:

tarantool> s:insert({2,1})
---
- error: Duplicate key exists in unique index "(null)" in space "a" with old tuple
    - [1, 1] and new tuple - [2, 1]
...

@TarantoolBot TarantoolBot removed the teamC label Jun 7, 2023
@locker locker self-assigned this May 17, 2024
locker added a commit that referenced this issue May 17, 2024
The code setting ER_TUPLE_FOUND uses index_name_by_id() to find
the index name, but it passes an index in the dense index map to
it while the function expects an index in the sparse index map.
Apparently, this doesn't work as expected after an index is removed
from the middle of the index map. This bug was introduced by
commit fc3834c ("vinyl: check key uniqueness before modifying
tx write set").

Instead of just fixing the index passed to index_name_by_id(), we do
a bit of refactoring. We stop passing index_name and space_name to
vy_check_is_unique_*() functions and instead get them right before
raising ER_TUPLE_FOUND. Note, to get the space name, we need to call
space_by_id() but it should be fine because (a) the space is very likely
to be cached as the last accessed one and (b) this is an error path so
it isn't performance critical. We also drop index_name_by_id() and
extract the index name from the LSM tree object.

Closes #5975

NO_DOC=bug fix
@locker locker added 2.11 Target is 2.11 and all newer release/master branches 3.1 Target is 3.1 and all newer release/master branches labels May 20, 2024
locker added a commit that referenced this issue May 20, 2024
The code setting ER_TUPLE_FOUND uses index_name_by_id() to find
the index name, but it passes an index in the dense index map to
it while the function expects an index in the sparse index map.
Apparently, this doesn't work as expected after an index is removed
from the middle of the index map. This bug was introduced by
commit fc3834c ("vinyl: check key uniqueness before modifying
tx write set").

Instead of just fixing the index passed to index_name_by_id(), we do
a bit of refactoring. We stop passing index_name and space_name to
vy_check_is_unique_*() functions and instead get them right before
raising ER_TUPLE_FOUND. Note, to get the space name, we need to call
space_by_id() but it should be fine because (a) the space is very likely
to be cached as the last accessed one and (b) this is an error path so
it isn't performance critical. We also drop index_name_by_id() and
extract the index name from the LSM tree object.

Closes #5975

NO_DOC=bug fix
locker added a commit that referenced this issue May 20, 2024
The code setting ER_TUPLE_FOUND uses index_name_by_id() to find
the index name, but it passes an index in the dense index map to
it while the function expects an index in the sparse index map.
Apparently, this doesn't work as expected after an index is removed
from the middle of the index map. This bug was introduced by
commit fc3834c ("vinyl: check key uniqueness before modifying
tx write set").

Instead of just fixing the index passed to index_name_by_id(), we do
a bit of refactoring. We stop passing index_name and space_name to
vy_check_is_unique_*() functions and instead get them right before
raising ER_TUPLE_FOUND. Note, to get the space name, we need to call
space_by_id() but it should be fine because (a) the space is very likely
to be cached as the last accessed one and (b) this is an error path so
it isn't performance critical. We also drop index_name_by_id() and
extract the index name from the LSM tree object.

Closes #5975

NO_DOC=bug fix

(cherry picked from commit 2cfba5e)
locker added a commit that referenced this issue May 20, 2024
The code setting ER_TUPLE_FOUND uses index_name_by_id() to find
the index name, but it passes an index in the dense index map to
it while the function expects an index in the sparse index map.
Apparently, this doesn't work as expected after an index is removed
from the middle of the index map. This bug was introduced by
commit fc3834c ("vinyl: check key uniqueness before modifying
tx write set").

Instead of just fixing the index passed to index_name_by_id(), we do
a bit of refactoring. We stop passing index_name and space_name to
vy_check_is_unique_*() functions and instead get them right before
raising ER_TUPLE_FOUND. Note, to get the space name, we need to call
space_by_id() but it should be fine because (a) the space is very likely
to be cached as the last accessed one and (b) this is an error path so
it isn't performance critical. We also drop index_name_by_id() and
extract the index name from the LSM tree object.

Closes #5975

NO_DOC=bug fix

(cherry picked from commit 2cfba5e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.11 Target is 2.11 and all newer release/master branches 3.1 Target is 3.1 and all newer release/master branches bug Something isn't working vinyl
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants