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

Prevent reloading of logback.xml from UDF sandbox

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 3.0.11, 3.10
    • None
    • None
    • Cassandra 3.7 (via brew install), Mac OS X 10.11.6

    • Low

    Description

      I have defined a UDA to implement standard deviation:

      cqlsh:mykeyspace> CREATE OR REPLACE FUNCTION sdState ( state tuple<int,double,double>, val double ) CALLED ON NULL INPUT RETURNS tuple<int,double,double> LANGUAGE java AS 
       ... 'int n = state.getInt(0); double mean = state.getDouble(1); double m2 = state.getDouble(2); n++; double delta = val - mean; mean += delta / n; m2 += delta * (val - mean); state.setInt(0, n); state.setDouble(1, mean); state.setDouble(2, m2); return state;'; 
      
      cqlsh:mykeyspace> CREATE OR REPLACE FUNCTION sdFinal ( state tuple<int,double,double> ) CALLED ON NULL INPUT RETURNS double LANGUAGE java AS 
       ... 'int n = state.getInt(0); double m2 = state.getDouble(2); if (n < 1) { return null; } return Math.sqrt(m2 / (n - 1));';
      
      cqlsh:mykeyspace> CREATE AGGREGATE IF NOT EXISTS stdev ( double ) 
       ... SFUNC sdState STYPE tuple<int,double,double> FINALFUNC sdFinal INITCOND (0,0,0);
      

      My table:

      CREATE TABLE readings (
          sensor_id int,
          time timestamp,
          temperature double,
          status text,
          PRIMARY KEY (sensor_id, time)
      ) WITH CLUSTERING ORDER BY (time ASC);
      

      I'm inserting a row every 0.1 seconds. The data looks like this:

      cqlsh:mykeyspace> select * from readings limit 10;
      
       sensor_id | time                            | status | temperature
      -----------+---------------------------------+--------+-------------
               5 | 2016-08-24 19:11:34.896000+0000 |     OK |        9.97
               5 | 2016-08-24 19:11:43.933000+0000 |     OK |       10.28
               5 | 2016-08-24 19:11:49.958000+0000 |     OK |        7.65
               5 | 2016-08-24 19:11:51.968000+0000 |     OK |       10.11
               5 | 2016-08-24 19:12:58.512000+0000 |  Fault |       10.41
               5 | 2016-08-24 19:13:04.542000+0000 |     OK |        9.66
               5 | 2016-08-24 19:13:16.593000+0000 |     OK |        10.9
               5 | 2016-08-24 19:13:37.692000+0000 |     OK |        11.2
               5 | 2016-08-24 19:13:46.738000+0000 |     OK |       10.34
               5 | 2016-08-24 19:13:49.757000+0000 |     OK |        10.6
      

      I'm running a query every few seconds with my UDA - like this (timestamps are different each time):

      select avg(temperature), stdev(temperature) from readings where sensor_id = 1 and time > 1472066523193;
      

      Most of the time, this works just fine:

      cqlsh:mykeyspace> select avg(temperature), stdev(temperature) from readings where sensor_id = 1 and time > 1472066523193;
      
       system.avg(temperature) | mykeyspace.stdev(temperature)
      -------------------------+-------------------------------
                        9.9291 |                       0.94179
      
      (1 rows)
      

      But, occasionally, it fails with one of two exceptions:

      cqlsh:mykeyspace> select avg(temperature), stdev(temperature) from readings where sensor_id = 1 and time > 1472066523193;
      Traceback (most recent call last):
        File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1277, in perform_simple_statement
          result = future.result()
        File "cassandra/cluster.py", line 3629, in cassandra.cluster.ResponseFuture.result (cassandra/cluster.c:69369)
          raise self._final_exception
      FunctionFailure: Error from server: code=1400 [User Defined Function failure] message="execution of 'mykeyspace.sdstate[frozen<tuple<int, double, double>>, double]' failed: java.security.AccessControlException: access denied ("java.io.FilePermission" "/usr/local/etc/cassandra/logback.xml" "read")"
      

      or

      cqlsh:mykeyspace> select count(*), avg(temperature), stdev(temperature) from readings where sensor_id = 1 and time > '2016-08-24 15:00:00.000+0000';
      Traceback (most recent call last):
        File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1277, in perform_simple_statement
          result = future.result()
        File "cassandra/cluster.py", line 3629, in cassandra.cluster.ResponseFuture.result (cassandra/cluster.c:69369)
          raise self._final_exception
      FunctionFailure: Error from server: code=1400 [User Defined Function failure] message="execution of 'mykeyspace.sdstate[frozen<tuple<int, double, double>>, double]' failed: com.datastax.driver.core.exceptions.CodecNotFoundException"
      

      The next query usually works ok.

      I don't see any clues in /usr/local/var/log/cassandra/system.log

      If I can pin it down more, I'll post follow-up comments.

      Attachments

        Issue Links

          Activity

            People

              snazy Robert Stupp
              metadaddy Pat Patterson
              Robert Stupp
              Carl Yeksigian
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: