Skip to content

Add connection lifetime limit option and tests#2668

Closed
ChrisWritable wants to merge 0 commit into
brianc:masterfrom
ChrisWritable:master
Closed

Add connection lifetime limit option and tests#2668
ChrisWritable wants to merge 0 commit into
brianc:masterfrom
ChrisWritable:master

Conversation

@ChrisWritable
Copy link
Copy Markdown
Contributor

This addresses issue #2027 "Add optional maximum connection lifetime parameter"
#2027

Adds the optional maxLifetimeSeconds parameter to the Pool constructor. If the parameter is left undefined or zero there is no change in behavior. When the parameter is set, it specifies a number of seconds to wait before recycling a connection. It waits until the connection is idle before recycling.

Copy link
Copy Markdown
Collaborator

@charmander charmander left a comment

Choose a reason for hiding this comment

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

Juggling indices (which change when you splice) feels uncomfortable. How about adding clients that are checked out when they expire to a WeakSet, then checking for previous expiration that way in release?

Also, this PR changes the mode of packages/pg-pool/index.js; could you revert that? (Or I can.)

@ChrisWritable
Copy link
Copy Markdown
Contributor Author

I believe I've made the changes requested. Let me know if this newer pull request 3ea8ff2 isn't what you were asking for.

Copy link
Copy Markdown
Collaborator

@charmander charmander left a comment

Choose a reason for hiding this comment

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

Yep, exactly!

Comment thread packages/pg-pool/index.js Outdated
Comment thread packages/pg-pool/test/lifetime-timeout.js Outdated
Comment thread packages/pg-pool/index.js Outdated
Comment thread packages/pg-pool/index.js Outdated
Comment thread packages/pg-pool/index.js Outdated
@ChrisWritable
Copy link
Copy Markdown
Contributor Author

I've updated the patch. Let me know what you think.

@hempels
Copy link
Copy Markdown

hempels commented Jan 26, 2022

@brianc Any thoughts on this PR? Would love to see it incorporated into node-postgres sooner than later if it passes muster.

@brianc
Copy link
Copy Markdown
Owner

brianc commented Jan 26, 2022

Yeah it looks good, sorry for missing this. I'll try to get this released today!

@brianc
Copy link
Copy Markdown
Owner

brianc commented Jan 26, 2022

@ChrisWritable - would it be possible to rebase this PR on top of current master of this repo? Because the tests haven't been run in CI on this PR AFAICT - I ported them to run on github actions so if you rebase on master & push back to this PR it should run them. Then I will merge. Thanks for your patience!

@brianc
Copy link
Copy Markdown
Owner

brianc commented Jan 28, 2022

Thanks for the PR @ChrisWritable - just FYI in the future if you don't want to open a new PR I'm pretty sure force pushing to your existing branch will just update the existing PR w/ the new commits or history. Either way works though!

@ChrisWritable
Copy link
Copy Markdown
Contributor Author

Ok. Thanks.

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.

4 participants