Bug 1017331 - Duplicate entry 'Administrator' for key 'PRIMARY' SQLState: 23000 when RuntimeManager is used by multiple threads
Summary: Duplicate entry 'Administrator' for key 'PRIMARY' SQLState: 23000 when Runtim...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER5
: 6.0.0
Assignee: Maciej Swiderski
QA Contact: Jiri Svitak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-09 16:06 UTC by Jiri Svitak
Modified: 2015-06-02 01:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:10:40 UTC
Type: Bug


Attachments (Terms of Use)
console log (86.20 KB, text/plain)
2013-10-09 16:06 UTC, Jiri Svitak
no flags Details

Description Jiri Svitak 2013-10-09 16:06:36 UTC
Created attachment 810016 [details]
console log

Duplicate entry 'Administrator' for key 'PRIMARY' when RuntimeManager is used by multiple threads. See the whole console log in attachment.

2013-10-09 16:49:43,113 INFO  [DefaultMessageGenerator] Starting to generate...
2013-10-09 16:49:44,344 WARN  [SqlExceptionHelper] SQL Error: 1062, SQLState: 23000
2013-10-09 16:49:44,344 WARN  [SqlExceptionHelper] SQL Error: 1062, SQLState: 23000
2013-10-09 16:49:44,344 ERROR [SqlExceptionHelper] Duplicate entry 'Administrator' for key 'PRIMARY'
2013-10-09 16:49:44,344 ERROR [SqlExceptionHelper] Duplicate entry 'Administrator' for key 'PRIMARY'
2013-10-09 16:49:44,345 WARN  [SqlExceptionHelper] SQL Error: 1062, SQLState: 23000
2013-10-09 16:49:44,345 ERROR [SqlExceptionHelper] Duplicate entry 'Administrator' for key 'PRIMARY'

To reproduce:
1.) git clone git://git.app.eng.bos.redhat.com/jbossqe-process-flood.git
2.) make sure that you are on company vpn to download all required maven artifacts
3.) make sure that you have local MySQL instance with clean database bpms, user bpms, password bpms (according to file mysql-localhost.xml)
4.) Run the test:
cd jbossqe-process-flood/bpms-6.x
./execute_scenario.sh -Dscenario=HumanTask_startProcess_Java -Dthreads=4 -DruntimeManager=PerProcessInstance -s ../mysql-localhost.xml

It can be either concurrency problem in runtime manager or bad usage of it. In any case this should not happen and more informative error message would be better.

Comment 1 Maciej Swiderski 2013-10-14 09:05:44 UTC
the main issue with this was that attempt to insert users/groups by user group callback was not secured to be thread safe and thus when several task were tried to be inserted at the same time for same users/groups caused the failure. Fix was applied to ensure that only single thread can perform the insertion and rest will wait and rely on already done operation

jbpm 
master:
https://github.com/droolsjbpm/jbpm/commit/e2af85494576f7d9ffd20cec58d8688bdda91e22

6.0.x
https://github.com/droolsjbpm/jbpm/commit/8e5de869436695bafa36e3a2dd6d5a6061b2432b

Comment 2 Marco Rietveld 2013-10-30 15:50:49 UTC
Maciej, 

Do you have a test for this somewhere? Of was this particularly hard to test?

Comment 3 Maciej Swiderski 2013-10-31 08:20:55 UTC
Marco, I used the jbossqe-process-flood as reproducer for this issue. Besides that I haven't created any junit test as it is tricky simulate that as junit test which essentially can fail with false results many times and thus I relied on jbossqe-process-flood only.

Comment 4 Jiri Svitak 2013-11-22 16:09:11 UTC
Verified in BPMS 6 ER5 (6.0.0-redhat-6).

One of the commands I used to verify:
./execute_scenario.sh -Dscenario=HumanTask_Java -Dthreads=4 -DruntimeManager=PerProcessInstance -s ../mysql-localhost.xml


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