Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-26007

Issue with Portfolio's table scanning behavior

XMLWordPrintable

      Issue Summary

      There looks to be a bug in Portfolio's DefaultSchemaProvider since 2016. It tries to map table names to schemas, according to the current DB contents (not config). It was never ready for a situation where a table name is duplicated across schemas. In such a case, the last schema on the list wins. The list is ordered however the SQL server sees fit.

      We can list duplicate tables:

      SELECT TABLE_NAME, COUNT(*) AS TABLE_NAME_COUNT
      FROM INFORMATION_SCHEMA.TABLES
      WHERE TABLE_TYPE='BASE TABLE'
      GROUP BY TABLE_NAME
      HAVING COUNT(*) > 1;
      

      Steps to Reproduce

      1. Prepare an instance with the default DB schema: 'dbo'
      2. Duplicate the tables, copying them from 'dbo' to another schema, e.g. named 'jiraschema' (they can be empty)
      3. Configure Portfolio to use "blocked by" issue links
      4. Link two issues with "blocked by"
      5. Add the two issues to a Portfolio plan
      6. Open the Dependency Report

      Expected Results

      The two linked issues are visible in the Dependency Report.

      Actual Results

      The Dependency Report does not contain the issues.

      Jira core sees issuelinks:

      EE: SELECT ID, LINKTYPE, SOURCE, DESTINATION, SEQUENCE FROM dbo.issuelink WHERE DESTINATION=? [DESTINATION=1161560]
      EE: results 1
      EE: SELECT ID, LINKTYPE, SOURCE, DESTINATION, SEQUENCE FROM dbo.issuelink WHERE SOURCE=? [SOURCE=1161560]
      EE: results 0
      EE: SELECT ID, LINKTYPE, SOURCE, DESTINATION, SEQUENCE FROM dbo.issuelink WHERE DESTINATION=? [DESTINATION=1161561]
      EE: results 0 
      

      ARJ doesn't see issuelinks:

      QD: select "link"."SOURCE", "link"."DESTINATION", "link"."LINKTYPE", "link"."ID" from "jiraschema"."issuelink" "link" where ("link"."LINKTYPE" in (?, ?)) and ("link"."SOURCE" in (?, ?) or ("link"."DESTINATION" in (?, ?))) [10240, 10540, 1161561, 1161560, 1161561, 1161560]
      QD: results 0
      QD: select "link"."SOURCE", "link"."DESTINATION", "link"."LINKTYPE", "link"."ID" from "jiraschema"."issuelink" "link" where ("link"."LINKTYPE" in (?, ?)) and ("link"."SOURCE" in (?, ?) or ("link"."DESTINATION" in (?, ?))) [10240, 10540, 1161561, 1161560, 1161561, 1161560]
      QD: results 0 
      

      The params and column names match. The query logic is equivalent. But the DB schema is different: dbo vs jiraschema.

      SELECT COUNT(*) FROM dbo.issuelink;
      > 3202
      
      SELECT COUNT(*) FROM jiraschema.issuelink;
      > 1573 
      

      Workaround

      Use Jira XML export. Import it on an instance without duplicated tables.

              kkanojia Kunal Kanojia
              97cfa19f8857 Ranjith Koolath
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: