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

add max and min pool idle config for sql sinks #2367

Merged
merged 17 commits into from
Apr 17, 2024

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Apr 11, 2024

Related #2366

doc about GenericObjectPool
https://commons.apache.org/proper/commons-pool/apidocs/org/apache/commons/pool2/impl/GenericObjectPool.html

$ psql -h localhost -U postgres 
SELECT datname, count(*) FROM pg_stat_activity
  WHERE state = 'idle' GROUP BY datname;

This PR allows change:

  • maxPoolSize
  • maxPoolIdle
  • minPoolIdle
  • minPoolIdleTimeMillis

And fixes default initial values for:

  • maxPoolSize: 3
  • maxPoolIdle: 2
  • minPoolIdle: 0
  • minIddleTimeMillis: 10000

With the following meanings:
// Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time.
gPool.setMaxActive(this.maxPoolSize);

// Sets the cap on the number of "idle" instances in the pool.
gPool.setMaxIdle(this.maxPoolIdle);

// Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects.
gPool.setMinIdle(this.minPoolIdle);

// Sets the minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any)
gPool.setMinEvictableIdleTimeMillis(this.minPoolIdleTimeMillis);

// Sets the number of milliseconds to sleep between runs of the idle object evictor thread
gPool.setTimeBetweenEvictionRunsMillis(this.minPoolIdleTimeMillis*3)

how to see number of idle connections:


@AlvaroVega AlvaroVega changed the title [WIP] add max and min pool idle config for sql sinks add max and min pool idle config for sql sinks Apr 16, 2024
@AlvaroVega AlvaroVega marked this pull request as ready for review April 16, 2024 08:23
@AlvaroVega AlvaroVega requested a review from fgalan April 16, 2024 08:24
@AlvaroVega
Copy link
Member Author

AlvaroVega commented Apr 16, 2024

This is a example about how now cygnus uses a connection, then changes to idle and finally is released

Screenshot from 2024-04-16 11-32-57

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

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

LGTM

@fgalan fgalan merged commit acd8506 into master Apr 17, 2024
7 checks passed
@fgalan fgalan deleted the task/add_min_max_pool_idle_sql_sinks branch April 17, 2024 06:54
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.

2 participants