Thanks for the suggestion, but since I work in two "worlds" (the process
definition and the process instance), I couldn't find one object I could
reliably synchronize on. As far as I know, Drools internally syncs on the
process object in the "definition world" and on the process instance object
in the "instance world" (at least in the parts of Drools I had a look at,
i.e. the parts that used to cause concurrency issues for me).
And just to be clear, when I say I synchronize on those two objects, I mean
I acquire both locks for my critical sections (-> nested
synchronized-blocks).
My main goal is not to change any of the Drools internals so that I can
deliver my code as an add-on to a standard Drools install. Also, I guess
it's a lot easier to upgrade to newer versions of Drools if I don't change
any internals.
After reading a recent thread on concurrency issues of the
StatefulKnowledgeSession
(
http://drools-java-rules-engine.46999.n3.nabble.com/StatefulKnowledgeSess...)
I have a theory of what might be going on in my case:
Due to the number of process instances I start in parallel it is likely that
many of them reach a WorkItemNode at the same time (right now I start the
same process multiple times, so the execution times for all instances should
be more or less the same).
When that happens, I guess it is likely that two WorkItems are created at
the same time with the same WorkItemID (since DefaultWorkItemManager doesn't
seem to be thread-safe with regards to the ID generation). All WorkItems
are stored in a Map with the WorkItemID used as the key, so only one of
these WorkItems with the same ID is stored in the Map.
And there we are: one WorkItem is "lost" and the corresponding
ProcessInstance will never finish.
I really hadn't thought about this before because I assumed the usage of
ConcurrentHashMap for WorkItem storage in the DefaultWorkItemManager would
ensure thread-safety.
I'm still testing the solution provided in that thread but so far it looks
very nice.
Regards
Henning Losert
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Weird-Problem-WorkIte...
Sent from the Drools - User mailing list archive at
Nabble.com.