Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CFFB5200BB3 for ; Wed, 2 Nov 2016 11:14:02 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CEBD6160AEA; Wed, 2 Nov 2016 10:14:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EEDDD160B0A for ; Wed, 2 Nov 2016 11:14:01 +0100 (CET) Received: (qmail 17419 invoked by uid 500); 2 Nov 2016 10:14:00 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 17181 invoked by uid 99); 2 Nov 2016 10:14:00 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2016 10:14:00 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id F21EC2C2A66 for ; Wed, 2 Nov 2016 10:13:59 +0000 (UTC) Date: Wed, 2 Nov 2016 10:13:59 +0000 (UTC) From: "chenglei (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (PHOENIX-3208) MutationState.toMutations method would throw a exception if multiple tables are upserted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 02 Nov 2016 10:14:03 -0000 [ https://issues.apache.org/jira/browse/PHOENIX-3208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] chenglei updated PHOENIX-3208: ------------------------------ Description: MutationState.toMutations method is to return the current uncommitted tables mutations , but if multiple tables have been upserted , the toMutations method would throw a exception: {code:borderStyle=solid} java.util.NoSuchElementException at com.google.common.collect.Iterators$1.next(Iterators.java:77) at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:584) at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:1) at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:710) at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:1) at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:732) at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:1) at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:354) at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:1) {code} I write a simple unit test to reproduce this problem in my patch,the PhoenixRuntime.getUncommittedDataIterator method internally uses the MutationState.toMutations method: {code:borderStyle=solid} @Test public void testToMutationsError() throws Exception { Connection conn = null; try { conn=DriverManager.getConnection(getUrl()); conn.createStatement().execute( "create table MUTATION_TEST1"+ "( id1 UNSIGNED_INT not null primary key,"+ "appId1 VARCHAR)"); conn.createStatement().execute( "create table MUTATION_TEST2"+ "( id2 UNSIGNED_INT not null primary key,"+ "appId2 VARCHAR)"); conn.createStatement().execute("upsert into MUTATION_TEST1(id1,appId1) values(111,'app1')"); conn.createStatement().execute("upsert into MUTATION_TEST2(id2,appId2) values(222,'app2')"); Iterator>> dataTableNameAndMutationKeyValuesIter = PhoenixRuntime.getUncommittedDataIterator(conn); assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); Pair> pair=dataTableNameAndMutationKeyValuesIter.next(); String tableName1=Bytes.toString(pair.getFirst()); List keyValues1=pair.getSecond(); assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); pair=dataTableNameAndMutationKeyValuesIter.next(); String tableName2=Bytes.toString(pair.getFirst()); List keyValues2=pair.getSecond(); if("MUTATION_TEST1".equals(tableName1)) { assertTable(tableName1, keyValues1, tableName2, keyValues2); } else { assertTable(tableName2, keyValues2, tableName1, keyValues1); } assertTrue(!dataTableNameAndMutationKeyValuesIter.hasNext()); } finally { if(conn!=null) { conn.close(); } } } {code} was: MutationState.toMutations method is to return the current uncommitted table's mutations , but if multiple tables have been upserted , the toMutations method would throw a exception: {code:borderStyle=solid} java.util.NoSuchElementException at com.google.common.collect.Iterators$1.next(Iterators.java:77) at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:584) at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:1) at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:710) at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:1) at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:732) at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:1) at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:354) at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:1) {code} I write a simple unit test to reproduce this problem in my patch,the PhoenixRuntime.getUncommittedDataIterator method internally uses the MutationState.toMutations method: {code:borderStyle=solid} @Test public void testToMutationsError() throws Exception { Connection conn = null; try { conn=DriverManager.getConnection(getUrl()); conn.createStatement().execute( "create table MUTATION_TEST1"+ "( id1 UNSIGNED_INT not null primary key,"+ "appId1 VARCHAR)"); conn.createStatement().execute( "create table MUTATION_TEST2"+ "( id2 UNSIGNED_INT not null primary key,"+ "appId2 VARCHAR)"); conn.createStatement().execute("upsert into MUTATION_TEST1(id1,appId1) values(111,'app1')"); conn.createStatement().execute("upsert into MUTATION_TEST2(id2,appId2) values(222,'app2')"); Iterator>> dataTableNameAndMutationKeyValuesIter = PhoenixRuntime.getUncommittedDataIterator(conn); assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); Pair> pair=dataTableNameAndMutationKeyValuesIter.next(); String tableName1=Bytes.toString(pair.getFirst()); List keyValues1=pair.getSecond(); assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); pair=dataTableNameAndMutationKeyValuesIter.next(); String tableName2=Bytes.toString(pair.getFirst()); List keyValues2=pair.getSecond(); if("MUTATION_TEST1".equals(tableName1)) { assertTable(tableName1, keyValues1, tableName2, keyValues2); } else { assertTable(tableName2, keyValues2, tableName1, keyValues1); } assertTrue(!dataTableNameAndMutationKeyValuesIter.hasNext()); } finally { if(conn!=null) { conn.close(); } } } {code} > MutationState.toMutations method would throw a exception if multiple tables are upserted > ----------------------------------------------------------------------------------------- > > Key: PHOENIX-3208 > URL: https://issues.apache.org/jira/browse/PHOENIX-3208 > Project: Phoenix > Issue Type: Bug > Affects Versions: 4.8.0 > Reporter: chenglei > Attachments: PHOENIX-3208.patch > > > MutationState.toMutations method is to return the current uncommitted tables mutations , but if multiple tables have been upserted , the toMutations method would throw a exception: > {code:borderStyle=solid} > java.util.NoSuchElementException > at com.google.common.collect.Iterators$1.next(Iterators.java:77) > at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:584) > at org.apache.phoenix.execute.MutationState$1.next(MutationState.java:1) > at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:710) > at org.apache.phoenix.execute.MutationState$2$1.next(MutationState.java:1) > at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:732) > at org.apache.phoenix.execute.MutationState$2.next(MutationState.java:1) > at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:354) > at org.apache.phoenix.util.PhoenixRuntime$1.next(PhoenixRuntime.java:1) > {code} > > I write a simple unit test to reproduce this problem in my patch,the PhoenixRuntime.getUncommittedDataIterator method internally uses the MutationState.toMutations method: > {code:borderStyle=solid} > @Test > public void testToMutationsError() throws Exception { > Connection conn = null; > try { > conn=DriverManager.getConnection(getUrl()); > conn.createStatement().execute( > "create table MUTATION_TEST1"+ > "( id1 UNSIGNED_INT not null primary key,"+ > "appId1 VARCHAR)"); > conn.createStatement().execute( > "create table MUTATION_TEST2"+ > "( id2 UNSIGNED_INT not null primary key,"+ > "appId2 VARCHAR)"); > conn.createStatement().execute("upsert into MUTATION_TEST1(id1,appId1) values(111,'app1')"); > conn.createStatement().execute("upsert into MUTATION_TEST2(id2,appId2) values(222,'app2')"); > Iterator>> dataTableNameAndMutationKeyValuesIter = > PhoenixRuntime.getUncommittedDataIterator(conn); > assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); > Pair> pair=dataTableNameAndMutationKeyValuesIter.next(); > String tableName1=Bytes.toString(pair.getFirst()); > List keyValues1=pair.getSecond(); > assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext()); > pair=dataTableNameAndMutationKeyValuesIter.next(); > String tableName2=Bytes.toString(pair.getFirst()); > List keyValues2=pair.getSecond(); > if("MUTATION_TEST1".equals(tableName1)) { > assertTable(tableName1, keyValues1, tableName2, keyValues2); > } > else { > assertTable(tableName2, keyValues2, tableName1, keyValues1); > } > assertTrue(!dataTableNameAndMutationKeyValuesIter.hasNext()); > } > finally { > if(conn!=null) { > conn.close(); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)