-
Notifications
You must be signed in to change notification settings - Fork 236
Deadlock on destroy #98
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
Comments
It seems like that we are experiencing the same issue. Sometimes the deletion never finishes and sometimes it does finish within some minutes. |
Not sure that it is the same instance of the same issue, but we are observing a very similar problem on a different situation. We have a Then we do a |
Some information about how we implement a workaround. First, some context. ContextWe have multiple WorkaroundThe workaround is to use 2 different Terraform providers provider "postgresql" {
scheme = "postgres"
host = "http://localhost:5432"
username = "postgres"
password = "postgres"
# Force sequential creation since 'postgresql' provider
# does not handle correctly concurrency calls to the DB
# https://github.com/cyrilgdn/terraform-provider-postgresql/issues/178
max_connections = 1
}
provider "postgresql" {
alias = "database"
scheme = "postgres"
host = "http://localhost:5432"
username = "postgres"
password = "postgres"
# Do not put 'max_connections = 1` for database because of the following bug
# https://github.com/cyrilgdn/terraform-provider-postgresql/issues/98
# This is the only reason of existence of this provider,
# used for creating the only 'postgresql_database' resource (see alias).
# max_connections = 1
}
resource "random_password" "pg" {
length = 32
special = false
}
resource "postgresql_role" "me" {
name = "me"
login = true
password = random_password.pg.result
}
resource "postgresql_database" "mydb" {
# Here, we force the use of the second provider, only for this resource
provider = postgresql.database
owner = postgresql_role.me.name
name = "mydb"
}
resource "postgresql_grant" "database" {
database = postgresql_database.mydb.name
role = postgresql_role.me.name
object_type = "database"
privileges = [
"CONNECT",
"CREATE",
]
}
resource "postgresql_grant" "schema" {
database = postgresql_database.mydb.name
role = postgresql_role.me.name
schema = "public"
object_type = "schema"
privileges = [
"CREATE",
"USAGE",
]
}
resource "postgresql_grant" "table" {
database = postgresql_database.mydb.name
role = postgresql_role.me.name
schema = "public"
object_type = "table"
privileges = [
"DELETE",
"INSERT",
"REFERENCES",
"SELECT",
"TRUNCATE",
"UPDATE",
]
} Hope this helps. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I triggered a deadlock when I try to run terraform destroy. I try to isolate as much as possible by reducing my TF file. With the provided file, it's a 50% chance of deadlock when trying to destroy.
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Should destroy all ressources
Actual Behavior
Steps to Reproduce
Sometime it take 2 or 3 times to trigger the dead lock
Other informations
Thank you for your work !
The text was updated successfully, but these errors were encountered: