# Bug OP-11910 - Adding new type to lot of projects with custom fields times out

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module |  |
| Target versions | 12.5.0 |
| Observed in versions |  |
| Sprint | 12.5.0 |
| 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 |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

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

## Costs

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

## Description

### Steps to reproduce

*Please write down the steps to reproduce. Try to write down all necessary preconditions (what permissions do you have, are other users involved?). Example:*

1.  Have a lot of projects (~2k)
2.  Have a lot of custom fields (unclear what's the threshold here)
3.  Add a new work package type
4.  Under Types \> Projects, select all projects to add it to

### What is the buggy behavior?

*Please describe the bug with as most details as possible. Example:*

  - The request times out after 120 seconds of execution time

### What is the expected behavior?

*Describe how the application should behave like. Example:*

1.  Request performs faster, or request is moved to the background

### Important note

*Please note that unless you are a contributor to OpenProject, you can no longer edit this bug report after saving. You can still add new comments, but no longer add any new images or other attachments. Please make sure that all necessary information and attachments are added, and the following attributes are set:*

### **Logs**

``` text
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: I, [2023-02-06T08:58:38.906019 #6908]  INFO -- : Completed 500 Internal Server Error in 121194ms (ActiveRecord: 36038.8ms | Allocations: 44396921)
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: F, [2023-02-06T08:58:38.907100 #6908] FATAL -- :
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: Rack::Timeout::RequestTimeoutException (Request ran for longer than 120000ms , sending SIGTERM to process 6908):
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]:   
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:186:in `block in set_active_custom_fields_for_projects'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:186:in `set_active_custom_fields_for_projects'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:191:in `set_active_custom_fields_for_project_ids'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:83:in `set_params_and_validate'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:54:in `block in update'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:53:in `update'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/base_type_service.rb:42:in `call'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/services/update_type_service.rb:36:in `call'
Feb 06 08:58:38 kvmua612 openproject-web-1.service[6908]: app/controllers/types_controller.rb:85:in `update'
```

### 

### Environment information

*Please check and fill out the following details to help us identify in what versions and distributions of OpenProject the error occurs*

**OpenProject installation type**

- [ ] Hosted cloud edition
- [x] Packaged installation
    - What distribution?
- [ ] Docker All-in-one container
- [ ] Docker-compose installation
- [ ] Other (please specify)
