> On 九月 27, 2016, 12:39 p.m., Jonathan Hurley wrote:
> > ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java,
> >  lines 225-226
> > <https://reviews.apache.org/r/52155/diff/2/?file=1508852#file1508852line225>
> >
> >     This doesn't guarantee ordering of any kind - the first one which comes 
> > back could have an ID of 9. Since it doesn't match `m_hcsId`, this code 
> > would try to update it to to a value of 1 and possibly cause duplicates.
> >     
> >     You can simply skip this whole section of updating if the 
> > `resultSet.getLong("id")` is non-null/non-zero. 
> >     
> >     You can then so something like this:
> >     `m_hcsId.set(NumberUtils.max(m_hcsId.get(), idKey)`

Hi Jonathan ,Thanks for your advice, that is highly appreciated. However, 
consider the randomness of the value of idKey, my method may avoid this issue. 
For instance, if the first-time get value of resultSet.getLong("id") is 2, and 
the second-time get value is 1, then basing on your method, the duplicates 
error would still occur. Hope we could get further agreement on this case, 
thanks.


- wang


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


On 九月 27, 2016, 12:03 p.m., wang yaoxin wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/52155/
> -----------------------------------------------------------
> 
> (Updated 九月 27, 2016, 12:03 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Oliver Szabo, Robert Nettleton, 
> and Sebastian Toader.
> 
> 
> Bugs: AMBARI-18441
>     https://issues.apache.org/jira/browse/AMBARI-18441
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> My first upgrade test failed due to my environment issue. Since in real 
> production environment this failure would  occur again.
> 
> ambari upgrade to 2.1.1 and later version, if the first time failed , excute 
> ambari-server upgrade again will error duplicate key value violates unique 
> constraint "pk_hostcomponentstate".
> 
> 
> Diffs
> -----
> 
>   
> ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
>  db13612 
> 
> Diff: https://reviews.apache.org/r/52155/diff/
> 
> 
> Testing
> -------
> 
> the unit test is UpgradeCatalog211Test.java: Process finished with exit code 
> 0.
> done !
> 
> 
> Thanks,
> 
> wang yaoxin
> 
>

Reply via email to