Find old or outdated open pull requests

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

For large or Data Center instances you should suspect there are alot of open pull requests that have not been updated in a while and are still open.  In a large Bitbucket Data Center environment this can add up to be a large number.  Each time the repository is updated, each open pull request needs to be evaluated to see if it needs to be updated.  This can add to the background load.  Closing out old open pull request can improve Bitbucket Data Center performance.

Having a small set of open pull request on a repository is normal.  It is not abnormal to have 50 to 100 open pull requests for a repository.

Diagnosis

This SQL will show you all of the pull request that have had 1000+ rescopes and the last time the pull request was updated.  This can indicate the age of the pull request.  You can change the value to 500 or 100 to see how extensive the problem is on Bitbucket by changing the value:  pr.entity_version > 1000 ← Here.

problem pull requests
SELECT p.project_key, 
       r.slug, 
       pr.scoped_id, 
       pr.entity_version, 
       pr.updated_timestamp 
FROM   sta_pull_request pr 
       JOIN repository r 
         ON pr.to_repository_id = r.id 
       JOIN project p 
         ON r.project_id = p.id 
WHERE  pr.pr_state = 0 
       AND pr.entity_version > 1000 
ORDER BY pr.entity_version desc;

This SQL will groups the pull request by project so you can isolate a particularly problematic project.

Problem Projects
SELECT p.project_key, 
       Count(1) 
FROM   sta_pull_request pr 
       JOIN repository r 
         ON pr.to_repository_id = r.id 
       JOIN project p 
         ON r.project_id = p.id 
WHERE  pr.pr_state = 0 
       AND pr.entity_version > 1000 
GROUP  BY p.project_key
ORDER BY 2 desc; 


Cause

Sometimes pull request do take an extended period of time to evaluate if they need to be merged.  But sometimes pull request get lost in the shuffle.  Remember open pull request might be needed.  Except for only the most obvious of cases, Only a developer of the code can know if the pull request should be closed.

Solution

Request that the owners of the repository close some of the older pull requests.

We are gathering impact for this Feature Request:

BSERV-11778 - Getting issue details... STATUS

Last modified on Apr 1, 2021

Was this helpful?

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