# Bug JIM-244 - Jira migration fails with PostgreSQL statement timeouts during work package creation

Project: Stream Jira to OpenProject data Migrator
Status: closed
URL: https://community.openproject.org/work_packages/JIM-244

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Immediate |
| Module |  |
| Target versions | 18.0.0 |
| Observed in versions |  |
| Sprint | Sprint 25.11.-01.12.2026 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee | Alfonso Mancilla |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### Steps to reproduce

1.  Configure a Jira migration and select multiple projects.
    
2.  Start the import.
    
3.  During stage 8, “Create work packages”, several project import jobs fail with PostgreSQL statement timeouts.
    

### What is the buggy behavior?

Eight project import jobs failed while creating work packages.

Seven reported the same error, with different physical tuple coordinates:

`ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout`  
`CONTEXT: while inserting index tuple (53,14) in relation "jira_open_project_references"`

Another job reported:

`ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout`  
`CONTEXT: while locking tuple (53,18) in relation "jira_open_project_references"`

All eight failures occurred through the same call path:

`app/workers/import/jira_open_project_reference_creation.rb:36:in 'Import::JiraOpenProjectReferenceCreation#create_reference!'`  
`app/workers/import/jira_create_project_work_packages_job.rb:177:in 'Import::JiraCreateProjectWorkPackagesJob#create_type'`

The failures affected both small and large projects, at different points in their progress.

### Suspected cause

I suspect this is related to the parallelisation of Jira project imports introduced in OpenProject 17.9.0. This hypothesis has not yet been confirmed.

The importer writes a type reference for each issue using `upsert_all`, with a unique key on: `(jira_import_id, op_entity_id, op_entity_class)`

This reference can be shared by several projects within the same import.

The reference write happens inside a transaction that also includes work package creation and the import of its history and comments. Concurrent project jobs using the same type may therefore wait for one another until the statement timeout is reached.

### Planned verification

I will rerun the import with the following setting on the worker: `OPENPROJECT_GOOD__JOB__MAX__THREADS: "1"`.

The deployment will use a single worker container for this test, to check whether processing the project jobs sequentially avoids these failures.  
I will report the result afterward.

### What is the expected behavior?

The migration should complete without statement timeouts caused by concurrent writes to shared Jira/OpenProject references.

### Environment information

*   OpenProject 17.9.0
    
*   Docker Compose deployment on a server
    
*   Migration of multiple Jira projects in a single import run
    
*   Browser : Chrome
