[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502868#comment-17502868 ] Andres de la Peña commented on CASSANDRA-17187: --- Committed to trunk as [3233c823116343cd95381790d736e239d800035a|https://github.com/apache/cassandra/commit/3233c823116343cd95381790d736e239d800035a], thanks for the review :) > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Assignee: Andres de la Peña >Priority: Normal > Labels: lhf > Fix For: 4.x > > Time Spent: 1h > Remaining Estimate: 0h > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add some tests for the new guardrail. Given that the new guardrail > is a Threshold, our new test should probably extend {{ThresholdTester}}. -- This message was sent by Atlassian Jira (v8.20.1#820001) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502464#comment-17502464 ] Andres de la Peña commented on CASSANDRA-17187: --- [~e.dimitrova] thanks for reviewing, I have tried to address your suggestions and questions on the PR. Running CI after rebasing: ||PR||CI|| |[trunk|https://github.com/apache/cassandra/pull/1444]|[j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/1339/workflows/f68679e1-3445-4950-8d96-ecacf8e88e8e] [j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/1339/workflows/6e4fddc7-2613-489a-bef7-1fb7f2100941]| > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Assignee: Andres de la Peña >Priority: Normal > Labels: lhf > Fix For: 4.x > > Time Spent: 50m > Remaining Estimate: 0h > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add some tests for the new guardrail. Given that the new guardrail > is a Threshold, our new test should probably extend {{ThresholdTester}}. -- This message was sent by Atlassian Jira (v8.20.1#820001) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.a
[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17501022#comment-17501022 ] Ekaterina Dimitrova commented on CASSANDRA-17187: - Overall looks good to me, left just two nits and 2 questions for quick confirmation of my understanding. CI also LGTM. Thanks! > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Assignee: Andres de la Peña >Priority: Normal > Labels: lhf > Fix For: 4.x > > Time Spent: 10m > Remaining Estimate: 0h > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add some tests for the new guardrail. Given that the new guardrail > is a Threshold, our new test should probably extend {{ThresholdTester}}. -- This message was sent by Atlassian Jira (v8.20.1#820001) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17496751#comment-17496751 ] Andres de la Peña commented on CASSANDRA-17187: --- Just rebased on top of the last changes on trunk, which involved some trivial merge conflicts on the new guardrail: ||PR||CI|| |[trunk|https://github.com/apache/cassandra/pull/1444]|[j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/1311/workflows/844a26dc-601e-4906-9cb0-c37f2d541abe] [j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/1311/workflows/ad10d189-3e33-4e8a-a103-4d1df0e35e78]| > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Assignee: Andres de la Peña >Priority: Normal > Labels: lhf > Fix For: 4.x > > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add some tests for the new guardrail. Given that the new guardrail > is a Threshold, our new test should probably extend {{ThresholdTester}}. -- This message was sent by Atlassian Jira (v8.20.1#820001) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17490859#comment-17490859 ] Andres de la Peña commented on CASSANDRA-17187: --- Here is the patch: ||PR||CI|| |[trunk|https://github.com/apache/cassandra/pull/1444]|[j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/1296/workflows/f532c245-0374-43ab-b991-c58fab0c135d] [j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/1296/workflows/57c48e3e-5fc0-4df1-82ae-c50592b79427]| The patch is relatively simple but the patch is a bit noisy because we need to pass the {{ClientState}} to {{PartitionKeySingleRestrictionSet}} and \{{ClusteringColumnRestrictions{}, and this affects a bunch of classes in the way. There is also a minor refactor ofthe signatures of the utility methods {{GuardrailTester#assertWarns}} and {{GuardrailTester#aasertFails}} that (trivially) touches a bunch of tests. The reason for this refactor is that we need to consider that a query can trigger multiple guardrails and thus produce multiple warnings. > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Assignee: Andres de la Peña >Priority: Normal > Labels: lhf > Fix For: 4.x > > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add s
[jira] [Commented] (CASSANDRA-17187) Guardrail for SELECT IN terms and their cartesian product
[ https://issues.apache.org/jira/browse/CASSANDRA-17187?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17486664#comment-17486664 ] Andres de la Peña commented on CASSANDRA-17187: --- There was an old patch by [~Ge] for this, I'll post it here as soon as I adapt it to the last changes. > Guardrail for SELECT IN terms and their cartesian product > - > > Key: CASSANDRA-17187 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17187 > Project: Cassandra > Issue Type: New Feature > Components: Feature/Guardrails >Reporter: Andres de la Peña >Priority: Normal > Labels: AdventCalendar2021, lhf > Fix For: 4.x > > > Add a guardrail to limit the number restrictions generated by the cartesian > product of the {{IN}} restrictions of a {{SELECT}} query, for example: > {code} > # Guardrail to warn or abort when IN query creates a cartesian product with a > # size exceeding threshold, eg. "a in (1,2,...10) and b in (1,2...10)" > results in > # cartesian product of 100. > # The two thresholds default to -1 to disable. > in_select_cartesian_product: > warn_threshold: -1 > abort_threshold: -1 > {code} > As an example of why this guardrails is proposed, these queries bring a C* > instance to its knees even before the query starts executing: > {code} > @Test > public void testPartitionKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk1 int, pk2 int, pk3 int, pk4 int, pk5 > int, pk6 int, pk7 int, pk8 int, pk9 int, " + >"PRIMARY KEY((pk1, pk2, pk3, pk4, pk5, pk6, pk7, pk8, pk9)))"); > execute("SELECT * FROM %s WHERE pk1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND pk9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > @Test > public void testClusteringKeyTerms() throws Throwable > { > createTable("CREATE TABLE %s (pk int ,ck1 int, ck2 int, ck3 int, ck4 int, > ck5 int, ck6 int, ck7 int, ck8 int, ck9 int, " + > "PRIMARY KEY(pk, ck1, ck2, ck3, ck4, ck5, ck6, ck7, ck8, ck9))"); > execute("SELECT * FROM %s WHERE pk = 1 " + > "AND ck1 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck2 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck3 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck4 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck5 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck6 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck7 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck8 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) " + > "AND ck9 in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);"); > } > {code} > +Additional information for newcomers:+ > # Add the configuration for the new guardrail on cartesian product in the > guardrails section of cassandra.yaml. > # Add a {{getInCartesianProduct}} method in {{GuardrailsConfig}} returning a > {{Threshold.Config}} object > # Implement that method in {{GuardrailsOptions}}, which is the default > yaml-based implementation of {{GuardrailsConfig}} > # Add a Threshold guardrail named {{inCartesianProduct}} in Guardrails, using > the previously created config > # Define JMX-friendly getters and setters for the previously created config > in {{GuardrailsMBean}} > # Implement the JMX-friendly getters and setters in Guardrails > # Now that we have the guardrail ready, it’s time to use it. We should search > for a place to invoke the Guardrails#inCartesianProduct guard method. The > {{MultiCBuilder}} look like good candidates for this. > # Finally, add some tests for the new guardrail. Given that the new guardrail > is a Threshold, our new test should probably extend {{ThresholdTester}}. -- This message was sent by Atlassian Jira (v8.20.1#820001) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org