I am fairly certain the reconnection details, etc will be driver specific.  

Many dbs will not drop the current connections when changing passwords - only used when a new connection is created. 

The easiest solution is to set the max connection lifetime on the pool, and change the password there to match. 

How you coordinate that will be more involved. 

Might be easier to detect the invalid password error and reset the pool. 



On Jul 29, 2024, at 7:32 AM, prasa...@gmail.com <prasad....@gmail.com> wrote:

I have a long running daemon written in Go, that listens to a port and spins up multiple go routines for every new connection to handle the data. There is a global variable context that has db Conn(*sql.DB) that is assigned connection context returned by database/sql library’s open() function during initialization time.
for security reasons we want to rotate db username & password periodically. I'm looking for best possible way to achieve same but i'm not able to find any pointers to it in documentation. Can anyone please suggest methods to handle the same?
I'm also not able find info about auto reconnecting details in case of DB failure. Just wondering how long driver will keep retyring in case of DB shutdown or failure?

closest one that i got is:  https://stackoverflow.com/questions/61921525/how-to-update-db-connection-in-gorm-with-new-aws-token/77287404#77287404.  but its good for only postgress.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/db61ab36-ed98-4b86-bdd3-7125fe85e284n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/09ABA647-58EA-4F33-923B-8AA2461FFDE8%40ix.netcom.com.

Reply via email to