You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@ambari.apache.org by Sebastian Toader <st...@hortonworks.com> on 2016/12/14 13:35:14 UTC

Review Request 54743: Add PK to hostcomponentdesiredstate Table To Support FK Relationships

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/54743/
-----------------------------------------------------------

Review request for Ambari, Attila Doroszlai, Attila Magyar, Jonathan Hurley, and Laszlo Puskas.


Bugs: AMBARI-19164
    https://issues.apache.org/jira/browse/AMBARI-19164


Repository: ambari


Description
-------

The ```hostcomponentdesiredstate``` table currently uses a compound PK based off of the cluster ID, service name, host id and component name. There are several problems with this approach:
Primary Keys should be data that's not part of the business logic of the system and not subject to be changed potentially (as strings are).
Other tables referencing the hostcomponentdesiredstate table would now need knowledge of cluster/service/component/host in order to make the correct FK association. This leads to extra data being tracked as well as data duplication.
Some databases, such as SQL Server, have problems with the indexing of compound PKs and may lead to deadlocks when querying and updating concurrently.
This table needs to be changed so that it uses a simple PK for referencing. FK relationships as they exist today can still be maintained as long as a UNIQUE constraint is placed on the table. We should:
Add a ```UNIQUE``` constraint to the former PK columns
Add an ```INDEX``` to the former PK columns


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java 488c01e 
  ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java 39e8488 
  ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java 876b1cf 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 274a1e0 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntityPK.java b16d582 
  ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java 1fe65db 
  ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java 042b4d2 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java f9c0eb7 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 5225598 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java 823fb27 
  ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql 8cf2c0d 
  ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql 82ce31e 
  ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql e2c2dd5 
  ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql 4e9a535 
  ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql 0ba7df6 
  ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql d8cad6f 
  ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java 0cf7f09 
  ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java d75d9d0 
  ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java 5987af3 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java 1513209 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java 89dd567 

Diff: https://reviews.apache.org/r/54743/diff/


Testing
-------

Unit tests:
Results :

Tests run: 4797, Failures: 0, Errors: 0, Skipped: 37


Manual testing:
Tested with creating a new cluster. Also tested Ambari upgrade from 2.4.2 to 2.5


Thanks,

Sebastian Toader