Bug 617544 - 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"
Multiple click on 'SYNCHRONIZE' of JBoss CSP patch feed gives error in server...
Status: CLOSED CURRENTRELEASE
Product: RHQ Project
Classification: Other
Component: Content (Show other bugs)
3.0.0
All Linux
high Severity medium (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On:
Blocks: jon3
  Show dependency treegraph
 
Reported: 2010-07-23 08:08 EDT by Rajan Timaniya
Modified: 2014-06-17 17:20 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-17 17:20:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
server log (173.01 KB, text/x-log)
2010-07-23 08:08 EDT, Rajan Timaniya
no flags Details
server log - JON goes down (396.75 KB, text/x-log)
2010-07-23 10:01 EDT, Rajan Timaniya
no flags Details
git patch (912 bytes, patch)
2010-07-23 15:53 EDT, Jay Shaughnessy
no flags Details | Diff

  None (edit)
Description Rajan Timaniya 2010-07-23 08:08:30 EDT
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.
Comment 1 Charles Crouch 2010-07-23 09:23:24 EDT
Needs triage.

Rajan, can you elaborate on what happens during " JON server goes
down."
Comment 2 Rajan Timaniya 2010-07-23 10:00:59 EDT
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.
Comment 3 Rajan Timaniya 2010-07-23 10:01:47 EDT
Created attachment 433960 [details]
server log - JON goes down
Comment 4 Joseph Marques 2010-07-23 10:10:41 EDT
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>
Comment 5 Charles Crouch 2010-07-23 10:20:29 EDT
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.
Comment 6 Jay Shaughnessy 2010-07-23 15:52:35 EDT
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.
Comment 7 Jay Shaughnessy 2010-07-23 15:53:55 EDT
Created attachment 434047 [details]
git patch
Comment 8 Charles Crouch 2010-07-23 16:02:14 EDT
Dropping priority as this could not be reproduced and multiple manual syncs should not be a common use case.
Comment 9 Jay Shaughnessy 2014-06-17 17:20:46 EDT
This may be fixed at the gui level in coregui. Closing due to inactivity.

Note You need to log in before you can comment on or make changes to this bug.