I'm using Cassandra 3.11 right out of the box (i.e. all default parameters) 
with the IBM JRE. Using any UDF results in a stack overflow error. They work 
fine with the Oracle JVM. I've tried increasing some stack sizes (-Xss and 
-Xmso), but that does not help. Is there some configuration I'm missing?

CREATE TABLE test (
    id int,
    val1 int,
    val2 int,
    PRIMARY KEY(id)
);

INSERT INTO test(id, val1, val2) VALUES(1, 100, 200);
INSERT INTO test(id, val1, val2) VALUES(2, 100, 300);
INSERT INTO test(id, val1, val2) VALUES(3, 200, 150);

CREATE OR REPLACE FUNCTION maxOf(current int, testvalue int) 
CALLED ON NULL INPUT 
RETURNS int
LANGUAGE java 
AS $$return Math.max(current,testvalue);$$;

SELECT id, val1, val2, maxOf(val1,val2) FROM test WHERE id = 1;

Here's the stack trace from debug.log:
java.lang.RuntimeException: java.lang.StackOverflowError
    at 
org.apache.cassandra.cql3.functions.UDFunction.async(UDFunction.java:453) 
~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.functions.UDFunction.executeAsync(UDFunction.java:398)
 ~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.functions.UDFunction.execute(UDFunction.java:298) 
~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.selection.ScalarFunctionSelector.getOutput(ScalarFunctionSelector.java:61)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.selection.Selection$SelectionWithProcessing$1.getOutputRow(Selection.java:592)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.getOutputRow(Selection.java:430)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.build(Selection.java:417)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:763)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:400)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:378)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:251)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:79)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:217)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:248) 
[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:233) 
[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:116)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:517)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:410)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at 
io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
 [netty-all-4.0.44.Final.jar:4.0.44.Final]
    at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
 [netty-all-4.0.44.Final.jar:4.0.44.Final]
    at 
io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:35)
 [netty-all-4.0.44.Final.jar:4.0.44.Final]
    at 
io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:348)
 [netty-all-4.0.44.Final.jar:4.0.44.Final]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522) 
[na:1.8.0]
    at 
org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162)
 [apache-cassandra-3.11.0.jar:3.11.0]
    at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) 
[apache-cassandra-3.11.0.jar:3.11.0]
    at java.lang.Thread.run(Thread.java:795) [na:2.9 (09-01-2017)]
Caused by: java.lang.StackOverflowError: null
    at java.lang.String.substring(String.java:2637) ~[na:2.9 (09-01-2017)]
    at java.lang.Class.getNonArrayClassPackageName(Class.java:1531) ~[na:2.9 
(09-01-2017)]
    at java.lang.Class.getPackageName(Class.java:1546) ~[na:2.9 (09-01-2017)]
    at java.lang.J9VMInternals$2.run(J9VMInternals.java:252) ~[na:2.9 
(09-01-2017)]
    at java.security.AccessController.doPrivileged(AccessController.java:647) 
~[na:1.8.0]
    at java.lang.J9VMInternals.checkPackageAccess(J9VMInternals.java:250) 
~[na:2.9 (09-01-2017)]
    at 
org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.isSecuredThread(ThreadAwareSecurityManager.java:210)
 ~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.checkPackageAccess(ThreadAwareSecurityManager.java:259)
 ~[apache-cassandra-3.11.0.jar:3.11.0]
    at java.lang.J9VMInternals$2.run(J9VMInternals.java:254) ~[na:2.9 
(09-01-2017)]
    at java.security.AccessController.doPrivileged(AccessController.java:647) 
~[na:1.8.0]
    at java.lang.J9VMInternals.checkPackageAccess(J9VMInternals.java:250) 
~[na:2.9 (09-01-2017)]
    at 
org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.isSecuredThread(ThreadAwareSecurityManager.java:210)
 ~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.checkPackageAccess(ThreadAwareSecurityManager.java:259)
 ~[apache-cassandra-3.11.0.jar:3.11.0]

    [previous 5 lines repeated many times]
    at java.lang.J9VMInternals$2.run(J9VMInternals.java:254) ~[na:2.9 
(09-01-2017)]
    at java.security.AccessController.doPrivileged(AccessController.java:647) 
~[na:1.8.0]
    at java.lang.J9VMInternals.checkPackageAccess(J9VMInternals.java:250) 
~[na:2.9 (09-01-2017)]
    at 
org.apache.cassandra.cql3.functions.UDFunction$$Lambda$277.00000000154A7350.call(Unknown
 Source) ~[na:na]
    at java.util.concurrent.FutureTask.run(FutureTask.java:277) ~[na:1.8.0]
    at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160) 
~[na:1.8.0]
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 
~[na:1.8.0]
    at 
org.apache.cassandra.concurrent.NamedThreadFactory.lambda$threadLocalDeallocator$0(NamedThreadFactory.java:81)
 ~[apache-cassandra-3.11.0.jar:3.11.0]
    at 
org.apache.cassandra.concurrent.NamedThreadFactory$$Lambda$12.0000000013A22FB0.run(Unknown
 Source) ~[na:na]
    ... 1 common frames omitted


Reply via email to