我在RHEL上使用Cassandra 3.11。我完全按照here所述定义了一个UDF。
CREATE OR REPLACE FUNCTION maxOf(current int, testvalue int)
CALLED ON NULL INPUT
RETURNS int
LANGUAGE java
AS $$return Math.max(current,testvalue);$$;
我能够创建UDF。但是当我运行以下查询时:
SELECT id,val1,val2,maxOf(val1,val2) FROM test WHERE id IN(1,2,3);
我收到以下错误:
com.datastax.driver.core.exceptions.FunctionExecutionException: execution of 'srm.maxof[int, int]'
failed: java.lang.RuntimeException: java.lang.StackOverflowError: operating system stack overflow
我已在enable_user_defined_functions: true
的所有节点上设置了cassandra.yaml
。
这是来自system.log的一个片段,其中包含JVM -X参数:
-XX:+UseThreadPriorities, -XX:ThreadPriorityPolicy=42, -XX:+HeapDumpOnOutOfMemoryError, -Xss512k, -XX:StringTableSize=1000003, -XX:+AlwaysPreTouch, -XX:-UseBiasedLocking, -XX:+UseTLAB, -XX:+ResizeTLAB, -XX:+UseNUMA, -XX:+PerfDisableSharedMem, -Djava.net.preferIPv4Stack=true, -XX:+UseParNewGC, -XX:+UseConcMarkSweepGC, -XX:+CMSParallelRemarkEnabled, -XX:SurvivorRatio=8, -XX:MaxTenuringThreshold=1, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:CMSWaitDuration=10000, -XX:+CMSParallelInitialMarkEnabled, -XX:+CMSEdenChunksRecordAlways, -XX:+CMSClassUnloadingEnabled, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintHeapAtGC, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -XX:+PrintPromotionFailure, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=10, -XX:GCLogFileSize=10M, -Xms8192M, -Xmx8192M, -Xmn2048M
仅在使用IBM JRE时才会发生这种情况。适用于Oracle JRE。
这是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]
[Previous 5 lines repeat 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
我缺少一些配置吗?我是否需要增加一些堆栈大小参数?
答案 0 :(得分:0)
默认情况下,自Cassandra 3.0起禁用UDF。要启用它们,您需要在enable_user_defined_functions: true
文件中设置cassandra.yaml
。