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

MultiTenancy - Large Migrations #3205

Open
jmortlock opened this issue Oct 28, 2024 · 2 comments
Open

MultiTenancy - Large Migrations #3205

jmortlock opened this issue Oct 28, 2024 · 2 comments

Comments

@jmortlock
Copy link

When running large migrations with multi-tenancy setup (MySql) we are hitting this error

Error: driver: bad connection

This happens after a long migration and before the start of the next one, I assume the "bad connection' has infact timed out.

@a8m
Copy link
Member

a8m commented Oct 29, 2024

Hey, @jmortlock,

Which command do you use in the multi-tenant setup? Also, what do you consider a "long" migration? How long has it been running?

@jmortlock
Copy link
Author

jmortlock commented Oct 29, 2024

Hi

I can see an example here after 40mins

Error: driver: bad connection
[mysql] 2024/10/28 20:35:11 connection.go:49: bad connection
  -- 12 sql statements
  -- 5 migrations
  -- 39m23.268774378s
  -------------------------

I am running this command to apply the migrations

atlas migrate apply --exec-order non-linear --env aws

Using the setup outlined in your docs, i.e. this sorta thing

env "aws" {
  src = "db/schema.hcl"
  for_each = toset(data.sql.tenants.values)
  url      = urlsetpath(data.runtimevar.url, each.value)
  migration { dir = "file://db/migrations" }
}

I suspect whats happening is because we are using RDS proxy service which has a much tighter default Idle timeout of 30mins (mysql default is 8hours).

Current workaround is to restart the migrations when the error is encountered.

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

2 participants