# Bug OP-20613 - Project copy blocks all work package creates until the copy completes

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-20613

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 17.9.5 |
| Observed in versions |  |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | Oliver Günther |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Use OpenProject 17.9.
    
2.  Open a project with many work packages, for example a template with several thousand work packages and attachments.
    
3.  Copy the project.
    
4.  While the copy runs, create a work package in a different project, in the UI or through the API.
    

### Actual behavior

*   The work package create, parent changes, and more in the other project waits until the project copy is completed.
    

### Expected behavior

A running project copy does not block work package creates, parent changes or deletes in other projects. While the copy runs, it may block other changes only for a short time.

### Environment

*   OpenProject 17.9.0 and later. OpenProject 17.8 does not have the problem.
    

### Technical notes

*   closure\_tree takes an advisory lock each time it updates the work package hierarchy (create, parent change, delete). The lock has the same name for all work packages, and PostgreSQL advisory locks apply to the whole database.
    
*   closure\_tree 9.8.0 (bumped in 17.9.0) keeps this lock until the outermost transaction commits, if the update runs at the first transaction level. See [ClosureTree/closure\_tree@b4eb3df](https://github.com/ClosureTree/closure_tree/commit/b4eb3df89dd4f7a4151a7f6204842661b219b241).
    
*   A project copy runs as one transaction. So the first copied work package takes the lock, and the copy keeps it until the whole copy commits.
    
*   With closure\_tree 9.7, the lock was released after each work package.
