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

Too many connections / connection pool size control #76

Open
gwilym opened this issue Apr 17, 2019 · 1 comment
Open

Too many connections / connection pool size control #76

gwilym opened this issue Apr 17, 2019 · 1 comment

Comments

@gwilym
Copy link

gwilym commented Apr 17, 2019

This is more of a feature request rather than a bug report, so the PR template below is only tersely completed. If more data is required I can provide as needed, but I think this request is fairly self-explanatory: could we please get some control over the connection pool size for terraform-mysql?

If some control already exists and I just haven't looked hard enough, apologies, please guide me 😁

Since Terraform attempts to run with a parallelism of 10 by default, this can cause issues if you have several providers pointing to the same, small MySQL server, contributing to the overall connection count on the server. In our case, we see connections spike from 60 to 90 at which point our configured limit is hit and Terraform begins to fail (as well as other apps actively using the server).

We'd prefer to not raise this configured limit, nor would we want to limit Terraform's parallelism for everything else, instead we'd prefer to limit how many connections Terraform will try to make per MySQL provider.

As I understand it, the default connection pool size for databases in Go is 0 (unlimited). An option on the provider block would be welcome.

Terraform Version

0.11.13

Affected Resource(s)

Please list the resources as a list, for example:

  • Any mysql_* resource

Terraform Configuration Files

None. This is going to depend greatly on your server setup so I haven't produced a minimal TF config set for this. If needed I will try to produce one but it would also require a mysql server configured with a low connection limit.

Debug Output

None. Though, can investigate if required.

Panic Output

None.

Expected Behavior

The MySQL provider respected a configurable, per-provider connection pool size.

Actual Behavior

Apply fails for some resources with "too many connections" error from server. Other apps using the same server/s also begin emitting the same errors. Monitoring shows upwards of 30+ connections simultaneous connections being started from Terraform.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Terraform running on EC2, against RDS Aurora/MySQL, instance size: db.t2.medium (default max 90 connections)

References

None, though, #71 is requesting a similar type of additional control over connection management.

@kostya2011
Copy link

kostya2011 commented May 7, 2019

+1
As a temporary work-around db.SetMaxIdleConns(N) might be added to connectToMySQL function, so idle connections will be dropped, after their number reach the threshold N

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

2 participants