[ https://issues.apache.org/jira/browse/CASSANDRA-20596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947298#comment-17947298 ]
Benedict Elliott Smith commented on CASSANDRA-20596: ---------------------------------------------------- This might not be a journal corruption issue, and it shouldn't be due to what you did. This might be down to schema changes, but we probably don't print enough debug log info just yet to easily diagnose this remotely. Have you dropped a table by any chance? Or even re-created a table with the same name? It looks like this is a table created on epoch 15, and it is trying to execute in epoch 23. If it got erased in-between, it might be an issue with our logic to reject commands, or it could be we have some other command store mapping or epoch handling issue that we haven't seen yet. > NPE when executing IF block in transactions with invalid comparison > ------------------------------------------------------------------- > > Key: CASSANDRA-20596 > URL: https://issues.apache.org/jira/browse/CASSANDRA-20596 > Project: Apache Cassandra > Issue Type: Bug > Components: Accord > Reporter: Jon Haddad > Priority: Normal > Attachments: corrupt.zip > > > I managed to catch a NPE when trying to execute a transaction. This came > about from an error in my syntax, but I think we should handle this more > gracefully. > Here's the setup: > > > {noformat} > create KEYSPACE games WITH replication = {'class': 'SimpleStrategy', > 'replication_factor': 1}; > USE games; > CREATE TABLE games.high_scores_by_user ( user text, game text, score int, > primary key(user, game)) > WITH compaction = {'class': 'UnifiedCompactionStrategy', > 'scaling_parameters': 'L10'} > AND transactional_mode = 'full'; > CREATE TABLE games.leaderboard (game text, score int, user text, primary key > (game, score, user)) > WITH compaction = {'class': 'UnifiedCompactionStrategy', > 'scaling_parameters': 'L10'} > AND clustering order by (score DESC, user ASC) > AND transactional_mode = 'full'; > {noformat} > > The query: > > {noformat} > BEGIN TRANSACTION > LET high_score = (SELECT * from games.high_scores_by_user WHERE user = > 'jon' and game = 'pictionary'); > SELECT high_score.score; > IF high_score = 100 THEN > INSERT INTO games.high_scores_by_user (game, score, user) VALUES > ('pictionary', 110, 'jon'); > INSERT INTO games.leaderboard (game, score, user) VALUES ('pictionary', > 110, 'jon'); > DELETE from games.leaderboard WHERE user = 'jon' AND game = 'pictionary' > AND score = 100; > END IF > COMMIT TRANSACTION;{noformat} > In the IF block I forgot to put the field I was comparing, it should have > been high_score.score, and got the following: > > {noformat} > NoHostAvailable: ('Unable to complete the operation against any hosts', > {<Host: 127.0.0.1:9042 datacenter1>: <Error from server: code=0000 [Server > error] message="java.lang.NullPointerException: Cannot read field "type" > because "receiver" is null">}){noformat} > On the server side, I see this: > > {noformat} > ERROR [Native-Transport-Requests-1] 2025-04-24 16:00:15,711 > QueryMessage.java:130 - Unexpected error during query > java.lang.NullPointerException: Cannot read field "type" because "receiver" > is null > at > org.apache.cassandra.cql3.terms.Constants$Literal.testAssignment(Constants.java:326) > at > org.apache.cassandra.cql3.terms.Constants$Literal.prepare(Constants.java:295) > at > org.apache.cassandra.cql3.terms.Constants$Literal.prepare(Constants.java:243) > at > org.apache.cassandra.cql3.transactions.ConditionStatement$Raw.prepare(ConditionStatement.java:105) > at > org.apache.cassandra.cql3.statements.TransactionStatement$Parsed.prepare(TransactionStatement.java:734) > at > org.apache.cassandra.cql3.QueryProcessor.getStatement(QueryProcessor.java:911) > at org.apache.cassandra.cql3.QueryProcessor.parse(QueryProcessor.java:360) > at > org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:116) > at > org.apache.cassandra.transport.Message$Request.execute(Message.java:259) > at > org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:423) > at > org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:442) > at > org.apache.cassandra.transport.Dispatcher.processRequest(Dispatcher.java:469) > at > org.apache.cassandra.transport.Dispatcher$RequestProcessor.run(Dispatcher.java:314) > at org.apache.cassandra.concurrent.FutureTask$1.call(FutureTask.java:99) > at org.apache.cassandra.concurrent.FutureTask.call(FutureTask.java:61) > at org.apache.cassandra.concurrent.FutureTask.run(FutureTask.java:71) > at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:145) > at > io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) > at java.base/java.lang.Thread.run(Thread.java:840){noformat} > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org