"This pull request is already being merged" is displayed while merging a pull request
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
要約
Merging a pull request cannot be completed and the message "This pull request is already being merged
" is displayed.
As the message indicates, the pull request cannot be merged because the merge is already in progress.
This can occur in the following scenarios:
Case 1: More than one user tried to merge the pull request
There may be more than one user who tried to merge the same pull request at around the same time.
When the first user initiates the merge, the second user will not be able to merge the pull request and will receive the message.
Case 2: A user tried to merge the pull request several times
A user tried to merge a pull request more than once because the first try appears to take a long time.
The succeeding merge attempts will show the message while the first one is still in progress.
診断
Case 1
To investigate this case, check the access logs to see if more than one user attempted to merge at around the same time:
$BITBUCKET_HOME/log/atlassian-bitbucket-access*.log
Look for POST /rest/api/latest/projects/<PROJECT_KEY>/repos/<REPO_SLUG>/pull-requests/<PR_NUMBER>/merge
requests for a given project key, repo slug and pull request number close to the time the message was displayed.
The access logs will show the start and end times for the requests. For details on the Bitbucket access logs format, refer to:
If the requests from different users overlap, i.e. the merge request of the first user has not yet completed when the second user's merge request was started, the second request will get a 409 - Conflict
response.
10.204.102.32 | https | i*1HRRJ1Tx963x13580663x0 | - | 2020-12-29 16:03:50,496 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/123/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/123/diff" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
10.204.102.160 | https | i*1HRRJ1Tx965x13581762x5 | - | 2020-12-29 16:05:01,487 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/123/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/123/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | - | - | - | - | - | a1zvbx |
10.204.102.160 | https | o*1HRRJ1Tx965x13581762x5 | user2 | 2020-12-29 16:05:01,497 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/123/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/123/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | 409 | 213 | 164 | - | 9 | a1zvbx |
10.204.102.32 | https | o*1HRRJ1Tx963x13580663x0 | user1 | 2020-12-29 16:05:19,974 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/123/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/123/diff" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | 200 | 213 | 11937 | - | 89478 | fn81ur |
In these sample log entries, there were 2 merge requests:
- User1: started a merge at
2020-12-29 16:03:50,496
and it completed at2020-12-29 16:05:19,974
(request id:1HRRJ1Tx963x13580663x0
). Its response code was200 - OK
- User2: started a merge at
2020-12-29 16:05:01,487
, which was after user1's request and it ended at2020-12-29 16:05:01,497
(request id:1HRRJ1Tx965x13581762x5
). Its response code was409 - Conflict
If debug logging was enabled, the application log will show a com.atlassian.bitbucket.pull.IllegalPullRequestStateException
for the second request:
2020-12-29 16:05:01,496 DEBUG [http-nio-7990-exec-720] user2 *1HRRJ1Tx965x13581762x5 a1zvbx 10.204.102.160 "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/123/merge HTTP/1.1" c.a.s.i.r.e.ServiceExceptionMapper Mapping ServiceException to REST response 409
com.atlassian.bitbucket.pull.IllegalPullRequestStateException: This pull request is already being merged.
Case 2
Similar to Case 1, the access logs can be checked for overlapping POST /rest/api/latest/projects/<PROJECT_KEY>/repos/<REPO_SLUG>/pull-requests/<PR_NUMBER>/merge
requests for a given project key, repo slug and pull request number performed by the same user.
10.204.102.37 | https | i*1HRRJ1Tx715x17470628x3 | - | 2021-01-04 11:55:56,929 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/456/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/456/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | - | - | - | - | - | 1w2x8xj |
10.204.102.37 | https | i*1HRRJ1Tx716x17471516x17 | - | 2021-01-04 11:56:59,669 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/456/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/456/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | - | - | - | - | - | 1w2x8xj |
10.204.102.37 | https | o*1HRRJ1Tx716x17471516x17 | user3 | 2021-01-04 11:56:59,686 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/456/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/456/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | 409 | 167 | 164 | - | 17 | 1w2x8xj |
10.204.102.37 | https | o*1HRRJ1Tx715x17470628x3 | user3 | 2021-01-04 11:57:21,002 | "POST /rest/api/latest/projects/PROJECT1/repos/repo1/pull-requests/456/merge HTTP/1.1" | "https://bitbucket.myhost.com/projects/PROJECT1/repos/repo1/pull-requests/456/overview" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | 200 | 167 | 9358 | - | 84072 | 1w2x8xj |
In these sample entries, user3 performed 2 overlapping merge requests
- First was started at
2021-01-04 11:55:56,929
and completed at 2021-01-04 11:57:21,002
(request id:1HRRJ1Tx715x17470628x3
). Its response code was200 - OK
- Second was started at
2021-01-04 11:56:59,669
, which was after the first request and ended at2021-01-04 11:56:59,686
(request id:1HRRJ1Tx716x17471516x17
). Its response was409 - Conflict
The question in this scenario would be: why would the same user try to merge the same pull request more than once?
The user may have tried to merge the same pull request again because the first try was taking long.
To investigate further, debug logging and profiling can be enabled and then a similar merge can be attempted.
Profiling logs will show which processes are taking some time. For a sample case where this was observed, profiling logs showed that third-party plugins and custom hooks have contributed to the longer merge request completion.