Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-11064

Failed aggregate creation breaks server permanently

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 3.0.4, 3.4
    • None
    • None
    • Normal

    Description

      While testing edge cases around aggregates, I tried the following to see if custom types were supported:

      ccm create v321 -v3.2.1 -n3
      ccm updateconf enable_user_defined_functions:true
      ccm start
      ccm node1 cqlsh
      
      CREATE FUNCTION id(i 'DynamicCompositeType(s => UTF8Type, i => Int32Type)')
      RETURNS NULL ON NULL INPUT
      RETURNS 'DynamicCompositeType(s => UTF8Type, i => Int32Type)'
      LANGUAGE java
      AS 'return i;';
      // function created successfully
      
      CREATE AGGREGATE ag()
      SFUNC id
      STYPE 'DynamicCompositeType(s => UTF8Type, i => Int32Type)'
      INITCOND 's@foo:i@32';
      
      ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.cassandra.exceptions.SyntaxException: Failed parsing CQL term: [s@foo:i@32] reason: SyntaxException line 1:1 no viable alternative at character '@'">

      Despite the error, the aggregate appears in system tables:

      select * from system_schema.aggregates;
       keyspace_name | aggregate_name | ...
      ---------------+----------------+ ...
                test |             ag | ...
      

      But you can't drop it, and trying to drop its function produces the server error again:

      DROP AGGREGATE ag;
      InvalidRequest: code=2200 [Invalid query] message="Cannot drop non existing aggregate 'test.ag'"
      
      DROP FUNCTION id;
      ServerError: <ErrorMessage code=0000 [Server error] message="java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.cassandra.exceptions.SyntaxException: Failed parsing CQL term: [s@foo:i@32] reason: SyntaxException line 1:1 no viable alternative at character '@'">
      

      What's worse, it's now impossible to restart the server:

      ccm stop; ccm start
      
      org.apache.cassandra.exceptions.SyntaxException: Failed parsing CQL term: [s@foo:i@32] reason: SyntaxException line 1:1 no viable alternative at character '@'
      	at org.apache.cassandra.cql3.CQLFragmentParser.parseAny(CQLFragmentParser.java:48)
      	at org.apache.cassandra.cql3.Terms.asBytes(Terms.java:51)
      	at org.apache.cassandra.schema.SchemaKeyspace.createUDAFromRow(SchemaKeyspace.java:1225)
      	at org.apache.cassandra.schema.SchemaKeyspace.fetchUDAs(SchemaKeyspace.java:1204)
      	at org.apache.cassandra.schema.SchemaKeyspace.fetchFunctions(SchemaKeyspace.java:1129)
      	at org.apache.cassandra.schema.SchemaKeyspace.fetchKeyspace(SchemaKeyspace.java:897)
      	at org.apache.cassandra.schema.SchemaKeyspace.fetchKeyspacesWithout(SchemaKeyspace.java:872)
      	at org.apache.cassandra.schema.SchemaKeyspace.fetchNonSystemKeyspaces(SchemaKeyspace.java:860)
      	at org.apache.cassandra.config.Schema.loadFromDisk(Schema.java:125)
      	at org.apache.cassandra.config.Schema.loadFromDisk(Schema.java:115)
      	at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:229)
      	at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:551)
      	at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:680)
      

      Attachments

        Issue Links

          Activity

            People

              snazy Robert Stupp
              omichallat Olivier Michallat
              Robert Stupp
              Sylvain Lebresne
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: