# HG changeset patch # User Marcin Kuzminski # Date 2018-06-11 13:35:54 # Node ID d0af9af8ab818c267d598d54a00496896d357438 # Parent e8c62649d62212df4a7376d84005b3706c64a4ae pull-requests: fix problem with long DB transaction and row-locking. fixes #5470 diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -510,6 +510,7 @@ class PullRequestModel(BaseModel): reviewer.rule_data = rule_data Session().add(reviewer) + Session().flush() # Set approval status to "Under Review" for all commits which are # part of this pull request. @@ -519,7 +520,13 @@ class PullRequestModel(BaseModel): user=created_by_user, pull_request=pull_request ) + # we commit early at this point. This has to do with a fact + # that before queries do some row-locking. And because of that + # we need to commit and finish transation before below validate call + # that for large repos could be long resulting in long row locks + Session().commit() + # prepare workspace, and run initial merge simulation MergeCheck.validate( pull_request, user=created_by_user, translator=translator) @@ -1629,7 +1636,7 @@ class MergeCheck(object): if fail_early: return merge_check - # merge possible + # merge possible, here is the filesystem simulation + shadow repo merge_status, msg = PullRequestModel().merge_status( pull_request, translator=translator, force_shadow_repo_refresh=force_shadow_repo_refresh)