[ 
https://issues.apache.org/jira/browse/AMBARI-21998?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dmitry Lysnichenko updated AMBARI-21998:
----------------------------------------
    Component/s: ambari-server

> Ambari upgrade don't delete stale constraints
> ---------------------------------------------
>
>                 Key: AMBARI-21998
>                 URL: https://issues.apache.org/jira/browse/AMBARI-21998
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-server
>            Reporter: Dmitry Lysnichenko
>            Assignee: Dmitry Lysnichenko
>            Priority: Critical
>
> During  Ambari upgrade from 2.2.2 to 2.5 I discovered that some UNIQUE 
> constraints are definned without name in older Ambari versions, and then 
> altered by name in UpgadeCatalogs/newer DDLs.
> For example:
> Ambari 2.2.2
> https://github.com/apache/ambari/blob/branch-2.2.2/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
> {code} UNIQUE (ldap_user, user_name));{code}
> Ambari-2.4.0
> https://github.com/apache/ambari/blob/branch-2.4/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql#L288
> {code}  CONSTRAINT UNQ_users_0 UNIQUE (user_name, user_type)){code}
> As a result, during upgrade from Ambari 2.2.2 to Ambari 2.5.0, the stale 
> unique constraint with default name is not deleted.
> That will reproduce on Postgres for any upgrade path that includes these 
> versions.
> {code}ambari=# \d+ users
> Table "ambari.users"
> Column         |            Type             |             Modifiers          
>     | Storage  | Description
> -----------------------+-----------------------------+------------------------------------+----------+-------------
> user_id               | integer                     | not null                
>            | plain    |
> principal_id          | bigint                      | not null                
>            | plain    |
> ldap_user             | integer                     | not null default 0      
>            | plain    |
> user_name             | character varying(255)      | not null                
>            | extended |
> create_time           | timestamp without time zone | default now()           
>            | plain    |
> user_password         | character varying(255)      |                         
>            | extended |
> active                | integer                     | not null default 1      
>            | plain    |
> active_widget_layouts | character varying(1024)     | default NULL::character 
> varying    | extended |
> user_type             | character varying(255)      | default 
> 'LOCAL'::character varying | extended |
> Indexes:
> "users_pkey" PRIMARY KEY, btree (user_id)
> "unq_users_0" UNIQUE, btree (user_name, user_type)
> "users_ldap_user_key" UNIQUE, btree (ldap_user, user_name)
> Foreign-key constraints:
> "fk_users_principal_id" FOREIGN KEY (principal_id) REFERENCES 
> adminprincipal(principal_id)
> Referenced by:
> TABLE "members" CONSTRAINT "fk_members_user_id" FOREIGN KEY (user_id) 
> REFERENCES users(user_id)
> Has OIDs: no
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to