Skip to content

Commit

Permalink
Merge pull request #128 from k-yomo/fix-to-unlock-when-error
Browse files Browse the repository at this point in the history
Fix to unlock when returning error
  • Loading branch information
k-yomo authored Aug 30, 2022
2 parents 267fb40 + 3558074 commit ef30d3d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/provider/resource_virtual_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ func resourceVirtualIndexCreate(ctx context.Context, d *schema.ResourceData, m i
mutexKV.Lock(ctx, algoliaIndexMutexKey(apiClient.appID, primaryIndexName))
primaryIndexSettings, err := primaryIndex.GetSettings(ctx)
if err != nil {
mutexKV.Unlock(ctx, algoliaIndexMutexKey(apiClient.appID, primaryIndexName))
return diag.FromErr(err)
}
replicas := primaryIndexSettings.Replicas.Get()
Expand All @@ -584,9 +585,11 @@ func resourceVirtualIndexCreate(ctx context.Context, d *schema.ResourceData, m i
Replicas: opt.Replicas(newReplicas...),
})
if err != nil {
mutexKV.Unlock(ctx, algoliaIndexMutexKey(apiClient.appID, primaryIndexName))
return diag.FromErr(err)
}
if err := res.Wait(); err != nil {
mutexKV.Unlock(ctx, algoliaIndexMutexKey(apiClient.appID, primaryIndexName))
return diag.FromErr(err)
}
}
Expand Down

0 comments on commit ef30d3d

Please sign in to comment.