[ https://issues.apache.org/jira/browse/CASSANDRA-12535?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joshua McKenzie updated CASSANDRA-12535: ---------------------------------------- Reviewer: Carl Yeksigian > Occasionally seeing AccessControlException, CodecNotFoundException when > executing a User Defined Aggregate > ---------------------------------------------------------------------------------------------------------- > > Key: CASSANDRA-12535 > URL: https://issues.apache.org/jira/browse/CASSANDRA-12535 > Project: Cassandra > Issue Type: Bug > Environment: Cassandra 3.7 (via brew install), Mac OS X 10.11.6 > Reporter: Pat Patterson > Assignee: Robert Stupp > Priority: Minor > Fix For: 3.0.x, 3.x > > > I have defined a UDA to implement standard deviation: > {noformat} > 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); > {noformat} > My table: > {noformat} > CREATE TABLE readings ( > sensor_id int, > time timestamp, > temperature double, > status text, > PRIMARY KEY (sensor_id, time) > ) WITH CLUSTERING ORDER BY (time ASC); > {noformat} > I'm inserting a row every 0.1 seconds. The data looks like this: > {noformat} > 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 > {noformat} > I'm running a query every few seconds with my UDA - like this (timestamps are > different each time): > {noformat} > select avg(temperature), stdev(temperature) from readings where sensor_id = 1 > and time > 1472066523193; > {noformat} > Most of the time, this works just fine: > {noformat} > 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) > {noformat} > But, occasionally, it fails with one of two exceptions: > {noformat} > 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")" > {noformat} > or > {noformat} > 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" > {noformat} > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)