背景:
今天在链接phoenix,使用delete语句删除表内容时,报了如下错误。
org.apache.phoenix.exception.PhoenixIOException: MutationState size of 519340 is bigger than max allowed size of 500000
at org.apache.phoenix.util.ServerUtil.parseServerException(ServerUtil.java:111)
at org.apache.phoenix.iterate.RoundRobinResultIterator.close(RoundRobinResultIterator.java:128)
at org.apache.phoenix.compile.DeleteCompiler$3.execute(DeleteCompiler.java:684)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:343)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:331)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:329)
at org.apache.phoenix.jdbc.PhoenixPreparedStatement.executeUpdate(PhoenixPreparedStatement.java:199)
at com.ngaa.test.execute.TestPhoenixMonitorResult.testDeleteInfo(TestPhoenixMonitorResult.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalArgumentException: MutationState size of 519340 is bigger than max allowed size of 500000
at org.apache.phoenix.execute.MutationState.throwIfTooBig(MutationState.java:438)
at org.apache.phoenix.execute.MutationState.join(MutationState.java:530)
at org.apache.phoenix.compile.MutatingParallelIteratorFactory$1.close(MutatingParallelIteratorFactory.java:98)
at org.apache.phoenix.iterate.BaseResultIterators.close(BaseResultIterators.java:879)
at org.apache.phoenix.iterate.RoundRobinResultIterator.close(RoundRobinResultIterator.java:125)
... 34 more
查看官方说明,发现需要在获取链接时修改默认的值,避免出现错误。
解决如下:
代码实现
Properties connectionProperties = new Properties();
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB,"
10000000
"); //改变默认的500000
connectionProperties.setProperty(QueryServices.IMMUTABLE_ROWS_ATTRIB,"
10000000
"); // 默认是500000
connection = DriverManager.getConnection("jdbc:phoenix:ulvdtlchd01:2181",connectionProperties);
从而引出了org.apache.phoenix.query.QueryServices.java这个类,内容如下:
https://code.csdn.net/snippets/2601969
参考链接:
https://issues.apache.org/jira/browse/PHOENIX-956
http://apache-phoenix-user-list.1124778.n5.nabble.com/simple-commands-that-mutate-a-large-number-of-rows-td96.html
http://secfree.github.io/blog/2015/11/17/phoenix-client-threads-number-control.html