[
https://issues.apache.org/jira/browse/CASSANDRA-11043?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrés de la Peña reopened CASSANDRA-11043:
-------------------------------------------
Reproduced In: 3.5, 3.0.5 (was: 3.2.1)
The validation method works great with CQL queries producing a
{{PartitionRangeReadCommand}}, but it is not called with CQL queries producing
one or more {{SinglePartitionReadCommand}}.
For example, the following query properly validates the expression:
{code}
SELECT * FROM test WHERE expr(test_idx, 'error');
{code}
However the following queries skip validation:
{code}
SELECT * FROM test WHERE expr(test_idx, 'error') AND id=1;
SELECT * FROM test WHERE expr(test_idx, 'error') AND id IN (1,2);
{code}
> Secondary indexes doesn't properly validate custom expressions
> --------------------------------------------------------------
>
> Key: CASSANDRA-11043
> URL: https://issues.apache.org/jira/browse/CASSANDRA-11043
> Project: Cassandra
> Issue Type: Bug
> Components: CQL, Local Write-Read Paths
> Reporter: Andrés de la Peña
> Assignee: Sam Tunnicliffe
> Labels: 2i, index, validation
> Fix For: 3.0.4, 3.4
>
> Attachments: test-index.zip
>
>
> It seems that
> [CASSANDRA-7575|https://issues.apache.org/jira/browse/CASSANDRA-7575] is
> broken in Cassandra 3.x. As stated in the secondary indexes' API
> documentation, custom index implementations should perform any validation of
> query expressions at {{Index#searcherFor(ReadCommand)}}, throwing an
> {{InvalidRequestException}} if the expressions are not valid. I assume these
> validation errors should produce an {{InvalidRequest}} error on cqlsh, or
> raise an {{InvalidQueryException}} on Java driver. However, when
> {{Index#searcherFor(ReadCommand)}} throws its {{InvalidRequestException}}, I
> get this cqlsh output:
> {noformat}
> Traceback (most recent call last):
> File "bin/cqlsh.py", line 1246, in perform_simple_statement
> result = future.result()
> File
> "/Users/adelapena/stratio/platform/src/cassandra-3.2.1/bin/../lib/cassandra-driver-internal-only-3.0.0-6af642d.zip/cassandra-driver-3.0.0-6af642d/cassandra/cluster.py",
> line 3122, in result
> raise self._final_exception
> ReadFailure: code=1300 [Replica(s) failed to execute read] message="Operation
> failed - received 0 responses and 1 failures" info={'failures': 1,
> 'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}
> {noformat}
> I attach a dummy index implementation to reproduce the error:
> {noformat}
> CREATE KEYSPACE test with replication = {'class' : 'SimpleStrategy',
> 'replication_factor' : '1' };
> CREATE TABLE test.test (id int PRIMARY KEY, value varchar);
> CREATE CUSTOM INDEX test_index ON test.test() USING 'com.stratio.TestIndex';
> SELECT * FROM test.test WHERE expr(test_index,'ok');
> SELECT * FROM test.test WHERE expr(test_index,'error');
> {noformat}
> This is specially problematic when using Cassandra Java Driver, because one
> of these server exceptions can produce subsequent queries fail (even if they
> are valid) with a no host available exception.
> Maybe the validation method added with
> [CASSANDRA-7575|https://issues.apache.org/jira/browse/CASSANDRA-7575] should
> be restored, unless there is a way to properly manage the exception.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)