Announcement

Collapse
No announcement yet.

Successfully wrote a testcase . The testcase made a Exception to the VoltDB. What should I do next?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Successfully wrote a testcase . The testcase made a Exception to the VoltDB. What should I do next?

    Code:
    /* This file is part of VoltDB.
     * Copyright (C) 2008-2014 VoltDB Inc.
     *
     * Permission is hereby granted, free of charge, to any person obtaining
     * a copy of this software and associated documentation files (the
     * "Software"), to deal in the Software without restriction, including
     * without limitation the rights to use, copy, modify, merge, publish,
     * distribute, sublicense, and/or sell copies of the Software, and to
     * permit persons to whom the Software is furnished to do so, subject to
     * the following conditions:
     *
     * The above copyright notice and this permission notice shall be
     * included in all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     * OTHER DEALINGS IN THE SOFTWARE.
     */
    
    package org.voltdb.regressionsuites;
    
    import java.io.IOException;
    
    import org.voltdb.BackendTarget;
    import org.voltdb.VoltTable;
    import org.voltdb.client.Client;
    import org.voltdb.client.ClientResponse;
    import org.voltdb.client.ProcCallException;
    import org.voltdb.compiler.VoltProjectBuilder;
    
    public class TestMaxInSuite extends RegressionSuite {
    
    	static final Class<?>[] PROCEDURES = {};
    
    	public TestMaxInSuite(String name) {
    		super(name);
    	}
    
    	public void testMaxIn() throws Exception {
    		final Client client = this.getClient();
    
    		ClientResponse resp = null;
    		for (int i = 0; i < 10; i++) {
    			resp = client.callProcedure("P1.insert", i, i);
    			assertEquals(ClientResponse.SUCCESS, resp.getStatus());
    		}
    
    		StringBuilder stringBuilder = new StringBuilder(
    				"select * from p1 where a2 in(");
    		for (int i = 0; i < 10000; i++) {
    			stringBuilder.append(i);
    			if (i != 9999) {
    				stringBuilder.append(",");
    			}
    		}
    		stringBuilder.append(");");
    		resp = client.callProcedure("@AdHoc", stringBuilder.toString());
    		assertEquals(ClientResponse.SUCCESS, resp.getStatus());
    
    		assertEquals(1, resp.getResults().length);
    		VoltTable results = resp.getResults()[0];
    
    		System.out.println(results.getRowCount());
    		System.out.println(results.getColumnCount());
    		System.out.println(results.fetchRow(0).getLong(0));
    
    		assertEquals(10, results.getRowCount());
    		assertEquals(2, results.getColumnCount());
    		assertEquals(0, results.fetchRow(0).getLong(0));
    	}
    
    	static public junit.framework.Test suite() {
    		VoltServerConfig config = null;
    		final MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(
    				TestMaxInSuite.class);
    
    		final VoltProjectBuilder project = new VoltProjectBuilder();
    
    		project.addStmtProcedure("CountP1", "select count(*) from p1;");
    		// project.addStmtProcedure("CountR1", "select count(*) from r1;");//if
    		// r1 doesn't exist , exception
    
    		try {
    			// a table that should generate procedures
    			// use column names such that lexical order != column order.
    			project.addLiteralSchema("CREATE TABLE p1(b1 INTEGER NOT NULL, a2 INTEGER NOT NULL, PRIMARY KEY (b1));");
    			project.addPartitionInfo("p1", "b1");
    
    		} catch (IOException error) {
    			fail(error.getMessage());
    		}
    
    		// JNI
    		config = new LocalCluster("testMax-onesite.jar", 1, 1, 0,
    				BackendTarget.NATIVE_EE_JNI);
    		boolean t1 = config.compile(project);
    		assertTrue(t1);
    		builder.addServerConfig(config);
    
    		// CLUSTER
    		config = new LocalCluster("testMax-cluster.jar", 2, 3, 1,
    				BackendTarget.NATIVE_EE_JNI);
    		boolean t2 = config.compile(project);
    		assertTrue(t2);
    		builder.addServerConfig(config);
    
    		return builder;
    	}
    }



    org.voltdb.client.ProcCallException: VOLTDB ERROR: UNEXPECTED FAILURE:
    java.lang.NegativeArraySizeException
    at org.voltdb.compiler.AdHocPlannedStatement.fromBuff er(AdHocPlannedStatement.java:130)
    at org.voltdb.compiler.AdHocPlannedStmtBatch.planArra yFromBuffer(AdHocPlannedStmtBatch.java:309)
    at org.voltdb.sysprocs.AdHocBase.runAdHoc(AdHocBase.j ava:82)
    at org.voltdb.sysprocs.AdHoc_RO_MP.run(AdHoc_RO_MP.ja va:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.voltdb.ProcedureRunner.call(ProcedureRunner.ja va:316)
    at org.voltdb.iv2.ProcedureTask.processInitiateTask(P rocedureTask.java:111)
    at org.voltdb.iv2.MpProcedureTask.run(MpProcedureTask .java:157)
    at org.voltdb.iv2.MpRoSite.run(MpRoSite.java:278)
    at org.voltcore.utils.CoreUtils$7$1.run(CoreUtils.jav a:644)
    at java.lang.Thread.run(Thread.java:745)

    at org.voltdb.client.ClientImpl.callProcedure(ClientI mpl.java:270)
    at org.voltdb.client.ClientImpl.callProcedureWithTime out(ClientImpl.java:224)
    at org.voltdb.client.ClientImpl.callProcedure(ClientI mpl.java:204)
    at org.voltdb.regressionsuites.TestMaxInSuite.testMax In(TestMaxInSuite.java:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at junit.framework.TestCase.runTest(TestCase.java:168 )
    at junit.framework.TestCase.runBare(TestCase.java:134 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:110)
    at junit.framework.TestResult.runProtected(TestResult .java:128)
    at junit.framework.TestResult.run(TestResult.java:113 )
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 43)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.junit.internal.runners.JUnit38ClassRunner.run( JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:192)
    Last edited by guotong1988; 10-27-2014, 11:38 PM.

  • #2
    And is there some bug in my testcase ?

    Comment


    • #3
      Tong,

      That's a nice stress JUit test and I think you find the first bug in VoltDB. I logged a bug ticket in your JIRA system: https://issues.voltdb.com/browse/ENG-7086

      org.voltdb.client.ProcCallException: VOLTDB ERROR: UNEXPECTED FAILURE:
      java.lang.NegativeArraySizeException
      at org.voltdb.compiler.AdHocPlannedStatement.fromBuff er(AdHocPlannedStatement.java:130)

      Code:
      // sql bytes
      short sqlLength = buf.getShort();
      byte[] sql = new byte[sqlLength];

      You construct a query with 48,900 bytes but we use the JAVA short type (max value is 32,767) to store the sql length. We forget to check the negative length before constructing the byte array.

      What you can do now :
      1) Reduce your parameter from 10,000 to 7,000, then it will work. Or
      2) is to change the source code to use a INTEGER or LONG type and test it from there.

      A very very long SQL is not common and not tested before.

      Thanks,
      Xin

      Comment

      Working...
      X