Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-21998

Ambari upgrade don't delete stale constraints

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • None
    • None
    • ambari-server
    • None

    Description

      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

       UNIQUE (ldap_user, user_name));

      Ambari-2.4.0
      https://github.com/apache/ambari/blob/branch-2.4/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql#L288

        CONSTRAINT UNQ_users_0 UNIQUE (user_name, user_type))

      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.

      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
      
      

      Attachments

        1. AMBARI-21998.patch
          2 kB
          Dmitry Lysnichenko

        Issue Links

          Activity

            People

              dmitriusan Dmitry Lysnichenko
              dmitriusan Dmitry Lysnichenko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: