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

concurrency issue when granting privileges on tables with postgresql_grant #425

Closed
vedata opened this issue Mar 28, 2024 · 3 comments
Closed

Comments

@vedata
Copy link

vedata commented Mar 28, 2024

Hi there,

We're encountering a persistent issue during the execution of Terraform apply, consistently receiving the error message: "Error: Could not execute revoke query: pq: tuple concurrently updated." Despite upgrading the provider to cyrilgdn/postgresql 1.18.0, the error remains unresolved

Terraform Version

Terraform v1.5.0

Affected Resource(s)

  • postgresql_grant

Terraform Configuration Files

resource "postgresql_grant" "rw_role_table_crud" {
  depends_on = [postgresql_schema.public]
  count      = var.create_rw_role ? 1 : 0

  database    = postgresql_database.service_database[0].name
  role        = postgresql_role.rw_role[0].name
  object_type = "table"
  schema      = "public"
  privileges  = ["INSERT", "SELECT", "UPDATE", "DELETE", "TRUNCATE"]
}

resource "postgresql_grant" "ro_role_table_crud" {
  depends_on = [postgresql_schema.public]
  count      = var.create_ro_role ? 1 : 0

  database    = postgresql_database.service_database[0].name
  role        = postgresql_role.ro_role[0].name
  object_type = "table"
  schema      = "public"
  privileges  = ["SELECT"]
}

Expected Behavior

resource "postgresql_grant" "rw_role_table_crud" {
depends_on = [postgresql_schema.public]
count = var.create_rw_role ? 1 : 0

database = postgresql_database.service_database[0].name
role = postgresql_role.rw_role[0].name
object_type = "table"
schema = "public"
privileges = ["INSERT", "SELECT", "UPDATE", "DELETE", "TRUNCATE"]
}

resource "postgresql_grant" "ro_role_table_crud" {
depends_on = [postgresql_schema.public]
count = var.create_ro_role ? 1 : 0

database = postgresql_database.service_database[0].name
role = postgresql_role.ro_role[0].name
object_type = "table"
schema = "public"
privileges = ["SELECT"]
}

Actual Behavior

│ Error: could not execute revoke query: pq: tuple concurrently updated

│ with module.cp-database.postgresql_grant.rw_role_table_crud[0],
│ on ../../modules/postgresql-db/main.tf line 155, in resource "postgresql_grant" "rw_role_table_crud":
│ 155: resource "postgresql_grant" "rw_role_table_crud" {



│ Error: could not execute revoke query: pq: tuple concurrently updated

│ with module.cp-database.postgresql_grant.ro_role_table_crud[0],
│ on ../../modules/postgresql-db/main.tf line 244, in resource "postgresql_grant" "ro_role_table_crud":
│ 244: resource "postgresql_grant" "ro_role_table_crud" {

Steps to Reproduce

  1. terraform apply

Important Factoids

The DB is running on AWS RDS with Engine version: 13.11

References

@enricojonas
Copy link

Same issue for us, need to apply several times.

@vedata vedata closed this as completed May 3, 2024
@vedata
Copy link
Author

vedata commented May 3, 2024

Removed table lock in DB

@kkapoorOS
Copy link

Why was this issue closed? I'm still seeing this issue even with version 1.22. The issue is also flaky, as it doesn't happen all the time. Applying with -parallelism=1 is a workaround that has worked for us (so far), but it is definitely not ideal! Please re-open and address

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

No branches or pull requests

3 participants