@@ -305,6 +305,7 @@ func resourceRedisCloudEssentialsDatabaseCreate(ctx context.Context, d *schema.R
305305 subId := d .Get ("subscription_id" ).(int )
306306
307307 utils .SubscriptionMutex .Lock (subId )
308+ defer utils .SubscriptionMutex .Unlock (subId )
308309
309310 createDatabaseRequest := fixedDatabases.CreateFixedDatabase {
310311 Name : redis .String (d .Get ("name" ).(string )),
@@ -426,7 +427,6 @@ func resourceRedisCloudEssentialsDatabaseCreate(ctx context.Context, d *schema.R
426427 databaseId , err := api .Client .FixedDatabases .Create (ctx , subId , createDatabaseRequest )
427428 if err != nil {
428429 log .Printf ("[ERROR] FixedDatabases.Create failed for subscription %d: %v" , subId , err )
429- utils .SubscriptionMutex .Unlock (subId )
430430 return diag .FromErr (err )
431431 }
432432 log .Printf ("[DEBUG] FixedDatabases.Create succeeded for subscription %d, database ID: %d" , subId , databaseId )
@@ -436,14 +436,12 @@ func resourceRedisCloudEssentialsDatabaseCreate(ctx context.Context, d *schema.R
436436 // Confirm Subscription Active status
437437 err = waitForEssentialsDatabaseToBeActive (ctx , subId , databaseId , api )
438438 if err != nil {
439- utils .SubscriptionMutex .Unlock (subId )
440439 return diag .FromErr (err )
441440 }
442441
443442 // Some attributes on a database are not accessible by the subscription creation API.
444443 // Run the subscription update function to apply any additional changes to the databases (enableDefaultUser)
445444 // Others are omitted here _because_ the update will take care of them, such as tags
446- utils .SubscriptionMutex .Unlock (subId )
447445 return resourceRedisCloudEssentialsDatabaseUpdate (ctx , d , meta )
448446}
449447
0 commit comments