JIRA development panel information is out of sync with Bitbucket Server

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

 

Summary

There is a discrepancy between the data shown in JIRA's development tool information and what's really in Bitbucket Server. For old branches/issues, this data will never get refreshed.

This out of sync situation can be observed:

a) At the Development Panel summary, when editing an issue;

 


b) At the Release Data page, when selecting a release and expanding the list of issues with the Release status per issue.

Diagnosis


  • Even if the application links are healthy and Jira is syncing with Bitbucket Server for further updates (Pull Requests, commits, etc.), ones that got stale due to some error situation or timeouts, will have to be forced synced.
  • The information provided at the Development Panel Summary, when editing an issue or when listing the issues from one release, are gathered from the AO_575BF5_DEV_SUMMARY table. The JSON_VALUE column contains the status information data (which holds status) for that particular issue:

SELECT * FROM "AO_575BF5_DEV_SUMMARY" WHERE "JSON" LIKE '%<issue-key>%';


  • Here is the breakdown of data when queried to the AO_575BF5_DEV_SUMMARY table. There could be multiple rows in the table for this issue key, but it is important to decide which object types we are after (for example commit, pull requests, branches, etc.):

    2021-05-03 04:25:32.986 | 9989027 | 6411084 | {"value":{"targets":{"XYZ-1943":[{"type": {"id":"repository"}
    ,"objects":[
    {"lastUpdated":"2021-05-04T17:11:28.000+0000","count":4,"commits":["f770e5059233f0313ce6158f921cd2b507e8acc3","ee2d26c7406f3ac03c2f96d55fcdc5b039efa9b9","420a69758ca30a1a40291f0801b5fea52522bc11","17b37a42f4cfc31a7504d45f40c9745781f775d3"],"type":"git"}
    ]},{"type":
    
    {"id":"branch"}
    ,"objects":[
    {"lastUpdated":"2021-05-04T17:11:45.162+0000","count":1,"branches":["bugfix/XYZ-1943_Things_are_not_working"]}
    ]},{"type":
    
    {"id":"pullrequest"}
    ,"objects":[
    {"lastUpdated":"2021-05-04T17:11:45.162+0000","state":"OPEN"}
    ]}]}},"expiry":9223371721494775807} | xxxxxxxxxx-a875-39ec-98a0-xxxxxxxxx | 2021-05-04 17:11:45.693
  1.  In the JSON above there are three objects repository, branch, pull request.
  2. Pick the object we need correction on, here pull request.
  3. Make sure that long id xxxxxxxxxx-a875-39ec-98a0-xxxxxxxxx in pull request object type corresponds to the id of app link where the Pull Request is coming from. You can do that by clicking on the edit link for that app link in the UI and the browser nav bar will show that ID(quickest). You can of course check DB for it too :)
  4. Notice state is OPEN, which is not the same as Bitbucket Server's actual Pull Request state.
  5. Expiry attribute, that is how Bitbucket Server determines which objects to re-sync/sync.


Cause

The information provided by Jira at the Development Panel Summary and at the Release Data is collected from the Jira AO_575BF5_DEV_SUMMARY table. The detailed information, gathered when we click at the Pull Request, Commit, or Branch links is gathered from Bitbucket Server, using the REST API.

One of the possible causes for this issue is the Bitbucket Server issue  BSERV-9452 - Getting issue details... STATUS The link aggregation result is returning cached data, and the other REST call is returning data from the pull request table. The latter will always be correct since it's the real data, but since those branches aren't in use now the cached data will never get updated again. 

Solution

Option #1: Expiry date on Jira, forcing to get an update from Bitbucket Server

We can force sync the state of stale object types from Bitbucket Server by updating the expiry property of pull request in that particular row of AO_575BF5_DEV_SUMMARY table.

  1. Copy the JSON content returned by the query to a text editor: 

    SELECT * FROM "AO_575BF5_DEV_SUMMARY" WHERE "JSON" LIKE '%<issue-key>%';
  2. Using any Unix Timestamp converter, calculate a date in the past, for instance, 08/25/2021 4:48 pm UTC corresponds to the Unix Timestamp 1619894065;
  3. On the text editor, replace the expiry information (on our sample, the previous value was "expiry":9223371721494775807) with the Expiry date in the past ("expiry":1619894065);
  4. Run the Update query below using the new JSON value prepared on the text editor and commit the changes:  

    Postgres sample
    update "AO_575BF5_DEV_SUMMARY" 
    set "JSON" = '{"value":{"targets":{"XYZ-1943":[{"type":{"id":"repository"},"objects":[{"lastUpdated":"2021-05-04T17:11:28.000+0000","count":4,"commits":["f770e5059233f0313ce6158f921cd2b507e8acc3","ee2d26c7406f3ac03c2f96d55fcdc5b039efa9b9","420a69758ca30a1a40291f0801b5fea52522bc11","17b37a42f4cfc31a7504d45f40c9745781f775d3"],"type":"git"}]},{"type":{"id":"branch"},"objects":[{"lastUpdated":"2021-05-04T17:11:45.162+0000","count":1,"branches":["bugfix/XYZ-1943_Things_are_not_working"]}]},{"type":{"id":"pullrequest"},"objects":[{"lastUpdated":"2021-05-04T17:11:45.162+0000","state":"OPEN"}]}]}},"expiry":1619894065}'
    where "ISSUE_ID" = 6411084 and "PROVIDER_SOURCE_ID" = 'xxxxxxxxxx-a875-39ec-98a0-xxxxxxxxx';
    
    commit; 
  5. Wait for the refresh to happen in the issue or reload the issue.


Option #2: Reindex Bitbucket Server and force a new event to send an update to Jira

  1. Use the following endpoint to run a reindex on Bitbucket Server using a user with Bitbucket Server admin access:

    • Curl Command using User authentication: 

      curl -v -u <username> -p -H "Accept: application/json" -k -H "Content-Type: application/json" -d "{}" <bitbucket URL>/rest/jira-dev/1.0/projects/<project key>/repos/<repository slug>/reindex
    • Sample for the project SUP_CM and the repository playground

      curl -v -u <username> -p -H "Accept: application/json" -k -H "Content-Type: application/json" -d "{}" <bitbucket URL>/rest/jira-dev/1.0/projects/SUP_CM/repos/playground/reindex
      Notes:
      • The request should return HTTP Response 204.
      • If the authentication was not accepted, use Personal access tokens for authentication:


      curl -v -p -H 'Authorization: Bearer MDM0MjM5NDc2MDxxxxxxxxxxxxxxxxxxxxx' -H "Accept: application/json" -H "Content-Type: application/json" -d "{}" <bitbucket URL>/rest/jira-dev/1.0/projects/SUP_CM/repos/playground/reindex
      
      
  2. Create a new Pull Request and merge it, to force a new update on Jira.
  3. Wait for the refresh to happen in the issue or reload the issue.



Last modified on Feb 28, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.