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

[YCQL] index update on list after an overwrite has incorrect behavior #6735

Closed
kmuthukk opened this issue Dec 22, 2020 · 0 comments
Closed
Assignees
Labels
kind/bug This issue is a bug priority/high High Priority

Comments

@kmuthukk
Copy link
Collaborator

kmuthukk commented Dec 22, 2020

Test Case 1:

ycqlsh:k> create table T(k int primary key, l list<int>);
ycqlsh:k> update T set l=[1, 2, 3] where k=1;
ycqlsh:k> update T set l[0]=100 where k=1;
ycqlsh:k> select * from T;

 k | l
---+-------------
 1 | [100, 2, 3]            --> EXPECTED/CORRECT

(1 rows)

# but after an overwrite to list
ycqlsh:k> update T set l=[4, 5, 6] where k=1;

# this statement results in incorrect behavior
ycqlsh:k> update T set l[0]=100 where k=1;
ycqlsh:k> select * from T;

 k | l
---+----------------
 1 | [100, 4, 5, 6]         -->  INCORRECT --> the list should now be [100, 5, 6]

(1 rows)

Test Case 2:

create table test(h int, v list<int>, primary key(h));
insert into test(h,v) values (1, [5,6,7,8]);
update test set v = [1,2,3,4] where h = 1;

-- Should throw an index-out-of-range error, but will succeed because old
-- values are not skipped when searching for the index.
update test set v[6] = 11 where h = 1;

select * from test;

 h | v
---+---------------
 1 | [1, 2, 11, 4]        --> INCORRECT ; the previous UPDATE should have raised an error.
@kmuthukk kmuthukk added kind/bug This issue is a bug priority/high High Priority labels Dec 22, 2020
@robertsami robertsami assigned robertsami and unassigned m-iancu Dec 23, 2020
robertsami added a commit that referenced this issue Jan 22, 2021
Summary:
Previously we would not consider the write time of a collection when iterating over its children. This means
we would look at children of a collection which were logically overwritten from the perspective of query
layer reads and count them as valid children when determining what docdb ArrayIndex corresponds to a given
cql list index. This diff fixes the logic to consider the write time of a collection and ignore children
which were written before that.

Test Plan:
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListOverwriteAndInsertTest/0"`
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListInsertAndGetTest/0"`
`build/latest/tests-integration-tests/cql-test --gtest_filter="CqlTest.TestUpdateListIndexAfterOverwrite"`

Reviewers: mihnea

Reviewed By: mihnea

Subscribers: zyu, yql, kannan, sergei, mbautin

Differential Revision: https://phabricator.dev.yugabyte.com/D10255
robertsami added a commit that referenced this issue Jan 28, 2021
…ies as expired

Summary:
Previously we would not consider the write time of a collection when iterating over its children. This means
we would look at children of a collection which were logically overwritten from the perspective of query
layer reads and count them as valid children when determining what docdb ArrayIndex corresponds to a given
cql list index. This diff fixes the logic to consider the write time of a collection and ignore children
which were written before that.

Original commit: e0643e6 / D10255

Test Plan:
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListOverwriteAndInsertTest/0"`
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListInsertAndGetTest/0"`
`build/latest/tests-integration-tests/cql-test --gtest_filter="CqlTest.TestUpdateListIndexAfterOverwrite"`

Jenkins: rebase: 2.4

Reviewers: mihnea

Reviewed By: mihnea

Subscribers: mbautin, sergei, kannan, yql, zyu

Differential Revision: https://phabricator.dev.yugabyte.com/D10470
robertsami added a commit that referenced this issue Feb 1, 2021
…ies as expired

Summary:
Previously we would not consider the write time of a collection when iterating over its children. This means
we would look at children of a collection which were logically overwritten from the perspective of query
layer reads and count them as valid children when determining what docdb ArrayIndex corresponds to a given
cql list index. This diff fixes the logic to consider the write time of a collection and ignore children
which were written before that.

Original commit: e0643e6 / D10255

Test Plan:
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListOverwriteAndInsertTest/0"`
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListInsertAndGetTest/0"`
`build/latest/tests-integration-tests/cql-test --gtest_filter="CqlTest.TestUpdateListIndexAfterOverwrite"`

Jenkins: rebase: 2.2

Reviewers: mihnea

Reviewed By: mihnea

Subscribers: mbautin, sergei, kannan, yql, zyu

Differential Revision: https://phabricator.dev.yugabyte.com/D10471
polarweasel pushed a commit to lizayugabyte/yugabyte-db that referenced this issue Mar 9, 2021
…expired

Summary:
Previously we would not consider the write time of a collection when iterating over its children. This means
we would look at children of a collection which were logically overwritten from the perspective of query
layer reads and count them as valid children when determining what docdb ArrayIndex corresponds to a given
cql list index. This diff fixes the logic to consider the write time of a collection and ignore children
which were written before that.

Test Plan:
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListOverwriteAndInsertTest/0"`
`build/latest/tests-docdb/docdb-test --gtest_filter="DocDBTests/DocDBTestWrapper.ListInsertAndGetTest/0"`
`build/latest/tests-integration-tests/cql-test --gtest_filter="CqlTest.TestUpdateListIndexAfterOverwrite"`

Reviewers: mihnea

Reviewed By: mihnea

Subscribers: zyu, yql, kannan, sergei, mbautin

Differential Revision: https://phabricator.dev.yugabyte.com/D10255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This issue is a bug priority/high High Priority
Projects
None yet
Development

No branches or pull requests

3 participants