Bug 778821 (SOA-1271)

Summary: jBPM creates two indices for each foreign key column on MySQL
Product: [JBoss] JBoss Enterprise SOA Platform 4 Reporter: Jiri Pechanec <jpechane>
Component: JBPM - within SOA, Build ProcessAssignee: Len DiMaggio <ldimaggi>
Status: CLOSED WONTFIX QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 4.3 CP01CC: dlesage, ldimaggi
Target Milestone: ---   
Target Release: FUTURE   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-1271
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-21 20:02:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jiri Pechanec 2009-04-03 15:44:09 UTC
Date of First Response: 2009-05-28 10:32:34
project_key: SOA

See JBPM-2143

If this issue will be fixed in CP then it is necessary to provide update scripts to remove duplicates from db schemas created by this version

Comment 1 Jiri Pechanec 2009-04-03 15:44:33 UTC
Link: Added: This issue depends JBPM-2143


Comment 2 Julian Coleman 2009-05-28 14:32:34 UTC
We will defer this to CP03.

Comment 3 Alejandro Guizar 2009-12-03 09:23:10 UTC
Resolving platform issue as the project peer JBPM-2143 has been resolved.

Comment 4 David Le Sage 2010-02-25 04:24:48 UTC
Please review the following draft text which has been added to the Resolved Issues section of the Release Notes. Also, what was the impact of having double indices?  Did it have a performance impact or was it confusing the database?  Please supply that info and I will add it to the followng note.:


https://jira.jboss.org/jira/browse/JBPM-2143

    jBPM was creating two indices for each foreign key column on MySQL databases. This problem
    has been rectified by the addition of customised MYSQLDialect statements for the addition
    of foreign keys. When foreign keys are added by the use of these statements, an index is not
    created, preventing the duplication issue from arising anymore.


Comment 5 Alejandro Guizar 2010-03-03 06:24:34 UTC
David, here is an updated text for the release notes that addresses your questions.

<<
The MySQL schema creation script that jBPM versions prior to 3.2.9 contained statements that resulted in the duplicate creation of indexes on table columns constrained by a foreign key. The statements below illustrate the problem:

create index IDX_PROCIN_PROCDEF on JBPM_PROCESSINSTANCE (PROCESSDEFINITION_);
alter table JBPM_PROCESSINSTANCE add index FK_PROCIN_PROCDEF (PROCESSDEFINITION_), add constraint FK_PROCIN_PROCDEF foreign key (PROCESSDEFINITION_) references JBPM_PROCESSDEFINITION (ID_);

When executed, these statements create two separate indices IDX_PROCIN_PROCDEF and FK_PROCIN_PROCDEF on the JBPM_PROCESSINSTANCE.PROCESSDEFINITION_ column. Both indexes contain the same data, but maintaining the redundant copy costs the DBMS additional effort.

The standard MySQLDialect provided with Hibernate adds an index clause to every foreign key statement it generates. jBPM provides a slight MySQLDialect variation that does not add such index clause. In lieu of the "alter table..." statement presented earlier, the custom dialect yields the next statement:

alter table JBPM_PROCESSINSTANCE add constraint FK_PROCIN_PROCDEF foreign key (PROCESSDEFINITION_) references JBPM_PROCESSDEFINITION (ID_);
>>

In the issue description Jiri mentions that it is necessary to provide an update script to remove duplicates from db schemas created by older versions of the mysql script. The update script should be referenced from the release notes as well.

Comment 6 David Le Sage 2010-03-09 04:41:48 UTC
Hello Alejandro, 

Many thanks for the detailed feedback.  Much appreciated. The Release Note now reads as per the below:



https://jira.jboss.org/jira/browse/JBPM-2143

    The MySQL schema creation script used by jBPM versions prior to 3.2.9 contained statements
    that resulted in the duplicate creation of indices on table columns constrained by a foreign
    key. Both indices contained the same data but maintaining the redundant copy resulted in the
    DBMS doing additional work. This problem has been rectified by the addition of a customized
    MYSQLDialect. The standard MYSQLDialect provided with Hibernate adds an index clause to
    every foreign key statement it generates. jBPM provides a slight variant of MYSQLDialect that
    does not add such an index clause. As a result, the duplicates are no longer created.

    Note that an update script is being provided to remove duplicate indices from database schemas
    created by older versions of the MySQL script.


Comment 7 Jiri Pechanec 2010-03-23 14:50:10 UTC
The script to remove duplicated indices was not provided.

Comment 8 David Le Sage 2010-03-23 23:46:47 UTC
I have removed the para about the scripts at this stage.  It can be reinstated if they are provided before the release.

Comment 10 David Le Sage 2011-03-21 01:19:52 UTC
Release Notes Docs Status: Added: Not Required
Writer: Added: dlesage


Comment 11 David Le Sage 2011-03-21 01:30:42 UTC
Release Notes Docs Status: Removed: Not Required Added: Documented as Resolved Issue
Release Notes Text: Added: https://jira.jboss.org/jira/browse/JBPM-2143

The MySQL schema creation script used by jBPM versions prior to 3.2.9 contained statements
that resulted in the duplicate creation of indices on table columns constrained by a foreign
key. Both indices contained the same data but maintaining the redundant copy resulted in the
DBMS doing additional work. This problem has been rectified by the addition of a customized
MYSQLDialect. The standard MYSQLDialect provided with Hibernate adds an index clause to
every foreign key statement it generates. jBPM provides a slight variant of MYSQLDialect that
does not add such an index clause. As a result, the duplicates are no longer created.


Comment 12 David Le Sage 2011-04-07 23:58:49 UTC
Release Notes Docs Status: Removed: Documented as Resolved Issue Added: Documented as Known Issue
Release Notes Text: Removed: https://jira.jboss.org/jira/browse/JBPM-2143

The MySQL schema creation script used by jBPM versions prior to 3.2.9 contained statements
that resulted in the duplicate creation of indices on table columns constrained by a foreign
key. Both indices contained the same data but maintaining the redundant copy resulted in the
DBMS doing additional work. This problem has been rectified by the addition of a customized
MYSQLDialect. The standard MYSQLDialect provided with Hibernate adds an index clause to
every foreign key statement it generates. jBPM provides a slight variant of MYSQLDialect that
does not add such an index clause. As a result, the duplicates are no longer created. Added: https://jira.jboss.org/jira/browse/JBPM-2143

The MySQL schema creation script used by jBPM versions prior to 3.2.9 contains statements
that result in the creation of duplicate indices on table columns constrained by a foreign
key. Both indices contain the same data but maintaining the redundant copy means the 
DBMS has to do additional work. 


Comment 13 Len DiMaggio 2011-11-21 19:54:33 UTC
In the release notes for 4.3 CP05 - this issue is described as:

https://jira.jboss.org/jira/browse/JBPM-2143
    The MySQL schema creation script used by jBPM versions prior to 3.2.9 contains statements that result in the creation of duplicate indices on table columns constrained by a foreign key. Both indices contain the same data but maintaining the redundant copy means the DBMS has to do additional work.