-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Database driver closes the connection pool #578
Comments
Thanks for the report! If I understand correctly, you'd like func (m *Mysql) Close() error {
connErr := m.conn.Close()
dbErr := m.db.Close()
if connErr != nil || dbErr != nil {
return fmt.Errorf("conn: %v, db: %v", connErr, dbErr)
}
return nil
} The issue is that an instance of the DB driver can be created via |
Since I am the one injecting
Yes, I understand and agree with this concern.
That would be a quick and easy solution that would help, but I'm wondering that this behaviour could get misunderstood, forgotten and get broken in the future 🤔 . Alternatively, since this class only ever uses |
Oh yeah, it'd still be the driver's responsibility to call |
Okay, nice. I think I can probably find time around next week to implement that. |
Closing this since it was implemented and resolved in #583 |
Describe the Bug
The
Close
method in the database drivers also closes the injected connection pool (*sql.DB
) object.Expected Behavior
The method returns it's internal connections to the pool, but does not close the pool itself.
Migrate Version
e.g. v4.14.1
Additional context
This is the way we are using this package. As the connection pool is injected, closing it is not the responsibility of this part of the code. The process should end-up with a database pool that is in the same state than in the beginning (pool opened, but all connections are free and not locked by the migration process).
Since the pool is not created by the database driver itself, it is not it's responsibility to close it.
The text was updated successfully, but these errors were encountered: