[
https://issues.apache.org/jira/browse/OFBIZ-2353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13033501#comment-13033501 ]
Jacques Le Roux commented on OFBIZ-2353:
----------------------------------------
Hi Philippe,
I see you are pretty active on OFBiz these last times. I wonder if you did not cross any issues again with this (I guess so). So did you implement Karl's pseudo-code?
I currently support a clustered project, we did not cross any such issues so far (not yet live but near). Nevetheless, I have reviewed the current algorithm. It’s based on Floyd Marinescu’s Sequence Blocks pattern in his ["In EJB Design Pattern" book|
http://www.inf.ufsc.br/~bosco/downloads/EJBDesignPatterns.pdf] (or the other way around, I don't know - ie Floyd Marinescu was inspired by OFBiz). Marinescu claims that it’s safe for clusters when using ReadCommitted isolation level, which is the default for all datasource in OFBiz. You might get collisions but then you retry a specified number of times (5 in OFBIz where a collisions detection like in Ethernet CSMA/CD is used.
Karl claims his suggested algorithm works in all cases and has been used in other applications. This sounds plausible because it seems inspired by Hibernate TableGenerator algorithm. But I wonder about performance because, unlike Sequence Blocks pattern, it uses an unlimited « do while loop » and adds another transaction (mostly the unlimited loop worries me). Note that the actual TableGenerator algorithm uses database stored procedures.
In other words, I will certainly write code based on Karl's proposition and uses it on stagging for a while, to test. I will continue for now to use the current algorithm on production (not yet public).
So I'm interested about your experience and possible solution. Of course, I'm also interested by all possibles solution used in live production clustered sites. This in order to definitively keep the better one from our experiences, in OFBiz OOTB...
Thanks to all interested
> 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, SVN trunk
> Reporter: Philippe Mouawad
> Assignee: Adam Heath
> Priority: Critical
>
> 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 is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira