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

When phoenix.allow.system.catalog.rollback=true, a view still sees data from a column that was dropped

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 5.0.0, 4.15.0
    • 5.1.0, 4.16.0
    • None
    • None

    Description

      Start a 4.x server with phoenix.allow.system.catalog.rollback=true, phoenix.system.catalog.splittable=false. Connect to it from a 4.x client with phoenix.allow.system.catalog.rollback=true. Run the following from the 4.x client:

      CREATE TABLE IF NOT EXISTS T (A INTEGER PRIMARY KEY, B INTEGER, C VARCHAR, D INTEGER);
      CREATE VIEW IF NOT EXISTS V (VA INTEGER, VB INTEGER) AS SELECT * FROM T WHERE B=200;
      UPSERT INTO V(A,B,C,D,VA,VB) VALUES (2, 200, 'def', -20, 91, 101);
      
      SELECT * FROM T;
      +----+------+------+------+
      | A  |  B   |  C   |  D   |
      +----+------+------+------+
      | 2  | 200  | def  | -20  |
      +----+------+------+------+
      
      SELECT * FROM V;
      +----+------+------+------+-----+------+
      | A  |  B   |  C   |  D   | VA  |  VB  |
      +----+------+------+------+-----+------+
      | 2  | 200  | def  | -20  | 91  | 101  |
      +----+------+------+------+-----+------+
      -- as expected
      -- drop a parent column from the view
      ALTER VIEW V DROP COLUMN C;
      
      SELECT * FROM V;
      +------+----+------+------+-----+------+
      |  C   | A  |  B   |  D   | VA  |  VB  |
      +------+----+------+------+-----+------+
      | def  | 2  | 200  | -20  | 91  | 101  |
      +------+----+------+------+-----+------+
      -- Column C can still be seen and its ordering is changed for some reason. If you run the drop column again, it is actually dropped
      ALTER VIEW V DROP COLUMN C;
      
      SELECT * FROM V;
      +----+------+------+-----+------+
      | A  |  B   |  D   | VA  |  VB  |
      +----+------+------+-----+------+
      | 2  | 200  | -20  | 91  | 101  |
      +----+------+------+-----+------+
      -- Gets dropped when drop column is run a second time.
      

      When splittable SYSTEM.CATALOG rollback is enabled, we store the parent's column metadata along with the view as well. After the first drop column command, metadata for column 'C' of the parent is removed from the view's metadata rows however it is not marked diverged, nor is an EXCLUDED_COLUMN entry made for that column in the view metadata rows.
      Because of this, when resolving the view we potentially keep combining the parent table columns and still get column 'C'. When the second drop column command is issued is when we actually add an EXCLUDED_COLUMN linking row for 'C' in the view metadata.

      Attachments

        1. PHOENIX-6032.master.v6.patch
          31 kB
          Chinmay Kulkarni
        2. PHOENIX-6032.master.v5.patch
          31 kB
          Chinmay Kulkarni
        3. PHOENIX-6032.master.v4.patch
          30 kB
          Chinmay Kulkarni
        4. PHOENIX-6032.master.v3.patch
          30 kB
          Chinmay Kulkarni
        5. PHOENIX-6032.master.v2.patch
          30 kB
          Chinmay Kulkarni
        6. PHOENIX-6032.master.v1.patch
          30 kB
          Chinmay Kulkarni

        Issue Links

          Activity

            People

              ckulkarni Chinmay Kulkarni
              ckulkarni Chinmay Kulkarni
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: