[
https://issues.apache.org/jira/browse/OFBIZ-2353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14114988#comment-14114988 ]
Jacopo Cappellato commented on OFBIZ-2353:
------------------------------------------
[~jacques.le.roux] thanks for the details and for pointing me to OFBIZ-3557, I will have a look at it.
After your comments I still think that this ticket should have been marked as invalid: the algorithm used by OFBiz was designed to work with multiple OFBiz instances connected to the same database and I doubt that the reported issue was caused by it; it was instead probably caused y the fact that the SequenceUtil class has some incorrect code that makes it not thread-safe.
The issue is still there.
The fix you have committed doesn't fix the issue reported (as a a side note it also adds some unnecessary complexities to the SequenceUtil class that I am going to clean): instead it avoids the collisions by acquiring a lock; however the code is redundant (why two SELECT FOR UPDATE statements? the second is not needed) and for a key component of the framework like this this is not good (the fact that "it works" is not enough).
I am still digging into this class but my plan right now is to refactor it and simplify it a lot. I will keep you updated on my progress.
> SequenceUtil may generate duplicate IDs in Load Balancing mode
> ---------------------------------------------------------------
>
> Key: OFBIZ-2353
> URL:
https://issues.apache.org/jira/browse/OFBIZ-2353> Project: OFBiz
> Issue Type: Bug
> Components: framework
> Affects Versions: Release Branch 4.0, Release Branch 09.04, Trunk
> Reporter: Philippe Mouawad
> Assignee: Jacopo Cappellato
> Priority: Critical
> Fix For: Release Branch 10.04, Release Branch 11.04, Trunk
>
> Attachments: OFBIZ-2353 SELECT FOR UPDATE solution.patch, OFBIZ-2353 SELECT FOR UPDATE solution.patch
>
>
> If Ofbiz is deploy on 2 servers in Load Balancing Mode
> SequenceUtil will generate duplicate IDs because synchronization is done at JVM level instead of doing it in DB.
> A good replacement implementation would be:
> org.hibernate.id.enhanced.TableGenerator
> But it would involve a dependency on Hibernate
> Philippe
> www.ubik-ingenierie.com
--
This message was sent by Atlassian JIRA
(v6.2#6252)