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

Indexes with groups erroneously accept deleteRecordsWhere queries on grouped columns #1583

Closed
alecgrieser opened this issue Apr 4, 2022 · 0 comments · Fixed by #1584
Closed
Assignees
Labels
bug Something isn't working

Comments

@alecgrieser
Copy link
Contributor

On indexes with a grouping, like the atomic mutation indexes or the rank indexes, the canDeleteWhere function should return true only if the delete-where predicate can be satisfied by the grouping columns. For example, if you had a SUM index on field("foo").groupBy(field("bar")), the index can allow delete where requests with predicates like Query.field("bar").equalsValue(x), but it should reject queries with predicates like Query.and(Query.field("bar").equalsValue(x), Query.field("foo").equalsValue(y)).

However, grouping queries currently use the QueryToKeyMatcher to determine if the query can be satisfied, and that tries to match the entire key, not just the grouping subkey:

return matches(query, ((GroupingKeyExpression) key).getWholeKey(), matchingMode, filterMask);

That means that indexes with groupings are accepting grouping predicates that they shouldn't be.

@alecgrieser alecgrieser added the bug Something isn't working label Apr 4, 2022
@alecgrieser alecgrieser self-assigned this Apr 4, 2022
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Apr 4, 2022
…eRecordsWhere queries on grouped columns

This adjusts the methods used by `canDeleteWhere` on indexes defined on a `GroupingKeyExpression` so that it tries to satisfy the query from the grouping sub key rather than the whole key to limit the number of accepted `deleteRecordsWhere` predicates to more closely align with that is actually possible to safely delete. This includes some regression tests that hit the error, as well as a small amount of refactoring that is to set up FoundationDB#1580.

This fixes FoundationDB#1583.
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Apr 4, 2022
…eRecordsWhere queries on grouped columns

This adjusts the methods used by `canDeleteWhere` on indexes defined on a `GroupingKeyExpression` so that it tries to satisfy the query from the grouping sub key rather than the whole key to limit the number of accepted `deleteRecordsWhere` predicates to more closely align with that is actually possible to safely delete. This includes some regression tests that hit the error, as well as a small amount of refactoring that is to set up FoundationDB#1580.

This fixes FoundationDB#1583.
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Apr 5, 2022
…eRecordsWhere queries on grouped columns

This adjusts the methods used by `canDeleteWhere` on indexes defined on a `GroupingKeyExpression` so that it tries to satisfy the query from the grouping sub key rather than the whole key to limit the number of accepted `deleteRecordsWhere` predicates to more closely align with that is actually possible to safely delete. This includes some regression tests that hit the error, as well as a small amount of refactoring that is to set up FoundationDB#1580.

This fixes FoundationDB#1583.
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Apr 6, 2022
…eRecordsWhere queries on grouped columns

This adjusts the methods used by `canDeleteWhere` on indexes defined on a `GroupingKeyExpression` so that it tries to satisfy the query from the grouping sub key rather than the whole key to limit the number of accepted `deleteRecordsWhere` predicates to more closely align with that is actually possible to safely delete. This includes some regression tests that hit the error, as well as a small amount of refactoring that is to set up FoundationDB#1580.

This fixes FoundationDB#1583.
ScottDugas added a commit that referenced this issue Apr 7, 2022
…ouping

Fixes #1583: Indexes with groups erroneously accept deleteRecordsWhere queries on grouped columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant