[ https://issues.apache.org/jira/browse/OFBIZ-2353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13037646#comment-13037646 ] Jacques Le Roux edited comment on OFBIZ-2353 at 5/31/11 9:06 AM: ----------------------------------------------------------------- Philippe, Yes thanks, but of course I don't intend to keep maxTries at 100 (we have other priorities at the moment). I was considering the SELECT FOR UPDATE solution because, as you said, it allows a totally DBMS independent solution. So an alternative in clustered environment for OFBiz OOTB. And I don't digg it in yet, but it sounds like it could be used w/out much changes, ie replace { sql = "SELECT " + SequenceUtil.this.idColName + " FROM " + SequenceUtil.this.tableName + " WHERE " + SequenceUtil.this.nameColName + "='" + this.seqName + "'"; } by { sql = "SELECT " + SequenceUtil.this.idColName + " FROM " + SequenceUtil.this.tableName + " WHERE " + SequenceUtil.this.nameColName + "='" + this.seqName + "'" + " FOR UPDATE"; } But once more I guess a CREATE SEQUENCE solution would give better performance (no contention, optimized DBMS internal mechanism). So I plan (have to look into details next week) to keep maxTries to 5 (should not be needed anymore, but I will make as less changes as possible in this next quick iteration) and use SELECT FOR UPDATE there, before implementing a complete solution based on CREATE SEQUENCE for the project (we use Postgres). was (Author: jacques.le.roux): Philippe, Yes thanks, but of course I don't intend to keep maxTries at 100 (we have other priorities at the moment). I was considering the SELECT FOR UPDATE solution because, as you said, it allows a totally DBMS independent solution. So an alternative in clustered environment for OFBiz OOTB. And I don't digg it in yet, but it sounds like it could be used w/out much changes, ie replace { sql = "SELECT " + SequenceUtil.this.idColName + " FROM " + SequenceUtil.this.tableName + " WHERE " + SequenceUtil.this.nameColName + "='" + this.seqName + "'"; } by { sql = "SELECT FOR UPDATE" + SequenceUtil.this.idColName + " FROM " + SequenceUtil.this.tableName + " WHERE " + SequenceUtil.this.nameColName + "='" + this.seqName + "'"; } But once more I guess a CREATE SEQUENCE solution would give better performance (no contention, optimized DBMS internal mechanism). So I plan (have to look into details next week) to keep maxTries to 5 (should not be needed anymore, but I will make as less changes as possible in this next quick iteration) and use SELECT FOR UPDATE there, before implementing a complete solution based on CREATE SEQUENCE for the project (we use Postgres). > 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 |
Free forum by Nabble | Edit this page |