You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "chenglei (JIRA)" <ji...@apache.org> on 2016/08/25 16:03:20 UTC

[jira] [Updated] (PHOENIX-3208) MutationState.toMutations method would throw a exception if multiple tables are upserted

     [ 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 table's mutations , but if multiple tables have been upserted , the toMutations method would throw a exception.
        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<Pair<byte[],List<KeyValue>>> dataTableNameAndMutationKeyValuesIter =
                    PhoenixRuntime.getUncommittedDataIterator(conn);


            assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
            Pair<byte[],List<KeyValue>> pair=dataTableNameAndMutationKeyValuesIter.next();
            String tableName1=Bytes.toString(pair.getFirst());
            List<KeyValue> keyValues1=pair.getSecond();

            assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
            pair=dataTableNameAndMutationKeyValuesIter.next();
            String tableName2=Bytes.toString(pair.getFirst());
            List<KeyValue> 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,I write a simple unit test to reproduce this problem in my patch:

{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<Pair<byte[],List<KeyValue>>> dataTableNameAndMutationKeyValuesIter =
                    PhoenixRuntime.getUncommittedDataIterator(conn);


            assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
            Pair<byte[],List<KeyValue>> pair=dataTableNameAndMutationKeyValuesIter.next();
            String tableName1=Bytes.toString(pair.getFirst());
            List<KeyValue> keyValues1=pair.getSecond();

            assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
            pair=dataTableNameAndMutationKeyValuesIter.next();
            String tableName2=Bytes.toString(pair.getFirst());
            List<KeyValue> 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
>
>         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.
>         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<Pair<byte[],List<KeyValue>>> dataTableNameAndMutationKeyValuesIter =
>                     PhoenixRuntime.getUncommittedDataIterator(conn);
>             assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
>             Pair<byte[],List<KeyValue>> pair=dataTableNameAndMutationKeyValuesIter.next();
>             String tableName1=Bytes.toString(pair.getFirst());
>             List<KeyValue> keyValues1=pair.getSecond();
>             assertTrue(dataTableNameAndMutationKeyValuesIter.hasNext());
>             pair=dataTableNameAndMutationKeyValuesIter.next();
>             String tableName2=Bytes.toString(pair.getFirst());
>             List<KeyValue> 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)