I want to use
Vault to manage and rotate the usernames and passwords to my databases.
If I open a connection: db, err := sql.Open("mysql", "...."), and then later on, open a new connection due to the username/password being rotated: db, err = sql.Open("mysql", "...") //no new variables created,
will the original sql instance leak? I want to avoid having to force all current queries and executions on the old db to terminate using Close(), as I would need to have some mutex to act as a gatekeeper for all interactions with the database, which would be quite complex.
Ideally, I would prefer the following:
1. New username/password pair received and sql.Open() is called.
2. Old db instance is still being used by a few goroutines as they still hold references to the old sql instance.
3. Goroutines finishes and no longer hold references to the old sql instance. The old sql instance is GC'd. Is this possible without calling Close()?
4. New goroutines are launched and they use the new sql instance.
Cheers,
Francis