Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

max_open_conns does not seem to work #127

Open
markusrydh opened this issue Apr 6, 2020 · 3 comments
Open

max_open_conns does not seem to work #127

markusrydh opened this issue Apr 6, 2020 · 3 comments

Comments

@markusrydh
Copy link

Using mysql provider 1.9.0 and max_open_conns set to 2 I still see a massive amount of mysql connections being used.

Terraform Configuration Files

provider "mysql" {
  version = "~> 1.9.0"

  endpoint = "${module.database.endpoint}:3306"
  username = var.db_master_username
  password = var.db_master_password
  max_open_conns = 2
}

Expected Behavior

No more than 2 open connections from the mysql provider plugin at any time.

Actual Behavior

21 observed connections in parallel, then terraform halts due to too many mysql connections.

Steps to Reproduce

I reproduce this even with parallelism is set to 1.

  1. terraform apply -parallelism=1

References

@stevehipwell
Copy link

@markusrydh did you find a resolution to this? We've got the exact same issue!

@markusrydh
Copy link
Author

Not really, but a workaround was to increase the max number of connections on the DB side. I was using AWS RDS and even for small DBs it is possible to increase it from the (low) default to a level where this no longer was a problem.

@gilesrapkin
Copy link

Setting the max_conn_lifetime_sec to 10 seemed to work for me as a workaround. It feels like the provider isn't re-using existing connections on subsequent requests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants