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

Update database connections defaults #5853

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jananiarunachalam
Copy link

@jananiarunachalam jananiarunachalam commented Feb 9, 2025

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality

Description of change

Which issue this PR fixes
Fixes #5802

@amartinezfayo amartinezfayo self-assigned this Feb 11, 2025
Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jananiarunachalam for working on this contribution!

Comment on lines +1068 to +1072
defaultConnMaxLifetime, err := time.ParseDuration("30s")
db.DB().SetConnMaxLifetime(defaultConnMaxLifetime) // default value
if err != nil {
return nil, "", false, nil, fmt.Errorf("failed to parse conn_max_lifetime %q: %w", defaultConnMaxLifetime, err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SetConnMaxLifetime function is already called later, based on the ConnMaxLifetime setting.
We don't need to make any change there. What we need to adjust is the ConnMaxIdleTime property calling SetConnMaxIdleTime, maybe with a value of 30s.
Also note that you will not need to make any parsing for that (i.e. time.ParseDuration("30s")), you can just call SetConnMaxIdleTime(time.Second * 30). We may define this as a constant in the function, and probably the MaxOpenConns and MaxIdleConns numbers too.

@sorindumitru
Copy link
Collaborator

Also, could you update the documentation in https://github.com/spiffe/spire/blob/main/doc/plugin_server_datastore_sql.md with the new defaults?

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

Successfully merging this pull request may close these issues.

Consider changing defaults for database connections
3 participants