Uploaded image for project: 'Atlassian Ecosystem'
  1. Atlassian Ecosystem
  2. ECO-313

Custom Entity Store index returning empty results with pagination cursor when no filters applied for query after re-installation of app

    • Severity 3 - Minor
    • Hide

      A short term fix has been put in place that from our monitoring shows has resolved this bug currently for all sites however the mitigation has added a latency increase to requests that would be impacted.

      The long term fix is in progress by the team currently.

      Show
      A short term fix has been put in place that from our monitoring shows has resolved this bug currently for all sites however the mitigation has added a latency increase to requests that would be impacted. The long term fix is in progress by the team currently.
    • Pre-deployment testing

      Issue Summary

      Some Custom Entity store query results are returning an empty object while providing a cursor when not specifying any filters which is not expected behaviour when the app has been reinstalled.

      This is being caused by how we ensure installation isolation and is happening when an app has been reinstalled with data from the previous installation having multiple entities that matched the index . This is filtering data on the indexes which is leading to 0 results being returned to apps but including a next page pagination cursor. This is only an issue with the index itself but the underlying data is still present and accessible through normal get operations.

      We have put a mitigation in place that we believe resolves the issue however this has led to a latency increase for any request that runs into the issue.

      We are actively working on a permanent fix that will resolve this issue and remove any latency impact for requests impacted by this scenario.

       

      This is reproducible on Data Center: no

      Steps to Reproduce

      1. Create an app using a CE scheme

       

      app:
        id: "ari:cloud:ecosystem::app/<appid>"
        storage:
          entities:
            - name: employee
              attributes:
                surname: 
                  type: string
                age: 
                  type: integer
                employmentyear: 
                  type: integer
              indexes:
                - name: by-age
                  range: 
                    - age 

      2. Install app into test site

      3. Store 40 items using that schema using function code like

       

      [ ...Array(40)].forEach((_, i) => {
        storage.entity("employee").set('oldKey' + i, {
            surname:"Davis",
            age: 30,
            employmentyear: 2022,
        });
      }) 

       

      4. Uninstall the app from test site

      5. Reinstall the app to test site

      6. Store an item using that schema

      storage.entity("employee").set('newKey', {
            surname:"Davis",
            age: 30,
            employmentyear: 2022,
      }); 

      7. Query index for item just saved

      const result = await storage
        .entity("employee")
        .query()
        .index("by-age")
        .where(WhereConditions.isGreaterThan(29))
        .limit(2)
        .getMany()
      console.log(result) 

      Expected Results

      Returns object with results array containing last item stored with an empty nextCursor object

      {
        results: [
          {
            key: 'newKey'
            value: {
              surname:"Davis",
              age: 30,
              employmentyear: 2022,
            }
          }
        ],
        nextCursor: undefined
      } 

      Actual Results

      Returns object with empty results array and cursor to next page

      {
        results: []
        nextCursor: '<stringContainingCursorValue>'
      } 

      Workaround

      Use provided cursor to fetch next page until results are returned

            [ECO-313] Custom Entity Store index returning empty results with pagination cursor when no filters applied for query after re-installation of app

            We have rolled out a fix for this problem and this should not be happening anymore.

            Rodolfo Candido added a comment - We have rolled out a fix for this problem and this should not be happening anymore.

              22714193a617 Rodolfo Candido
              ldurkan Skywalker
              Affected customers:
              3 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: