phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-3534) Support multi region SYSTEM.CATALOG table
Date Wed, 30 May 2018 23:04:00 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-3534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16495849#comment-16495849
] 

ASF GitHub Bot commented on PHOENIX-3534:
-----------------------------------------

Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/303#discussion_r191948821
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java ---
    @@ -388,51 +435,65 @@ public void testViewAndTableInDifferentSchemas(boolean isNamespaceMapped)
throws
             } catch (TableNotFoundException ignore) {
             }
             ddl = "DROP TABLE " + fullTableName1;
    -        validateCannotDropTableWithChildViewsWithoutCascade(conn, fullTableName1);
             ddl = "DROP VIEW " + fullViewName2;
             conn.createStatement().execute(ddl);
             ddl = "DROP TABLE " + fullTableName1;
             conn.createStatement().execute(ddl);
         }
     
    -    
    +
         @Test
    -    public void testDisallowDropOfColumnOnParentTable() throws Exception {
    +    public void testDropOfColumnOnParentTableInvalidatesView() throws Exception {
             Connection conn = DriverManager.getConnection(getUrl());
    +        String fullTableName = generateUniqueTableName();
    +        String viewName = generateUniqueViewName();
    +        splitSystemCatalog(Lists.newArrayList(fullTableName, viewName));
    +
             String ddl = "CREATE TABLE " + fullTableName + " (k1 INTEGER NOT NULL, k2 INTEGER
NOT NULL, v1 DECIMAL, CONSTRAINT pk PRIMARY KEY (k1, k2))" + tableDDLOptions;
             conn.createStatement().execute(ddl);
    -        String viewName = "V_" + generateUniqueName();
             ddl = "CREATE VIEW " + viewName + "(v2 VARCHAR, v3 VARCHAR) AS SELECT * FROM
" + fullTableName + " WHERE v1 = 1.0";
             conn.createStatement().execute(ddl);
             
    -        try {
    -            conn.createStatement().execute("ALTER TABLE " + fullTableName + " DROP COLUMN
v1");
    -            fail();
    -        } catch (SQLException e) {
    -            assertEquals(SQLExceptionCode.CANNOT_MUTATE_TABLE.getErrorCode(), e.getErrorCode());
    +        conn.createStatement().execute("ALTER TABLE " + fullTableName + " DROP COLUMN
v1");
    +        // TODO see if its possibel to prevent the dropping of a column thats required
by a child view (for its view where clause)
    +        // the view should be invalid
    --- End diff --
    
    I was thinking of handling the race condition by writing a cell using checkAndPut with
the column name being mutated (added or dropped) to the header row of the base table. When
a view is create the columns used in the view where clause will also do a checkAndPut on this
cell in the base table. If this is happening concurrently only of the clients will succeed
(either the drop column, or the view creation). 
    
    If a DROP TABLE cascade is issued then the base table (with child views) is dropped. When
any child views are resolved and we see the base table does not exists we throw a TableNotFoundException.
If the DROP VIEW is issued without CASCADE and there are child views the statement fails with
a not allowed to mutate exception. If a drop table without cascade and a create view happens
concurrently we could create the view even though the base table would have been dropped,
but the next time the view is resolved you would get a TableNotFoundException.   


> Support multi region SYSTEM.CATALOG table
> -----------------------------------------
>
>                 Key: PHOENIX-3534
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3534
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Thomas D'Silva
>            Priority: Major
>         Attachments: PHOENIX-3534-wip.patch
>
>
> Currently Phoenix requires that the SYSTEM.CATALOG table is single region based on the
server-side row locks being held for operations that impact a table and all of it's views.
For example, adding/removing a column from a base table pushes this change to all views.
> As an alternative to making the SYSTEM.CATALOG transactional (PHOENIX-2431), when a new
table is created we can do a lazy cleanup  of any rows that may be left over from a failed
DDL call (kudos to [~lhofhansl] for coming up with this idea). To implement this efficiently,
we'd need to also do PHOENIX-2051 so that we can efficiently find derived views.
> The implementation would rely on an optimistic concurrency model based on checking our
sequence numbers for each table/view before/after updating. Each table/view row would be individually
locked for their change (metadata for a view or table cannot span regions due to our split
policy), with the sequence number being incremented under lock and then returned to the client.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message