> On May 4, 2016, 2:07 p.m., Jonathan Hurley wrote: > > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java, > > lines 360-361 > > <https://reviews.apache.org/r/46944/diff/1/?file=1369950#file1369950line360> > > > > Might want to try/catch the persist() and reload the cluster service > > map in that case. > > > > Here's a scenario: > > - You add the service to the cluster > > - You persist the service which throws an exception > > - You can't add the service again since the cluster thinks it has it > > already > > > > Now this problem actually existed before as well. Just because > > persist() was being called before `cluster.addService()` doesn't mean it > > happened at that point. EclipseLink was cache the call until it needed to > > flush it. So even the code as it existed today was problematic.
what if I add this line to ServiceImpl#persist() method : cluster.addService(this) , just before ServiceInstalledEvent is published? (and remove addService from ServiceResourceProvider) - Oliver ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/46944/#review131668 ----------------------------------------------------------- On May 3, 2016, 7:36 p.m., Oliver Szabo wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/46944/ > ----------------------------------------------------------- > > (Updated May 3, 2016, 7:36 p.m.) > > > Review request for Ambari, Jonathan Hurley, Laszlo Puskas, and Sebastian > Toader. > > > Bugs: AMBARI-16230 > https://issues.apache.org/jira/browse/AMBARI-16230 > > > Repository: ambari > > > Description > ------- > > 2 different type of errors can occur during adding any new service to Ambari: > > org.apache.ambari.server.AmbariException: Unable to create a default alert > group for unknown service <SERVICE_NAME> in cluster > > org.apache.ambari.server.ServiceNotFoundException: Service not found, > clusterName=c1, serviceName=<SERVICE_NAME> > > The reason is that: ServiceInstalledEvent can be handled quicker than > ServiceImpl.persist() can finish > > > Diffs > ----- > > > ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java > 47342f3 > > Diff: https://reviews.apache.org/r/46944/diff/ > > > Testing > ------- > > Unit Testing is in progress.. > FT: added new services about 10 times, has no any errors thrown. > > > Thanks, > > Oliver Szabo > >