GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Emit a 'release' event when a connection is released back to the pool by nihonjinrxs · Pull Request #2845 · brianc/node-postgres

Conversation

@nihonjinrxs

@nihonjinrxs nihonjinrxs commented Oct 17, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR has the Pool object emit a 'release' event upon the release of a client/connection back to the pool.

We're experiencing an issue that feels quite similar to what's described in #2262, and in reading through the comments there, I was interested to see @brianc's suggestion of adding a 'release' event as the corresponding bookend to the 'connect' and 'acquire' events. However, in searching the code, it seems this was never implemented, so I've implemented that here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weyert and mamush-m reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nihonjinrxs
Emit a 'release' event when a connection is released back to the pool
f77824c
@nihonjinrxs
nihonjinrxs force-pushed the feature/pg-pool/events/emit-release branch from 7cf4cbe to f77824c Compare October 18, 2022 16:06
@nihonjinrxs
nihonjinrxs marked this pull request as ready for review October 18, 2022 16:12
@nihonjinrxs

nihonjinrxs commented Oct 24, 2022

Copy link
Copy Markdown
Contributor Author

@brianc let me know if you need anything more from me on this. Happy to help get this merged in whatever way you need. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weyert

weyert commented Oct 24, 2022

Copy link
Copy Markdown

Nice, looks like this could also be used to count the number of open connections?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs

nihonjinrxs commented Oct 30, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Nice, looks like this could also be used to count the number of open connections?

@weyert You could, but I think it's probably easier to use the existing properties totalCount and idleCount to understand connection count in the pool. There's also a waitingCount which counts requests waiting for a connection to be available.

If you wanted to do it via events, there are also existing events emitted:

  • connect when a new connection is made to postgres
  • remove when a connection is dropped from the pool

What this PR adds is the balancing release event for the acquire event which is emitted when an existing connection in the pool is acquired to perform a query.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs
nihonjinrxs marked this pull request as draft October 30, 2022 05:08
@nihonjinrxs
nihonjinrxs marked this pull request as ready for review October 30, 2022 05:08
@brianc

brianc commented Nov 21, 2022

Copy link
Copy Markdown
Owner

This looks perfectly good to me! Thank you so much! Agree the symmetry here is nice and kinda long standing silly oversight on my part to not do that to begin with. 😄 ❤️

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brianc

brianc commented Nov 21, 2022

Copy link
Copy Markdown
Owner

okay weirdly....the tests don't seem to have run for this PR? Would you be able to try rebasing on master and see if they run at that point? Since it's a net addition only with like 1 line of change and good test coverage I can also just pull it and run them manually if you don't have time....though I do like every PR to go through CI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs
Merge branch 'brianc:master' into feature/pg-pool/events/emit-release
6b9d1b2
@nihonjinrxs

nihonjinrxs commented Dec 7, 2022

Copy link
Copy Markdown
Contributor Author

Hey @brianc -- sorry for the delay in getting back to this. I've synced my fork, and CI seems to be running. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs

nihonjinrxs commented Dec 28, 2022

Copy link
Copy Markdown
Contributor Author

@brianc Any chance we can get this one merged soon?

orcwarrior reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs

nihonjinrxs commented Jan 24, 2023

Copy link
Copy Markdown
Contributor Author

Hey, @brianc -- sorry to ping again, but it's been a while. Hoping to get this PR merged soon. We're currently operating off of a local branch incorporating this change, and I'd really like to be able to come back to the origin distribution if possible. Let me know if you need anything from me to make this happen. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nihonjinrxs

nihonjinrxs commented Feb 15, 2023

Copy link
Copy Markdown
Contributor Author

@brianc just checking in again -- would love to get this PR merged soon, so we can get off this branch build. Let me know if there's anything more you need here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brianc

brianc commented Mar 6, 2023

Copy link
Copy Markdown
Owner

sorry for delay! Will release it today!

nihonjinrxs reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brianc
brianc merged commit 810b125 into brianc:master Mar 6, 2023
@shleeable shleeable mentioned this pull request Mar 8, 2023
[Dependashlee] Bump pg from 8.5.0 to 8.11.0 (JS) mastodon/mastodon#23815
Closed
@nihonjinrxs
nihonjinrxs deleted the feature/pg-pool/events/emit-release branch March 10, 2023 18:35
@nihonjinrxs nihonjinrxs mentioned this pull request Mar 10, 2023
Add release event to Pool API docs #2928
Merged
@dholms dholms mentioned this pull request Apr 19, 2023
Bump node-postgres version bluesky-social/atproto#846
Merged
nihonjinrxs added a commit to nihonjinrxs/DefinitelyTyped that referenced this pull request May 2, 2023
@nihonjinrxs
Add 'release' event type to pg Pool types
2791804
Added in brianc/node-postgres#2845 and released as part of version 8.10.0.
thijs pushed a commit to thijs/node-postgres that referenced this pull request Aug 1, 2023
@nihonjinrxs thijs
Emit a 'release' event when a connection is released back to the pool (…
eb2dfdf
…brianc#2845)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@nihonjinrxs @weyert @brianc
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.