[ 
https://issues.apache.org/jira/browse/SQOOP-1625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14186511#comment-14186511
 ] 

Qian Xu edited comment on SQOOP-1625 at 10/28/14 7:34 AM:
----------------------------------------------------------

Patch provided. {{ADD CONSTRAINT .. UNIQUE}} was happened every time when 
upgrade happens. Now it will happen once if repository version is less than 4. 

Unittest has been changed. Previously unittest will insert records into 
{{SQ_JOB}} with an identical job name. Note that the constraint requires 
{{SQB_NAME}} of job is to be unique. If you think {{SQB_NAME}} and {{SQB_TYPE}} 
should be unique, better open another jira for that.


was (Author: stanleyxu2005):
Patch provided. `ADD CONSTRAINT` was happened every time when upgrade happens. 
Now it will happen once if repository version is less than 4. Unittest has been 
changed. Previously unittest will insert records into SQ_JOB with an identical 
job name.

> Repository upgrade issue
> ------------------------
>
>                 Key: SQOOP-1625
>                 URL: https://issues.apache.org/jira/browse/SQOOP-1625
>             Project: Sqoop
>          Issue Type: Bug
>    Affects Versions: 1.99.4
>            Reporter: Qian Xu
>            Assignee: Qian Xu
>         Attachments: SQOOP-1625.patch
>
>
> I'm facing such a situation. 
>  1. I recompile the project without changing anything.
>  2. I replace old binaries with newly built binaries (derby's repository is 
> kept unchanged)
>  3. I restart Sqoop2 server, it will trigger an upgrade check. 
> As the repository version is not incremented, I expect nothing to be update. 
> But I see a SQL error:
> {code}
> Caused by: ERROR 42Z93: Constraints 'FK_SQB_NAME_UNIQUE' and 
> 'FK_SQB_NAME_UNIQUE' have the same set of columns, which is not allowed.
> {code}
> In DerbyRepositoryHandler.java, constraints will be added to repository, if 
> repository version is greater than 3, Sqoop will attempt to add particular 
> constraints repeatedly. I'm afraid this will fail. 
> {code}
>     // Add unique constraints on job and links for version 4 onwards
>     if (repositoryVersion > 3) {
>       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_UNIQUE_CONSTRAINT_NAME, conn);
>       runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_UNIQUE_CONSTRAINT_NAME, conn);
>       
> runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIGURABLE_ADD_UNIQUE_CONSTRAINT_NAME, 
> conn);
>     }
> {code}
> So I'm thinking, whether we should do as follows:
>  1. Increase the current repository version to 5 (instead of 4) and
>  2. Change the following code
> {code}
>     // original
>     if (repositoryVersion > 3) {
>     // proposed
>     if (repositoryVersion <= 4) {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to