Unable to clone plan - This plan name already exists
Asked by Steve Holzer:

A plan was cloned, then deleted.  
The logs show the plan was deleted.  
An attempt to clone the plan again returns the following two messages.  

This plan name already exists.

This key is used by a plan scheduled for deletion. Please try again in a couple of minutes.  

I can find no reference to the full key.   
No plans in the build table are showing as marked for deletion.   

How can we clear this state from Bamboo so that the plan can be created.   

The clone can be created using different plan name and key but this is not a workable solution for the team creating this plan.

This is a single node instance of Bamboo using PostgreSQL for backend.


Answers:
author: Eduardo Alvarenga
body: Hello [@Steve Holzer](/t5/user/viewprofilepage/user-id/749490)

That should work. I have tried reproducing your steps but could successfully clone the Plan giving it the same key as the deleted one and by using the cloned one as the source.

Please make sure to wait for Bamboo to purge the plan completely. It should take around 5 minutes or less. You should see messages such as the following in the logs:

```
2023-03-09 10:37:44,840 INFO [https-jsse-nio-45825-exec-23 url: /ajax/deleteChain.action; user: ealvarenga] [DeletionServiceImpl] Stopping any running builds for STEV-S1
2023-03-09 10:37:44,842 INFO [https-jsse-nio-45825-exec-23 url: /ajax/deleteChain.action; user: ealvarenga] [DeletionServiceImpl] Scheduling plan [STEV-S1] for deletion
2023-03-09 10:37:44,845 INFO [https-jsse-nio-45825-exec-23 url: /ajax/deleteChain.action; user: ealvarenga] [DeletionServiceImpl] Stopping any running builds for STEV-S1-JOB1

...
2023-03-09 10:39:31,779 INFO [DelayedDeletionThread] [DeletionServiceHelper] Deleting 1 job(s) marked for deletion
2023-03-09 10:39:31,780 INFO [DelayedDeletionThread] [DeletionServiceHelper] Deleting STEV-S1-JOB1
2023-03-09 10:39:31,932 INFO [DelayedDeletionThread] [ImmutablePlanCacheServiceImpl] Skipping invalidation, plan is being deleted: STEV-S1
2023-03-09 10:39:31,932 INFO [scheduler_Worker-3] [DeletionServiceHelper] Completed background deletion in 162.1 ms
2023-03-09 10:39:31,939 INFO [DelayedDeletionThread] [DeletionServiceHelper] Deleting 1 stage(s) marked for deletion
2023-03-09 10:39:31,939 INFO [DelayedDeletionThread] [PlanManagerImpl] Removing 1 stage(s) for plan STEV-S1
2023-03-09 10:39:31,950 INFO [DelayedDeletionThread] [ImmutablePlanCacheServiceImpl] Skipping invalidation, plan is being deleted: STEV-S1
2023-03-09 10:39:31,950 INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-25] [DeletionServiceHelper] Completed background deletion in 17.64 ms
2023-03-09 10:39:31,959 INFO [DelayedDeletionThread] [DeletionServiceHelper] Deleting 1 TopLevelPlan(s) and/or ChainBranch(es) marked for deletion
2023-03-09 10:39:31,959 INFO [DelayedDeletionThread] [DeletionServiceHelper] Deleting STEV-S1
```

Then try cloning it again.

If that doesn't work, please reach out to Atlassian Support at <https://support.atlassian.com/contact> as we'll need to investigate the issue further.

Kind regards,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Steve Holzer
body: Hello Eduardo,  
Thanks for your response.  
The issue seems to involve a Deletion Service bug and the team will need to work with Atlassian support to see if the issue can be fixed. There is risk here with this approach.  

What has happened is that all plans mentioned in the application log have been successfully removed. No reference to them can be found in the database.  

So on this instance all plans that get deleted are deleted, but due to the state of the deletion service, because of the bug, it never completes and so you can't use the plan name or key after that.

Application restart does not help.   

Regards,

Steve


author: Eduardo Alvarenga
body: Hello [@Steve Holzer](/t5/user/viewprofilepage/user-id/749490)

Indeed it would be important to raise a case with Atlassian Support to have that investigated further. As mentioned, we were not able to reproduce it on the latest Bamboo release 9.2.1 and also on 8.2.5 by following the guidelines you have provided.

We are legitimately interested to find out more about it. When opening the case with Atlassian, kindly mention this community question to speed up things.

Alternatively, if you have the means to literally reproduce it you can open a BAM bug directly at <https://jira.atlassian.com>.

Cheers,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


Tags: server