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

tuple concurrently updated error when granting priviliges on same database for multiple users #223

Closed
timothegenzmer opened this issue Jun 23, 2022 · 2 comments · Fixed by #224

Comments

@timothegenzmer
Copy link
Contributor

Terraform Version

Terraform v1.2.3
on darwin_amd64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.16.0

Affected Resource(s)

  • postgresql_grant

Terraform Configuration Files

terraform {
  required_version = ">= 1.0"

  required_providers {
    postgresql = {
      source  = "cyrilgdn/postgresql"
      version = ">=1.16"
    }
  }
}

provider "postgresql" {
  port            = 5432
  database        = "postgres"
  username        = "postgres"
  password        = "password"
  sslmode         = "disable"
  superuser = false
}

resource "postgresql_role" "demo" {
  name     = "demo"
  login    = true
  password = "demo"
}

resource "postgresql_role" "demo2" {
  name     = "demo2"
  login    = true
  password = "demo"
}

resource "postgresql_grant" "demo" {
  database    = "postgres"
  role        = postgresql_role.demo.name
  object_type = "database"
  privileges  = ["CONNECT"]
}

resource "postgresql_grant" "demo2" {
  database    = "postgres"
  role        = postgresql_role.demo2.name
  schema      = "public"
  object_type = "database"
  privileges  = ["CONNECT"]
}

Debug Output

https://gist.github.com/timothegenzmer/c918c3d50acae32c83fade871167d283

Expected Behavior

The provider is able to grant multiple privileges on the same database for multiple users without error

Actual Behavior

Postgres error that a tuple is updated concurrently

╷
│ Error: could not execute revoke query: pq: tuple concurrently updated
│
│   with postgresql_grant.demo,
│   on main.tf line 45, in resource "postgresql_grant" "demo":
│   45: resource "postgresql_grant" "demo" {
│
╵

Steps to Reproduce

  1. terraform apply

References

This seems to be similar to
#215
#178
#169

@philip-harvey
Copy link

This seems to be duplicate of #178

@timothegenzmer
Copy link
Contributor Author

#178 is different in that it is about granting permissions on a schema and a database for the same role.

This issue is about granting permissions on the same database for different roles.
It might be a duplicate nevertheless

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 a pull request may close this issue.

2 participants