Created attachment 433929 [details] server log Description of problem: Multiple click on 'SYNCHRONIZE' of JBoss CSP patch feed gives error in server log - duplicate key value violates unique constraint "rhq_repo_pkg_ver_map_key" 2010-07-23 14:41:38,942 INFO [org.rhq.enterprise.server.plugin.pc.content.sync.PackageSourceSynchronizer] Lazy load enabled for source [JBoss Patch Content Source], skipping package bits sync for repo [JBoss Patches] 2010-07-23 14:41:42,054 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 23505 2010-07-23 14:41:42,054 ERROR [org.hibernate.util.JDBCExceptionReporter] Batch entry 0 insert into RHQ_REPO_PKG_VERSION_MAP (CTIME, REPO_ID, PACKAGE_VERSION_ID) values ('1279876297797', '10001', '10164') was aborted. Call getNextException to see the cause. 2010-07-23 14:41:42,054 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 23505 2010-07-23 14:41:42,054 ERROR [org.hibernate.util.JDBCExceptionReporter] ERROR: duplicate key value violates unique constraint "rhq_repo_pkg_ver_map_key" 2010-07-23 14:41:42,055 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) . . . Version-Release number of selected component (if applicable): version: 2.4.0.GA_QA (build #75) build number: 10876:a0cdffc How reproducible: Intermittent Steps to Reproduce: 1) Log-in to JON 2.4 (build #75) 2) Go to Administration > Content > Content Sources 3) Click on 'JBoss CSP Patch Feed' link 4) Provide user name/password to 'CSP Feed Settings' and make it active 5) Click on 'SAVE' 6) Click on 'SYNCHRONIZE' button 7) Click on 'JBoss Patches' link 8) Click on 'SYNCHRONIZE' button Actual results: Multiple click on 'SYNCHRONIZE' of JBoss CSP patch feed gives error in server log - duplicate key value violates unique constraint "rhq_repo_pkg_ver_map_key" Expected results: JON should not give 'duplicate key value violates unique constraint' error and it should synchronize Jboss CSP patch feed. Additional info: Tried to reproduce same issue many time but for some attempts JON server goes down. Please refer attached server log.
Needs triage. Rajan, can you elaborate on what happens during " JON server goes down."
JON server goes down details: version: 2.4.0.GA_QA (build #75) build number: 10876:a0cdffc Steps to Reproduce: 1) Log-in to JON 2.4 (build #75) 2) Go to Administration > Content > Content Sources 3) Click on 'JBoss CSP Patch Feed' link 4) Provide user name/password to 'CSP Feed Settings' and make it active 5) Click on 'SAVE' 6) Click on 'SYNCHRONIZE' button 7) Click on 'JBoss Patches' link 8) Click on 'SYNCHRONIZE' button 9) Repeat steps 6 to 8 for couple of times Observation: Running JON server goes down, there isn't any error/exception in server log. Additional info: Please refer attached server log for the case of JON server down.
Created attachment 433960 [details] server log - JON goes down
from resourceOperationScheduleNew.xhtml... <h:commandButton action="#{ResourceOperationScheduleUIBean.schedule}" value="SCHEDULE" styleClass="buttonmed" rendered="#{ResourceUIBean.permissions.control}" onclick="return preventDoubleClick();"/> <script type="text/javascript"> var submitted = false; function preventDoubleClick() { if (submitted) { return false; } else { submitted = true; return true; } } </script>
Needs to be reproduced but clicking the synchronize button, returning to the page, and clicking again repeatedly is not a typical execution path. Double click prevention would not seem to help in this case either.
I failed to reproduce but... After looking at this I don't think we have in place any good mechanism for serializing or protecting against concurrent, ui requested, sync job execution. There are Content Source syncs and their are Repo syncs, both of which can be kicked off manually and via cron job. Moreover, a Content Source sync, when completing its sync of discovered repos, goes on to sync the repos as well. So, to really protect against concurrent repo syncs we need to put in synch job serialization, or be smart enough to fail if one is in progress (for a particular source or repo). One very basic enhancement we can make is to add a bit of gui protection against a single gui session requesting multiple repo syncs from the repo view. This UI bean actually does know when a sync is in progress. The one line patch is attached as fix1.patch. I think any real protection will require a more sophisticated approach.
Created attachment 434047 [details] git patch
Dropping priority as this could not be reproduced and multiple manual syncs should not be a common use case.
This may be fixed at the gui level in coregui. Closing due to inactivity.