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

NPE when migrating users table during upgrade to Ambari 2.7.0 with Oracle DB

    XMLWordPrintableJSON

Details

    Description

      NPE when migrating users table during upgrade to Ambari 2.7.0 with Oracle DB:

      2018-08-20 11:36:46,395 ERROR [main] SchemaUpgradeHelper:207 - Upgrade failed. 
      java.lang.NullPointerException
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.convertUserCreationTimeToLong(UpgradeCatalog270.java:595)
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.upgradeUserTables(UpgradeCatalog270.java:342)
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.executeDDLUpdates(UpgradeCatalog270.java:318)
      	at org.apache.ambari.server.upgrade.AbstractUpgradeCatalog.upgradeSchema(AbstractUpgradeCatalog.java:970)
      	at org.apache.ambari.server.upgrade.SchemaUpgradeHelper.executeUpgrade(SchemaUpgradeHelper.java:205)
      	at org.apache.ambari.server.upgrade.SchemaUpgradeHelper.main(SchemaUpgradeHelper.java:448)
      2018-08-20 11:36:46,395 ERROR [main] SchemaUpgradeHelper:473 - Exception occurred during upgrade, failed
      org.apache.ambari.server.AmbariException
      	at org.apache.ambari.server.upgrade.SchemaUpgradeHelper.executeUpgrade(SchemaUpgradeHelper.java:208)
      	at org.apache.ambari.server.upgrade.SchemaUpgradeHelper.main(SchemaUpgradeHelper.java:448)
      Caused by: java.lang.NullPointerException
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.convertUserCreationTimeToLong(UpgradeCatalog270.java:595)
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.upgradeUserTables(UpgradeCatalog270.java:342)
      	at org.apache.ambari.server.upgrade.UpgradeCatalog270.executeDDLUpdates(UpgradeCatalog270.java:318)
      	at org.apache.ambari.server.upgrade.AbstractUpgradeCatalog.upgradeSchema(AbstractUpgradeCatalog.java:970)
      	at org.apache.ambari.server.upgrade.SchemaUpgradeHelper.executeUpgrade(SchemaUpgradeHelper.java:205)
      	... 1 more
      

      Cause
      This is caused by one or more records with a NULL value in the create_time field.

      For example:

      user_id user_name user_type create_time
      1 admin LOCAL NULL

      Workaround 
      Update the relevant records to not have a NULL in the create_time column.

      For example:

      UPDATE users SET create_time=systimestamp WHERE create_time IS NULL;
      

      Solution
      During upgrade, protect against a null value for currentUserCreateTime.getValue() at:

      org/apache/ambari/server/upgrade/UpgradeCatalog270.java:595
                dbAccessor.updateTable(USERS_TABLE, temporaryColumnName, currentUserCreateTime.getValue().getTime(),
                    "WHERE " + USERS_USER_ID_COLUMN + "=" + currentUserCreateTime.getKey());
      

      If currentUserCreateTime.getValue() is null, the current timestamp should be used.

      Note: This may be a reoccurring issue since there is no provision to ensure that create_time is not NULL when initializing the Ambari database:

      insert into users(user_id, principal_id, user_name, user_password)
      select 1,1,'admin','538916f8943ec225d97a9a86a2c6ec0818c1cd400e09e03b660fdaaec4af29ddbb6f2b1033b81b00' from dual;

      Attachments

        Activity

          People

            smolnar Sandor Molnar
            smolnar Sandor Molnar
            Votes:
            0 Vote for this issue
            Watchers:
            2 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 - 2h 10m
                2h 10m