You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Liudmila Kornilova (Jira)" <ji...@apache.org> on 2019/08/20 10:07:00 UTC

[jira] [Commented] (CASSANDRA-15269) Cassandra fails to process OperationExecutionException which causes ClassCastException

    [ https://issues.apache.org/jira/browse/CASSANDRA-15269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16911178#comment-16911178 ] 

Liudmila Kornilova commented on CASSANDRA-15269:
------------------------------------------------

Each {{ExceptionCode}} correspond to specific exception class.
 {{OperationExecutionException}} did not have it's own code, instead it used {{FUNCTION_FAILURE}} code. So the exception was treated as {{FunctionExecutionException}}

I added {{OPERATION_FAILURE}} code

How to test:
 revert locally d60e7988736ed4358595e9c781b110a5bbb5f812 commit (void result truncate in decimal operations)
Or throw {{ArithmeticException}} in {{DecimalType.mod}}
{noformat}
try (CqlSession session = CqlSession.builder().build()) {
    session.execute("drop table if exists d");
    session.execute("create table d (n decimal primary key, d decimal)");
    session.execute("insert into d (n, d) values (123456789112345678921234567893123456, 2)");
    session.execute("select n % d from my.d");
}
{noformat}
What used to be:
{noformat}
Exception in thread "main" com.datastax.oss.driver.api.core.servererrors.ServerError: java.lang.ClassCastException: org.apache.cassandra.exceptions.OperationExecutionException cannot be cast to org.apache.cassandra.exceptions.FunctionExecutionException
	at com.datastax.oss.driver.api.core.servererrors.ServerError.copy(ServerError.java:54)
{noformat}
What is now:
{noformat}
Exception in thread "main" com.datastax.oss.driver.api.core.DriverExecutionException
	at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(CompletableFutures.java:150)
...
Caused by: java.lang.IllegalArgumentException: Unsupported error code: 5888
{noformat}
New error code should be added to Datastax Cassandra Native Protocol in [ProtocolConstants.java|https://github.com/datastax/native-protocol/blob/1.x/src/main/java/com/datastax/oss/protocol/internal/ProtocolConstants.java#L70]

If this commit is merged, I'll write a patch to the protocol

> Cassandra fails to process OperationExecutionException which causes ClassCastException
> --------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-15269
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15269
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL/Interpreter
>            Reporter: Liudmila Kornilova
>            Assignee: Liudmila Kornilova
>            Priority: Normal
>
> While working on CASSANDRA-15232 I noticed that OperationExecutionException is not processed correctly.
> How to reproduce the issue:
>  1. {{create table d (numerator decimal primary key, denominator decimal);}}
>  2. {{insert into d (numerator, denominator) values (123456789112345678921234567893123456, 2);}}
>  3. {{select numerator % denominator from d;}}
> What happens:
>  1. remainder operation throws ArithmeticException (BigDecimal:1854)
>  2. The exception is wrapped in OperationExecutionException
>  3. ClassCastException appears (OperationExecutionException cannot be cast to FunctionExecutionException at ErrorMessage.java:280)
> What should happen:
> OperationExecutionException with message "the operation 'decimal % decimal' failed: Division impossible" should be delivered to user 
> Note that after fixing CASSANDRA-15232 {{select numerator % denominator from d;}} will produce correct result of remainder operation.
>  Currently I am not aware of other cases when OperationExecutionException may be treated as FunctionExecutionException



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org