You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Sid Wagle <sw...@hortonworks.com> on 2015/11/06 00:38:21 UTC

Review Request 39996: Refactor code that caches stale entity references

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

Review request for Ambari, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


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


Repository: ambari


Description
-------

- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Preliminary patch.


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 

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


Testing
-------

Unit testing in progress.


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sumit Mohanty <sm...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review105424
-----------------------------------------------------------

Ship it!


Ship It!

- Sumit Mohanty


On Nov. 5, 2015, 11:38 p.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 5, 2015, 11:38 p.m.)
> 
> 
> Review request for Ambari, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Preliminary patch.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Unit testing in progress.
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Myroslav Papirkovskyy <mp...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review106040
-----------------------------------------------------------


@OneToMany(mappedBy = "clusterServiceEntity", cascade = CascadeType.ALL)
  private Collection<ServiceComponentDesiredStateEntity> serviceComponentDesiredStateEntities;

Can we get rid of this cascade also? at least change it from ALL to REMOVE or {PERSIST, REMOVE}

One more test case to check: remove cluster (via API, this also happens in install wizard sometimes but not sure about exact case)

- Myroslav Papirkovskyy


On Лис. 11, 2015, 5:11 до полудня, Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Лис. 11, 2015, 5:11 до полудня)
> 
> 
> Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Problems:
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Analysis:
> - Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
> - Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.
> 
> Patch details:
> - Make sure cached references are refreshed appropriately
> - Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Looking to add further Unit tests.
> 
> Existing unit test pass. Last re-run remainig.
> 
> Manual testing scenarios pass:
> - Cluster deploy
> - Add Service
> - Add host
> - Delete service
> - Delete host
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sumit Mohanty <sm...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review106767
-----------------------------------------------------------

Ship it!


Good find, but surprising though +1.

- Sumit Mohanty


On Nov. 16, 2015, 10:52 p.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 16, 2015, 10:52 p.m.)
> 
> 
> Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Problems:
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Analysis:
> - Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
> - Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.
> 
> Patch details:
> - Make sure cached references are refreshed on getter / setter methods
> - Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
> - Marked HostRoleCommand and ExecutionCommand as non-Cacheable entites for JPA
> - Make sure bi-directional persist is present on non-Cascaded entities
> - Removed refresh() calls that were responsible for
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java c74bbbc 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java 9d5fa85 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java 194ac7d 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java 52079cf 
>   ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAOTest.java 95209d4 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java 482ac38 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Looking to add further Unit tests.
> 
> Existing unit test pass. Last re-run remainig.
> 
> Manual testing scenarios pass:
> - Cluster deploy
> - Add Service
> - Add host
> - Delete service
> - Delete host
> - Stop All services
> - Delete cluster
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 16, 2015, 10:52 p.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


Changes
-------

Found that @Cacheable(false) has a major problem resulting in shared object cache misbehavior, verified with using different eclipselink versions that this is not a known issue that is fixed.


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


Repository: ambari


Description
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Patch details:
- Make sure cached references are refreshed on getter / setter methods
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
- Marked HostRoleCommand and ExecutionCommand as non-Cacheable entites for JPA
- Make sure bi-directional persist is present on non-Cascaded entities
- Removed refresh() calls that were responsible for


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java c74bbbc 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java 9d5fa85 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java 194ac7d 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java 52079cf 
  ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAOTest.java 95209d4 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java 482ac38 

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


Testing
-------

Looking to add further Unit tests.

Existing unit test pass. Last re-run remainig.

Manual testing scenarios pass:
- Cluster deploy
- Add Service
- Add host
- Delete service
- Delete host
- Stop All services
- Delete cluster


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Myroslav Papirkovskyy <mp...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review106284
-----------------------------------------------------------

Ship it!


Ship It!

- Myroslav Papirkovskyy


On Лис. 12, 2015, 1:19 до полудня, Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Лис. 12, 2015, 1:19 до полудня)
> 
> 
> Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Problems:
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Analysis:
> - Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
> - Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.
> 
> Patch details:
> - Make sure cached references are refreshed on getter / setter methods
> - Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
> - Marked HostRoleCommand and ExecutionCommand as non-Cacheable entites for JPA
> - Make sure bi-directional persist is present on non-Cascaded entities
> - Removed refresh() calls that were responsible for
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java 194ac7d 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java ac5df7c 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java 482ac38 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Looking to add further Unit tests.
> 
> Existing unit test pass. Last re-run remainig.
> 
> Manual testing scenarios pass:
> - Cluster deploy
> - Add Service
> - Add host
> - Delete service
> - Delete host
> - Stop All services
> - Delete cluster
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 11, 2015, 11:19 p.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


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


Repository: ambari


Description (updated)
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Patch details:
- Make sure cached references are refreshed on getter / setter methods
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
- Marked HostRoleCommand and ExecutionCommand as non-Cacheable entites for JPA
- Make sure bi-directional persist is present on non-Cascaded entities
- Removed refresh() calls that were responsible for


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java 194ac7d 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java ac5df7c 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog210Test.java 482ac38 

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


Testing (updated)
-------

Looking to add further Unit tests.

Existing unit test pass. Last re-run remainig.

Manual testing scenarios pass:
- Cluster deploy
- Add Service
- Add host
- Delete service
- Delete host
- Stop All services
- Delete cluster


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sebastian Toader <st...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review106025
-----------------------------------------------------------

Ship it!


Ship it.

- Sebastian Toader


On Nov. 11, 2015, 4:11 a.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 11, 2015, 4:11 a.m.)
> 
> 
> Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Problems:
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Analysis:
> - Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
> - Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.
> 
> Patch details:
> - Make sure cached references are refreshed appropriately
> - Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Looking to add further Unit tests.
> 
> Existing unit test pass. Last re-run remainig.
> 
> Manual testing scenarios pass:
> - Cluster deploy
> - Add Service
> - Add host
> - Delete service
> - Delete host
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 11, 2015, 3:11 a.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


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


Repository: ambari


Description (updated)
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Patch details:
- Make sure cached references are refreshed appropriately
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 

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


Testing
-------

Looking to add further Unit tests.

Existing unit test pass. Last re-run remainig.

Manual testing scenarios pass:
- Cluster deploy
- Add Service
- Add host
- Delete service
- Delete host


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 11, 2015, 3:10 a.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


Changes
-------

- Removed refresh calls from child objects like ServiceComponent to parent objects refresh methods to update cached references.
- Marked ExecutionCommand and HostRoleCommand entities as non Cacheable for JPA layer since explict caching exists in ActionDBAccessor. This is to ensure sahred object cache will be used for out getters / setter calls.


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


Repository: ambari


Description
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Preliminary patch:
- Make sure cached references are refreshed appropriately
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 

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


Testing (updated)
-------

Looking to add further Unit tests.

Existing unit test pass. Last re-run remainig.

Manual testing scenarios pass:
- Cluster deploy
- Add Service
- Add host
- Delete service
- Delete host


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 10, 2015, 8:22 p.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


Changes
-------

Changes : Get calls will update cached references. Ignore JPA caching for HRC and ExecCmd, these objects are explicitly cached by ActionDBAccessorImpl.


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


Repository: ambari


Description
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Preliminary patch:
- Make sure cached references are refreshed appropriately
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java 99c327f 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java eade294 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java 25d830b 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java bb8ba19 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java c39ecc4 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java 7b1c6ca 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 

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


Testing
-------

Looking to add further Unit tests.

Existing unit test pass.

Manual testing: Cluster deploy successful. Need to test blueprints.


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 9, 2015, 2:59 a.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


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


Repository: ambari


Description
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Preliminary patch:
- Make sure cached references are refreshed appropriately
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java d34e2d5 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java 4195710 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 

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


Testing (updated)
-------

Looking to add further Unit tests.

Existing unit test pass.

Manual testing: Cluster deploy successful. Need to test blueprints.


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sebastian Toader <st...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review105621
-----------------------------------------------------------

Ship it!


Ship It!

- Sebastian Toader


On Nov. 7, 2015, 6:47 a.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 7, 2015, 6:47 a.m.)
> 
> 
> Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Problems:
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Analysis:
> - Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
> - Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.
> 
> Preliminary patch:
> - Make sure cached references are refreshed appropriately
> - Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
>   ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java 4195710 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
>   ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
>   ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Looking to add further Unit tests.
> 
> Existing unit test pass.
> 
> Manual testing in progress.
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/
-----------------------------------------------------------

(Updated Nov. 7, 2015, 5:47 a.m.)


Review request for Ambari, Alejandro Fernandez, Jonathan Hurley, Mahadev Konar, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.


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


Repository: ambari


Description (updated)
-------

Problems:
- Deleted hostcomponent rows re-appear
- Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables

Analysis:
- Stale entity references cached that point to dettached entites and may get persisted in altogether different transaction
- Cascaded persist annotation mixed with manual bi-directional persist operations. The manual persist was done since there are cached references in the object hierarchy at different levels. The Casade addition seems to have been an after thought added on even though manual bi-directional perist laways existed.

Preliminary patch:
- Make sure cached references are refreshed appropriately
- Remove Cascaded persist for only those relations that could result in un-intentional persist of the relationship with downstream objects. eg: ServiceComponentHostDesiredStateEntity


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java 101aea1 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java ee8e7d6 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java 42f7777 
  ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java 4195710 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
  ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
  ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
  ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java f6b388f 
  ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
  ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog150Test.java 39dd815 

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


Testing (updated)
-------

Looking to add further Unit tests.

Existing unit test pass.

Manual testing in progress.


Thanks,

Sid Wagle


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sid Wagle <sw...@hortonworks.com>.

> On Nov. 6, 2015, 9:52 a.m., Sebastian Toader wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java, line 92
> > <https://reviews.apache.org/r/39996/diff/1/?file=1117446#file1117446line92>
> >
> >     Couldn't this constructor just simply call the second one to avoid code duplication? e.g.
> >     
> >     this(service, desiredStateEntity, injector)

Not really, one creates a fresh new in-memory only instantiation, the other reconstructs from an entity.


> On Nov. 6, 2015, 9:52 a.m., Sebastian Toader wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java, line 353
> > <https://reviews.apache.org/r/39996/diff/1/?file=1117446#file1117446line353>
> >
> >     You may forgot this line commented out. In general I think it's a good practice to reload an entity from db prior modifying it to ensure no stale other entities are referenced (in case the referenced entities were already deleted in some other place).

Yes, thanks I was playing around with unit testing.


> On Nov. 6, 2015, 9:52 a.m., Sebastian Toader wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java, line 108
> > <https://reviews.apache.org/r/39996/diff/1/?file=1117447#file1117447line108>
> >
> >     Can this constructor call the other one with the appropriate params to avoid code duplication?

I see your point of reducing code dup but there are more than 1 differences like persisted flag, so will leave the code asis for now.


> On Nov. 6, 2015, 9:52 a.m., Sebastian Toader wrote:
> > ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java, line 72
> > <https://reviews.apache.org/r/39996/diff/1/?file=1117449#file1117449line72>
> >
> >     I think this initialisation needs to run only once per test suite so would make it @BeforeClass

Actually, every test starts and stop persistence service this way which avoid test from stepping on each other vs cleanup code in the @After method.


- Sid


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


On Nov. 5, 2015, 11:38 p.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 5, 2015, 11:38 p.m.)
> 
> 
> Review request for Ambari, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Preliminary patch.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Unit testing in progress.
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>


Re: Review Request 39996: Refactor code that caches stale entity references

Posted by Sebastian Toader <st...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/39996/#review105387
-----------------------------------------------------------



ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (line 92)
<https://reviews.apache.org/r/39996/#comment163972>

    Couldn't this constructor just simply call the second one to avoid code duplication? e.g.
    
    this(service, desiredStateEntity, injector)



ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (line 353)
<https://reviews.apache.org/r/39996/#comment163973>

    You may forgot this line commented out. In general I think it's a good practice to reload an entity from db prior modifying it to ensure no stale other entities are referenced (in case the referenced entities were already deleted in some other place).



ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (line 108)
<https://reviews.apache.org/r/39996/#comment163977>

    Can this constructor call the other one with the appropriate params to avoid code duplication?



ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java (line 72)
<https://reviews.apache.org/r/39996/#comment163986>

    I think this initialisation needs to run only once per test suite so would make it @BeforeClass


- Sebastian Toader


On Nov. 6, 2015, 12:38 a.m., Sid Wagle wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/39996/
> -----------------------------------------------------------
> 
> (Updated Nov. 6, 2015, 12:38 a.m.)
> 
> 
> Review request for Ambari, Myroslav Papirkovskyy, Sumit Mohanty, and Sebastian Toader.
> 
> 
> Bugs: AMBARI-13753
>     https://issues.apache.org/jira/browse/AMBARI-13753
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> - Deleted hostcomponent rows re-appear
> - Inconsistencies in hostcomponentstate and hostcomponentdesiredstate tables
> 
> Preliminary patch.
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java 6150011 
>   ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java bbe2f62 
>   ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java c0804ff 
>   ambari-server/src/test/java/org/apache/ambari/server/testing/DBInconsistencyTests.java PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/39996/diff/
> 
> 
> Testing
> -------
> 
> Unit testing in progress.
> 
> 
> Thanks,
> 
> Sid Wagle
> 
>