How to fix an issue when custom fields are getting locked

Problem Statement

When migrating a project from one server to another using the Configuration Manager for Jira app, the custom fields that were migrated earlier are getting locked.

Error Message 

Log Entries 

2023-03-03 17:45:39,716+0000 HealthCheck:thread-1 ERROR ServiceRunner [c.a.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event [com.atlassian.applinks.analytics.ApplinksRequestExecutionEvent@fd213e0] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.atlassian.webhooks.plugin.WebHookEventsProcessor.onEvent(java.lang.Object), listener=com.atlassian.webhooks.plugin.WebHookEventsProcessor@ea2a378}] java.lang.RuntimeException: attempt to unlock read lock, not locked by current thread. Listener: com.atlassian.webhooks.plugin.WebHookEventsProcessor event: com.atlassian.applinks.analytics.ApplinksRequestExecutionEvent at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.IllegalMonitorStateException: attempt to unlock read lock, not locked by current thread

Environment

Application

Jira

Platform

Server/Datacenter

Cause

The issue occurs if the property configuration item access level of the custom fields is set to ADMIN on target and LOCKED on source. This difference is displayed in the deployment wizard i.e. target custom fields' configuration item access level and will be modified to LOCKED.

Always back up the data before performing any modifications to the database. Test any alter, insert, update, or delete SQL commands on a staging Jira server/datacenter first.

Solution

Steps to unlock the custom field from the database.

  1. Run the following query via the database to determine the Jira Software custom field IDs:
    select * from customfield;

  2. Match the id of the field that needs to be unlocked with the relevant entry in the managedconfigurationitem table's item_id column.
    select * from managedconfigurationitem;

  3. Set the managed column to false for any field that needs to be unlocked. For example, the below query unlocks Epic Status and Epic Colour:
    UPDATE managedconfigurationitem set managed='false' where item_id in ('customfield_10208','customfield_10209');

  4. After the above change, the 'access_level' column will remain with the 'LOCKED' value, but the custom fields will be unlocked from the UI.

  5. Make the required changes to the fields.

  6. Lock the fields that were unlocked by setting the managed column to true. For example, the below query locks Epic Status and Epic Colour:
    UPDATE managedconfigurationitem set managed='true' where item_id in ('customfield_10208','customfield_10209');

These fields are locked again on startup by automated tasks within the apps.

There is an Atlassian KB article that talks about changing and checking custom fields' configuration item access level i.e. locked status.

https://confluence.atlassian.com/jirakb/unlock-a-locked-jira-software-custom-field-779158866.html

ADMIN option is similar to LOCKED option i.e., custom field is locked for all others except for admins.

https://docs.atlassian.com/software/jira/docs/api/7.2.1/com/atlassian/jira/config/managedconfiguration/ConfigurationItemAccessLevel.html