Your Question

How to approach password renewal, IAM authentication?

The current approach for Postres: Alter the dialector's Initialize(db *gorm.DB) (err error) where the db.ConnPool returned is through a custom function. This function returns a wrapper of the pgx and is a driver connector. Here's the relevant part the wrapper Connect(ctx context.Context) (driver.Conn, error) function, which is used to open new connections:

func (config *IamAuthDbDriver) Connect(ctx context.Context) (driver.Conn, error) {
    // fetch a fresh token with IAM connection string, from AWS
    dsn, err := GetIAMConnString()
    // err check

    pgxDriver := &stdlib.Driver{}
    connector, err := pgxDriver.OpenConnector(dsn)
    // err check

    return connector.Connect(ctx)
}

With some soft tests, this worked as expected. However, when tested on a service with a high volume of SQL transactions, with three different databases, I am getting this error, at random time intervals (the exact statement name varies):

ERROR: prepared statement "lrupsc_17_0" does not exist (SQLSTATE 26000)

I am investigating this problem further, along with the option to sql.register(MyIAMDriver) and pass the name to the gorm dialector's config.

The document you expected this should be explained

official documents site

Expected answer

What to fix in the current approach to prevent missing prepared statements from occurring randomly, or suggestion of a different approach - register custom driver or other.

Comment From: github-actions[bot]

This issue has been automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

Comment From: cgetzen

Hi @Kantonov, curious if you ever figured out what this error was.