-
Notifications
You must be signed in to change notification settings - Fork 61
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
[#361] Add a max_connection_age
setting
#365
Conversation
Issue #361
|
Otherwise it looks good |
99be1d0
to
0a6e70a
Compare
Thanks for the feedback! I added new STATE, TRACKER, Prometheus metric, and documentation for |
0a6e70a
to
d1b6157
Compare
doc/CONFIGURATION.md
Outdated
@@ -60,7 +60,8 @@ The available keys and their accepted values are reported in the table below. | |||
| log_connections | `off` | Bool | No | Log connects | | |||
| log_disconnections | `off` | Bool | No | Log disconnects | | |||
| blocking_timeout | 30 | Int | No | The number of seconds the process will be blocking for a connection (disable = 0) | | |||
| idle_timeout | 0 | Int | No | The number of seconds a connection is been kept alive (disable = 0) | | |||
| idle_timeout | 0 | Int | No | The number of seconds a connection is been kept alive since becomes idle (disable = 0) | | |||
| max_connection_age | 0 | Int | No | The number of seconds a connection is been kept alive since starts (disable = 0) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... since it times out"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get it right,
idle_timeout
is "The number of seconds a connection can remain idle before it is automatically closed"max_connection_age
is "The number of seconds a connection can remain active before it is automatically closed if it is not being used"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the maximum seconds that a connection will live - it will be checked upon returned to the pool, or during idle timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I updated the max_connection_age
docs and kept the idle_timeout
docs untouched.
Checking upon returned to the pool is added to pgagroal_return_connection
.
Both ways of checking are tested using a basic setup.
doc/man/pgagroal.conf.5.rst
Outdated
The number of seconds a connection is been kept alive since becomes idle (disable = 0). Default is 0 | ||
|
||
max_connection_age | ||
The number of seconds a connection is been kept alive since starts (disable = 0). Default is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
d1b6157
to
53e9a2d
Compare
src/libpgagroal/pool.c
Outdated
|
||
config = (struct configuration*)shmem; | ||
|
||
/* Kill the connection, if it lives longer than max_connection_age */ | ||
now = time(NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some extra checks here, right ?
Is max_connection_age > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I've tested thses cases this time:
idle_timeout
off,max_connection_age
on, one prefill, no connection / get one connection and then closeidle_timeout
on,max_connection_age
off, one prefill, get one connection and then closeidle_timeout = 20
,max_connection_age = 40
, one prefill, get two connections and then close
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent
53e9a2d
to
c13ca00
Compare
Can you rebase ? |
c13ca00
to
c55b849
Compare
This defines how long a connection will live in seconds - Add a `max_connection_age` member to `struct configuration`. It will be checked upon returned to the pool, or during idle timeout. - Add new STATE, TRACKER, and Prometheus metric for `max_connection_age` - Add documentation for `max_connection_age` - Add a `start_time` member to `struct connection`. Its implementation is similar to `timestamp`
c55b849
to
6112ec6
Compare
Sure, rebased and fixed conflicts |
Merged. Thanks for your contribution ! |
This defines how long a connection will live in seconds
max_connection_age
member tostruct configuration
. Its implementation and related functions are similar toidle_timeout
start_time
member tostruct connection
. Its implementation is similar totimestamp