Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-4743

ALTER TABLE ADD COLUMN for global index should not modify HBase metadata if failed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.15.0, 5.1.0
    • None

    Description

      When you issue an "ALTER TABLE" for a global index to add a column, Phoenix throws a SQLException, but the HBase metadata for the global index table is still modified.

      Steps to reproduce:

      • Create the base data table: 
        create table if not exists z_base_table (id INTEGER not null primary key, host VARCHAR(10), flag boolean);
      • Create a global index on top of this table: 
        create index global_z_index on z_base_table(HOST);
      • Add a column to the global index table:
        alter table global_z_index add cf1.age INTEGER;

      This will throw an exception in Phoenix, but HBase metadata for the global index table is still modified. Stack trace:

      Error: ERROR 1010 (42M01): Not allowed to mutate table. Cannot add/drop column referenced by VIEW columnName=GLOBAL_Z_INDEX (state=42M01,code=1010)
       java.sql.SQLException: ERROR 1010 (42M01): Not allowed to mutate table. Cannot add/drop column referenced by VIEW columnName=GLOBAL_Z_INDEX
       at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:494)
       at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:150)
       at org.apache.phoenix.schema.MetaDataClient.processMutationResult(MetaDataClient.java:3049)
       at org.apache.phoenix.schema.MetaDataClient.addColumn(MetaDataClient.java:3503)
       at org.apache.phoenix.schema.MetaDataClient.addColumn(MetaDataClient.java:3210)
       at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableAddColumnStatement$1.execute(PhoenixStatement.java:1432)
       at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:408)
       at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:391)
       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
       at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:390)
       at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:378)
       at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1825)
       at sqlline.Commands.execute(Commands.java:822)
       at sqlline.Commands.sql(Commands.java:732)
       at sqlline.SqlLine.dispatch(SqlLine.java:813)
       at sqlline.SqlLine.begin(SqlLine.java:686)
       at sqlline.SqlLine.start(SqlLine.java:398)
       at sqlline.SqlLine.main(SqlLine.java:291

       

      Attachments

        1. PHOENIX-4743.patch
          5 kB
          Sandeep Pal
        2. PHOENIX-4743.v1.patch
          5 kB
          Sandeep Pal
        3. PHOENIX-4743.v3.patch
          6 kB
          Sandeep Pal
        4. PHOENIX-4743-4.x-HBase-1.3.patch
          5 kB
          Sandeep Pal

        Issue Links

          Activity

            People

              sandeep.pal Sandeep Pal
              ckulkarni Chinmay Kulkarni
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2.5h
                  2.5h