History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-984
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Robin Shen
Reporter: Karim Heredia
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
QuickBuild

Creating a new authorization with non-existing group should fail

Created: 14/Jul/11 09:01 AM   Updated: 08/Aug/11 07:26 AM
Component/s: None
Affects Version/s: 3.1.51
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Linux 64-bit


 Description  « Hide
I created a XML that looks like this one:

<com.pmease.quickbuild.model.Authorization>
 <configuration>1</configuration>
  <group>2621</group>
  <permissions>
    <string>ACCESS_SETTINGS</string>
    <string>PROMOTE_BUILD</string>
    <string>ACCESS_BUILD_LOG</string>
    <string>EDIT_SETTINGS</string>
    <string>PMD REPORT</string>
    <string>ADD_CHILDREN</string>
    <string>STOP_BUILD</string>
    <string>RUN_BUILD</string>
    <string>NUNIT REPORT</string>
    <string>FINDBUGS REPORT</string>
    <string>ACCESS_BUILD_CHANGES</string>
    <string>ACCESS_BUILD_STEPS</string>
    <string>MODIFY_BUILD</string>
    <string>EMMA REPORT</string>
    <string>JUNIT REPORT</string>
    <string>COBERTURA REPORT</string>
    <string>CHECKSTYLE REPORT</string>
    <string>ACCESS_STATISTICS</string>
    <string>NCOVER REPORT</string>
    <string>ACCESS_BUILD_VARIABLES</string>
    <string>CPD REPORT</string>
    <string>TESTNG REPORT</string>
    <string>MBUNIT REPORT</string>
    <string>FXCOP REPORT</string>
  </permissions>
</com.pmease.quickbuild.model.Authorization>

Note: Group 2621 **does not** exist and was added there by mistake.

Posted it via REST API like this (used it several times with other authorizations):

   curl -k -s -X POST -u karim.heredia:**** -d@myauth.xml https://server.com/rest/authorizations

Authorization is created and an ID is returned.

However, from there on, the server log starts getting full with this exception:

   jvm 1 | org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.pmease.quickbuild.model.Group#2621]

Also, getting the resource https://server.com/rest/authorizations gives the same exception. I had to manually get into the database and remove the offending row.
 


 All   Comments   Work Log   Change History      Sort Order:
Robin Shen [14/Jul/11 10:14 AM]
The POST operation should fail as this operation will violate the foreign key constraint in database. Can you please check the table QB_AUTHORIZATION in database to see if the field FK_AUTH_GROUP is defined as a foreign key into table QB_GROUP. If not, please export/import data again to see if the foreign key can be created.


Karim Heredia [25/Jul/11 08:44 AM]
Hi Robin,

This is what I see directly on the database. We haven't made any modification, except migrations since the first 2.1.x version we have installed. Also, I thought that when we migrated to 3.1.51, I saw that the migration process actually exports the data, recreates the database and then imports the data; if this is the case, foreign keys should be created there, correct?

{code}
mysql> select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where TABLE_NAME='QB_AUTHORIZATION';
+------------------+---------------------+---------------------+-----------------------+------------------------+
| TABLE_NAME | COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+------------------+---------------------+---------------------+-----------------------+------------------------+
| QB_AUTHORIZATION | QB_ID | PRIMARY | NULL | NULL |
| QB_AUTHORIZATION | QB_CONFIGURATION_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_GROUP_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_ID | PRIMARY | NULL | NULL |
| QB_AUTHORIZATION | QB_CONFIGURATION_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_GROUP_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_ID | PRIMARY | NULL | NULL |
| QB_AUTHORIZATION | QB_CONFIGURATION_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_GROUP_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_ID | PRIMARY | NULL | NULL |
| QB_AUTHORIZATION | QB_CONFIGURATION_ID | QB_CONFIGURATION_ID | NULL | NULL |
| QB_AUTHORIZATION | QB_GROUP_ID | QB_CONFIGURATION_ID | NULL | NULL |
+------------------+---------------------+---------------------+-----------------------+------------------------+
12 rows in set (0.00 sec)

mysql> select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where TABLE_NAME='QB_GROUP';
+------------+-------------+-----------------+-----------------------+------------------------+
| TABLE_NAME | COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+------------+-------------+-----------------+-----------------------+------------------------+
| QB_GROUP | QB_ID | PRIMARY | NULL | NULL |
| QB_GROUP | QB_NAME | QB_NAME | NULL | NULL |
| QB_GROUP | QB_ID | PRIMARY | NULL | NULL |
| QB_GROUP | QB_NAME | QB_NAME | NULL | NULL |
| QB_GROUP | QB_ID | PRIMARY | NULL | NULL |
| QB_GROUP | QB_NAME | QB_NAME | NULL | NULL |
| QB_GROUP | QB_ID | PRIMARY | NULL | NULL |
| QB_GROUP | QB_NAME | QB_NAME | NULL | NULL |
+------------+-------------+-----------------+-----------------------+------------------------+
8 rows in set (0.01 sec)
{code}

Robin Shen [26/Jul/11 01:43 AM]
The database seems to be created incorrectly: there is no foreign keys created. Please do the following to see if foreign keys can be created:
1. backup the database from QuickBuild administration page.
2. drop the quickbuild schema from mysql.
3. create a blank schema using the same name as above.
4. run "bin/restore.bat" to restore the database from the backup created in step 1.

Then please examine if the foreign key exists, if not, please let me know your MySQL version, JDBC driver version, database style (innodb, isam, etc.)

Karim Heredia [06/Aug/11 09:19 PM]
I did as instructed:

1. Created a backup
2. drop table quickbuild;
3. create table quickbuild;
4. <QB server>/bin/restore.sh backup.zip

All data is back in. When checking the information schema, I get the exact same results as above.

MySQL version (one is an older server that ran QB for 1 year, the other is a new server we are using since 3 months ago):

mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2
mysql Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (x86_64) using readline 6.1

JDBC: mysql-connector-java-5.1.16

Tables are MyISAM

Robin Shen [07/Aug/11 12:52 AM]
Please use innodb instead as myisam does not support foreign keys. To do so:
1. Backup QB database via QB administration page.
2. Shutdown QB.
3. Edit /etc/my.cnf to change "default-storage-engine" from "MYISAM" to "innodb".
4. Restart MySQL service.
5. Drop quickbuild schema and create a blank one with the same name.
6. Restore backup to database by running "bin/restore".
7. Check if all tables created are of "innodb" type, and if "QB_AUTHORIZATION" has foreign keys pointing to QB_CONFIGURATION and QB_GROUP.

We will also modify the hibernate.properties to emphasize that "innodb" should be used as the default storage engine.

Karim Heredia [08/Aug/11 06:10 AM]
Please also document it in here: http://wiki.pmease.com/display/QB31/Data+Management

We have been using QB for a while now, but I haven't seen instructions to use InnoDB anywhere.

Robin Shen [08/Aug/11 07:26 AM]
Mentioned in data management section now.