cyrilgdn / terraform-provider-postgresql

Terraform PostgreSQL provider
https://www.terraform.io/docs/providers/postgresql/
Mozilla Public License 2.0
359 stars 182 forks source link

Postgres provider creating new connection for every state check related to database, schema, roles, grants etc.. #255

Open mchhataniClearCover opened 1 year ago

mchhataniClearCover commented 1 year ago

Hi there,

Thank you for opening an issue. Please provide the following information:

Terraform Version

Terraform v1.2.8 on darwin_amd64

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

Debug Output

Panic Output

Expected Behavior

Use the same connection.

Actual Behavior

  1. We are using TF postgres provider to manager database, extension , schema, roles, grants , replication slot.
  2. We have implemented Atlantis to automatically plan the TF changes.
  3. For connecting to database, we use AWS VPC private Link + Network Load Balancer to talk to the database.
  4. When checking the postgres logs , it seems like for every status check with TF configuration and actual values in DB, a new connection is established, this leads to slowness sometimes when we use VPC link.

Steps to Reproduce

Important Factoids

References

Anton-Shutik commented 1 year ago

That might fix this issue as well. #289

seanamos commented 9 months ago

I spent some time looking at this because our postgres resources plan/apply relatively slowly compared to other providers/resources (especially our MSSQL resources). With a small amount of resources (<20), it's not that big of a problem, but when you get to >50, it really starts adding up in the plan/apply time.

I do believe the lack of connection re-use is one of the primary reasons it is quite slow.