Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add retry on db replica create #907

Merged

Conversation

DMW2151
Copy link
Contributor

@DMW2151 DMW2151 commented Nov 23, 2022

Implements fix for #906 by adding more permissive retry logic in two places:

  • Call to client.Databases.CreateReplica in resourceDigitalOceanDatabaseReplicaCreate now allows 412 as a retryable error.
  • Call to GetReplica in waitForDatabaseReplica allows 404 while replica creates. Same logic as currently used in resourceDigitalOceanDatabaseClusterCreate.

With the change, one can run a plan that creates a DB and replica as shown below without running into race condition on replica create:

resource "digitalocean_database_replica" "read-replica" {
  cluster_id = digitalocean_database_cluster.postgres-example.id
  name       = "test-postgres-cluster-replica"
  size       = "db-s-1vcpu-1gb"
  region     = "nyc1"
}

resource "digitalocean_database_cluster" "postgres-example" {
  name       = "test-postgres-cluster"
  engine     = "pg"
  version    = "11"
  size       = "db-s-1vcpu-1gb"
  region     = "nyc1"
  node_count = 1
}

Result from apply:

digitalocean_database_cluster.postgres-example: Creating...
...
digitalocean_database_cluster.postgres-example: Creation complete after 3m34s [id=4201c593-eeef-4cac-9465-fade75eaeaee]
digitalocean_database_replica.read-replica: Creating...
...
digitalocean_database_replica.read-replica: Creation complete after 3m53s [id=4201c593-eeef-4cac-9465-fade75eaeaee/replicas/test-postgres-cluster-replica]

Copy link
Member

@bentranter bentranter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bentranter bentranter merged commit 2a9921d into digitalocean:main Nov 24, 2022
@DMW2151 DMW2151 temporarily deployed to Acceptance Tests November 24, 2022 18:03 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants