Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-54039

[BP 7.2.0 MB-53416] Query returning incorrect number of documents

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.2.0
    • 7.0.1, 7.1.0, 7.2.0
    • query
    • Security Level: Public
    • Official Couchbase Docker Image
    • Untriaged
    • 1
    • Unknown

    Description

      We've encountered an issue with a query in Customer360 that isn't working correctly. We've reproduced the issue in a Docker container running Couchbase Server. With the documents attached (named in CB:  JIRA::ID) and indexes listed below, we believe the query should be returning two documents. However, the query only returns one. 

      Query:

      WITH capella_links AS (OBJECT result.link_id: result.issue_links FOR result IN (
              SELECT SPLIT(j.remote_link, "/")[-1] AS link_id,
                     ARRAY link FOR link IN TO_ARRAY(j.issue_links) WHEN link NOT LIKE "CCBSE-%" END AS issue_links
              FROM customer_dashboard j
              WHERE j.type = "JIRA::CCBSE"
                  AND j.remote_link IS NOT NULL) END)
      SELECT ARRAY account_name FOR account_name IN ARRAY_DISTINCT(ARRAY_FLATTEN(ARRAY_AGG(j.account_name),1)) WHEN account_name IS NOT NULL END AS accounts
      FROM `customer_dashboard` j
          JOIN `customer_dashboard` l ON KEYS ["JIRA::AV-10168"]
      WHERE j.type LIKE "JIRA::CBSE"
          AND l.id = "AV-10168"
          AND j.status = "Open"
          AND ARRAY_LENGTH(ARRAY_CONCAT(NVL(TO_ARRAY(j.issue_links), []), NVL(capella_links.[j.id], []))) > 0
          AND j.issue_type = "Improvement"
      GROUP BY l,
               j,
               capella_links
      ORDER BY COUNT(1) DESC,
               l.id ASC

      It appears there is something weird going on with this particular statement: 

      AND ARRAY_LENGTH(ARRAY_CONCAT(NVL(TO_ARRAY(j.issue_links), []), NVL(capella_links.[j.id], []))) > 0

      Indexes:

      CREATE INDEX `cbse_closed_links` ON `customer_dashboard`(`id`,`issue_type`,`issue_links`,`summary`,`components`) WHERE ((`type` = "JIRA::CBSE") and (`status` = "Open"))

      CREATE INDEX `customer_page_issues_index` ON `customer_dashboard`(`id`,(distinct (array `a` for `a` in `account_name` end)),`issue_links`,`summary`,`status`,`account_name`,`components`,`fix_versions`,`created`,`updated`,`assignee`,`business_impact`) WHERE ((`type` = "JIRA::CBSE") and (`issue_type` = "Improvement")) 

      Why is only one document returned from this query?

      Attachments

        1. JIRA_AV-10168.json
          0.7 kB
        2. JIRA_CBSE-10613.json
          0.4 kB
        3. JIRA_CBSE-12378.json
          0.5 kB
        4. JIRA_CCBSE-231.json
          0.4 kB
        5. JIRA_CCBSE-523.json
          0.5 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pierre.regazzoni Pierre Regazzoni
            Sitaram.Vemulapalli Sitaram Vemulapalli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty