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

chore: tune shared db connection pooling #4213

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

atzoum
Copy link
Contributor

@atzoum atzoum commented Dec 7, 2023

Description

Trying to minimise each rudder-server's footprint on the overall number of shared postgres's connections

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link
Contributor

coderabbitai bot commented Dec 7, 2023

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@atzoum atzoum changed the base branch from master to release/v1.18.x December 7, 2023 09:36
@atzoum atzoum changed the title Chore.tune shared db conns chore: tune shared db conns Dec 7, 2023
@atzoum atzoum changed the title chore: tune shared db conns chore: tune shared db connection pooling Dec 7, 2023
@atzoum atzoum marked this pull request as ready for review December 7, 2023 09:51
Copy link

codecov bot commented Dec 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a894473) 74.40% compared to head (2745564) 72.66%.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           release/v1.18.x    #4213      +/-   ##
===================================================
- Coverage            74.40%   72.66%   -1.74%     
===================================================
  Files                  397      387      -10     
  Lines                58330    56488    -1842     
===================================================
- Hits                 43399    41049    -2350     
- Misses               12623    13068     +445     
- Partials              2308     2371      +63     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -192,5 +192,7 @@ func setupDBConn(conf *config.Config) (*sql.DB, error) {
if err := db.Ping(); err != nil {
return nil, fmt.Errorf("db ping: %v", err)
}
db.SetMaxIdleConns(conf.GetInt("drainConfig.maxIdleConns", 1))
db.SetMaxOpenConns(conf.GetInt("drainConfig.maxOpenConns", 2))
Copy link
Member

Choose a reason for hiding this comment

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

We could get away with db.SetMaxOpenConns(1) if we remove the two drainConfig routines from gatewayAppHandler.
As for processor, both routines can carry on with one connection imo.

@@ -202,6 +203,9 @@ func NewJobService(config JobServiceConfig) (JobService, error) {
if config.MaxPoolSize <= 2 {
config.MaxPoolSize = 2 // minimum 2 connections in the pool for proper startup
}
if config.MinPoolSize <= 0 {
Copy link
Member

Choose a reason for hiding this comment

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

why not an upper limit for both of them too..?

maxConns := lo.Clamp(config.MaxPoolSize, 2, 3)
minConss := lo.Clamp(config.MinPoolSize, 1, 2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need to limit a configuration option that is there just for overriding it in case we face some issue in production

Copy link
Member

Choose a reason for hiding this comment

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

true

@cisse21 cisse21 merged commit 01c90fc into release/v1.18.x Dec 7, 2023
42 checks passed
@cisse21 cisse21 deleted the chore.tuneSharedDBConns branch December 7, 2023 11:34
This was referenced Jan 15, 2024
This was referenced Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants